started fresh
@ -1 +0,0 @@
|
|||||||
101010
|
|
@ -1,16 +0,0 @@
|
|||||||
"""
|
|
||||||
ASGI config for currencyproj project.
|
|
||||||
|
|
||||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from django.core.asgi import get_asgi_application
|
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'currencyproj.settings')
|
|
||||||
|
|
||||||
application = get_asgi_application()
|
|
@ -1,125 +0,0 @@
|
|||||||
"""
|
|
||||||
Django settings for currencyproj project.
|
|
||||||
|
|
||||||
Generated by 'django-admin startproject' using Django 3.1.6.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/3.1/topics/settings/
|
|
||||||
|
|
||||||
For the full list of settings and their values, see
|
|
||||||
https://docs.djangoproject.com/en/3.1/ref/settings/
|
|
||||||
"""
|
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
import os
|
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
||||||
|
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
|
||||||
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
|
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
|
||||||
SECRET_KEY = '%j9h3c5ukt2mom45uiuy_paz+h1*qmqns@)-b0loxk_^bj%eg5'
|
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
|
||||||
DEBUG = True
|
|
||||||
|
|
||||||
ALLOWED_HOSTS = []
|
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
|
||||||
'django.contrib.admin',
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'home',
|
|
||||||
]
|
|
||||||
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'currencyproj.urls'
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'DIRS': [],
|
|
||||||
'APP_DIRS': True,
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
WSGI_APPLICATION = 'currencyproj.wsgi.application'
|
|
||||||
|
|
||||||
|
|
||||||
# Database
|
|
||||||
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
|
||||||
'NAME': BASE_DIR / 'db.sqlite3',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
|
||||||
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
|
|
||||||
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# Internationalization
|
|
||||||
# https://docs.djangoproject.com/en/3.1/topics/i18n/
|
|
||||||
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
|
||||||
# https://docs.djangoproject.com/en/3.1/howto/static-files/
|
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
|
||||||
STATICFILES_DIRS = [
|
|
||||||
os.path.join(BASE_DIR, "static"),
|
|
||||||
]
|
|
@ -1,16 +0,0 @@
|
|||||||
|
|
||||||
from django.contrib import admin
|
|
||||||
from django.urls import path
|
|
||||||
from home.models import upload_video,upload_image
|
|
||||||
# from home.views import upload_content, imageUpload, videoUpload
|
|
||||||
from home.views import finallyUploadImage
|
|
||||||
from home.forms import UploadImage
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
path('admin/', admin.site.urls),
|
|
||||||
# path('upload/',upload_content, name="upload"),
|
|
||||||
# path('upload_video/',videoUpload,name='upload_video'),
|
|
||||||
# path('upload_image/',imageUpload,name='upload_image'),
|
|
||||||
path('upload/',finallyUploadImage,name="Plsman")
|
|
||||||
|
|
||||||
]
|
|
@ -1,16 +0,0 @@
|
|||||||
"""
|
|
||||||
WSGI config for currencyproj project.
|
|
||||||
|
|
||||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'currencyproj.settings')
|
|
||||||
|
|
||||||
application = get_wsgi_application()
|
|
@ -1,5 +0,0 @@
|
|||||||
from django.contrib import admin
|
|
||||||
from .models import upload_image, upload_video
|
|
||||||
|
|
||||||
admin.site.register(upload_image)
|
|
||||||
admin.site.register(upload_video)
|
|
@ -1,5 +0,0 @@
|
|||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class HomeConfig(AppConfig):
|
|
||||||
name = 'home'
|
|
@ -1,9 +0,0 @@
|
|||||||
from django import forms
|
|
||||||
from .models import upload_image
|
|
||||||
|
|
||||||
class UploadImage(forms.ModelForm):
|
|
||||||
class Meta:
|
|
||||||
model = upload_image
|
|
||||||
fields = [
|
|
||||||
'image'
|
|
||||||
]
|
|
@ -1,22 +0,0 @@
|
|||||||
# Generated by Django 3.1.6 on 2021-02-05 00:24
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
initial = True
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='upload',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('image', models.FileField(upload_to='images/')),
|
|
||||||
('video', models.FileField(upload_to='videos/')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]
|
|
@ -1,30 +0,0 @@
|
|||||||
# Generated by Django 3.1.6 on 2021-02-05 00:37
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('home', '0001_initial'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='upload_image',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('image', models.FileField(upload_to='images/')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='upload_video',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('video', models.FileField(upload_to='videos/')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
migrations.DeleteModel(
|
|
||||||
name='upload',
|
|
||||||
),
|
|
||||||
]
|
|
@ -1,23 +0,0 @@
|
|||||||
# Generated by Django 3.1.6 on 2021-02-05 12:13
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('home', '0002_auto_20210205_0037'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='upload_image',
|
|
||||||
name='image',
|
|
||||||
field=models.FileField(upload_to='static/images/'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='upload_video',
|
|
||||||
name='video',
|
|
||||||
field=models.FileField(upload_to='static/videos/'),
|
|
||||||
),
|
|
||||||
]
|
|
@ -1,23 +0,0 @@
|
|||||||
# Generated by Django 3.1.6 on 2021-02-05 12:16
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('home', '0003_auto_20210205_1213'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='upload_image',
|
|
||||||
name='image',
|
|
||||||
field=models.FileField(upload_to='images/'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='upload_video',
|
|
||||||
name='video',
|
|
||||||
field=models.FileField(upload_to='videos/'),
|
|
||||||
),
|
|
||||||
]
|
|
@ -1,8 +0,0 @@
|
|||||||
from django.db import models
|
|
||||||
|
|
||||||
class upload_image(models.Model):
|
|
||||||
# check for file extensions
|
|
||||||
image = models.FileField(upload_to="images/")
|
|
||||||
|
|
||||||
class upload_video(models.Model):
|
|
||||||
video = models.FileField(upload_to="videos/")
|
|
@ -1,13 +0,0 @@
|
|||||||
{% extends 'uploadImage.html' %}
|
|
||||||
{% block replace %}
|
|
||||||
<div class="jumbotron">
|
|
||||||
<h1 class="display-4">Welcome to DataFlair<br>Hello {{ user_pr.fname }}</h1>
|
|
||||||
<p class="lead">its an awesome profile picture</p>
|
|
||||||
<hr class="my-4">
|
|
||||||
{% load static %}
|
|
||||||
<img src="{% static user_pr.image.url %}" class="image_responsive" height="100px" width="100px">
|
|
||||||
<p>
|
|
||||||
{{ user_pr.display_picture.url }}<BR>
|
|
||||||
You have learned some awesome technologies like {{ user_pr.technologies }}</p>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
@ -1,10 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" dir="ltr">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title></title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>404</h1>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,20 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" dir="ltr">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title></title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<form action="" method="POST">{% csrf_token %}
|
|
||||||
<label for="choice">What are we gonna upload today?</label>
|
|
||||||
<select name="choices" id="choices">
|
|
||||||
<option value="image">Picture</option>
|
|
||||||
<option value="video">Video</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<button type="submit"> Submit </button>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,25 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Make Profile</title>
|
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<div class="jumbotron">
|
|
||||||
<h1 class="display-4">DataFlair Django File Uploading</h1>
|
|
||||||
{% block replace %}
|
|
||||||
<p class="lead">To make a user profile and upload the files fill this form</p>
|
|
||||||
<hr class="my-4">
|
|
||||||
<form method="POST" enctype="multipart/form-data">
|
|
||||||
{% csrf_token %}
|
|
||||||
<table>
|
|
||||||
{{ form.as_table }}
|
|
||||||
</table>
|
|
||||||
<input type="submit" class="btn btn-primary btn-lg" name="register">
|
|
||||||
</div>
|
|
||||||
</center>
|
|
||||||
{% endblock %}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,10 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" dir="ltr">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>test2</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>test2</h1>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,3 +0,0 @@
|
|||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
|
@ -1,67 +0,0 @@
|
|||||||
# from django.shortcuts import render, redirect
|
|
||||||
# import os
|
|
||||||
# from .models import upload_video,upload_image
|
|
||||||
#
|
|
||||||
# def imageUpload(request):
|
|
||||||
# if request.method == "GET":
|
|
||||||
# return render(request, "uploadImage.html")
|
|
||||||
# elif request.method == "POST":
|
|
||||||
# image = request.POST["image"]
|
|
||||||
# # add the id of the user, after you add in users
|
|
||||||
# savingImage = open(f"../images/{image}","w")
|
|
||||||
# for i in image:
|
|
||||||
# savingImage.write(i)
|
|
||||||
# savingImage.close()
|
|
||||||
# return redirect(f"/images/{image}")
|
|
||||||
# else:
|
|
||||||
# return
|
|
||||||
#
|
|
||||||
# def videoUpload(request):
|
|
||||||
# if request.method == "GET":
|
|
||||||
# return render(request, "uploadVideo.html")
|
|
||||||
# elif request.method == "POST":
|
|
||||||
# video = request.POST["video"]
|
|
||||||
# # add the id of the user, after you add in users
|
|
||||||
# return upload_video(video)
|
|
||||||
# else:
|
|
||||||
# return
|
|
||||||
#
|
|
||||||
# # these functions do the same thing, but i cant merge them in one, because i cant add parameters(because of request)
|
|
||||||
#
|
|
||||||
# def upload_content(request):
|
|
||||||
# if request.method == "GET":
|
|
||||||
# return render(request, "index.html")
|
|
||||||
# elif request.method == "POST":
|
|
||||||
# choice = request.POST["choices"]
|
|
||||||
# if choice == "image":
|
|
||||||
# return redirect("/upload_image/")
|
|
||||||
# elif choice == "video":
|
|
||||||
# return redirect("/upload_video/")
|
|
||||||
# else:
|
|
||||||
# return
|
|
||||||
# else:
|
|
||||||
# return
|
|
||||||
# # in conclusion - im genious, good job boyan lmao
|
|
||||||
|
|
||||||
|
|
||||||
from django.shortcuts import render
|
|
||||||
from .forms import UploadImage
|
|
||||||
from .models import upload_image
|
|
||||||
|
|
||||||
IMAGE_FILE_TYPES = ['png', 'jpg', 'jpeg']
|
|
||||||
|
|
||||||
def finallyUploadImage(request):
|
|
||||||
form = UploadImage()
|
|
||||||
if request.method == 'POST':
|
|
||||||
form = UploadImage(request.POST, request.FILES)
|
|
||||||
if form.is_valid():
|
|
||||||
user_pr = form.save(commit=False)
|
|
||||||
user_pr.image = request.FILES['image']
|
|
||||||
file_type = user_pr.image.url.split('.')[-1]
|
|
||||||
file_type = file_type.lower()
|
|
||||||
if file_type not in IMAGE_FILE_TYPES:
|
|
||||||
return render(request, 'error.html')
|
|
||||||
user_pr.save()
|
|
||||||
return render(request, 'details.html', {'user_pr': user_pr})
|
|
||||||
context = {"form": form,}
|
|
||||||
return render(request, 'uploadImage.html', context)
|
|
Before Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 8.5 KiB |
@ -1,22 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""Django's command-line utility for administrative tasks."""
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
"""Run administrative tasks."""
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'currencyproj.settings')
|
|
||||||
try:
|
|
||||||
from django.core.management import execute_from_command_line
|
|
||||||
except ImportError as exc:
|
|
||||||
raise ImportError(
|
|
||||||
"Couldn't import Django. Are you sure it's installed and "
|
|
||||||
"available on your PYTHONPATH environment variable? Did you "
|
|
||||||
"forget to activate a virtual environment?"
|
|
||||||
) from exc
|
|
||||||
execute_from_command_line(sys.argv)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
Before Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 64 KiB |