diff --git a/website/db.sqlite3 b/website/db.sqlite3 index cd50d136..f794a7bc 100644 Binary files a/website/db.sqlite3 and b/website/db.sqlite3 differ diff --git a/website/home/__pycache__/admin.cpython-36.pyc b/website/home/__pycache__/admin.cpython-36.pyc new file mode 100644 index 00000000..c7725463 Binary files /dev/null and b/website/home/__pycache__/admin.cpython-36.pyc differ diff --git a/website/home/__pycache__/models.cpython-36.pyc b/website/home/__pycache__/models.cpython-36.pyc new file mode 100644 index 00000000..089fc763 Binary files /dev/null and b/website/home/__pycache__/models.cpython-36.pyc differ diff --git a/website/home/__pycache__/views.cpython-36.pyc b/website/home/__pycache__/views.cpython-36.pyc new file mode 100644 index 00000000..9640f227 Binary files /dev/null and b/website/home/__pycache__/views.cpython-36.pyc differ diff --git a/website/static/akmddGB.png b/website/static/akmddGB.png new file mode 100644 index 00000000..e69de29b diff --git a/website/templates/uploadChoice.html b/website/templates/uploadChoice.html new file mode 100644 index 00000000..9ca7d295 --- /dev/null +++ b/website/templates/uploadChoice.html @@ -0,0 +1,21 @@ +{% extends 'base.html' %} + +{% block title %} Home {% endblock %} + +{% block content %} +{% if user.is_authenticated %} + Hi {{ user.username }}!
+
{% csrf_token %} + + + + + +{% else %} +

You are not logged in

+ Log In +{% endif %} +{% endblock %} diff --git a/website/templates/uploadImage.html b/website/templates/uploadImage.html new file mode 100644 index 00000000..d76abd72 --- /dev/null +++ b/website/templates/uploadImage.html @@ -0,0 +1,17 @@ +{% extends 'base.html' %} + +{% block title %} Home {% endblock %} + +{% block content %} +{% if user.is_authenticated %} + Hi {{ user.username }}!
+ {% csrf_token %} + + + + +{% else %} +

You are not logged in

+ Log In +{% endif %} +{% endblock %} diff --git a/website/upload/__init__.py b/website/upload/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/website/upload/__pycache__/__init__.cpython-36.pyc b/website/upload/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 00000000..fb5f5ec8 Binary files /dev/null and b/website/upload/__pycache__/__init__.cpython-36.pyc differ diff --git a/website/upload/__pycache__/admin.cpython-36.pyc b/website/upload/__pycache__/admin.cpython-36.pyc new file mode 100644 index 00000000..882cca75 Binary files /dev/null and b/website/upload/__pycache__/admin.cpython-36.pyc differ diff --git a/website/upload/__pycache__/models.cpython-36.pyc b/website/upload/__pycache__/models.cpython-36.pyc new file mode 100644 index 00000000..7895cdc3 Binary files /dev/null and b/website/upload/__pycache__/models.cpython-36.pyc differ diff --git a/website/upload/__pycache__/views.cpython-36.pyc b/website/upload/__pycache__/views.cpython-36.pyc new file mode 100644 index 00000000..53f1b077 Binary files /dev/null and b/website/upload/__pycache__/views.cpython-36.pyc differ diff --git a/website/upload/admin.py b/website/upload/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/website/upload/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/website/upload/apps.py b/website/upload/apps.py new file mode 100644 index 00000000..00a986c7 --- /dev/null +++ b/website/upload/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class UploadConfig(AppConfig): + name = 'upload' diff --git a/website/upload/forms.py b/website/upload/forms.py new file mode 100644 index 00000000..45c3ffa9 --- /dev/null +++ b/website/upload/forms.py @@ -0,0 +1,9 @@ +from django import forms +from .models import Image + + +class ImageForm(forms.ModelForm): + """Form for the image model""" + class Meta: + model = Image + fields = ('title', 'image') diff --git a/website/upload/migrations/__init__.py b/website/upload/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/website/upload/migrations/__pycache__/__init__.cpython-36.pyc b/website/upload/migrations/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 00000000..192f30b7 Binary files /dev/null and b/website/upload/migrations/__pycache__/__init__.cpython-36.pyc differ diff --git a/website/upload/models.py b/website/upload/models.py new file mode 100644 index 00000000..de4eca9b --- /dev/null +++ b/website/upload/models.py @@ -0,0 +1,4 @@ +from django.db import models + +class Image(models.Model): + image = models.ImageField(upload_to='static/%Y/%m/%d/', blank=True) diff --git a/website/upload/tests.py b/website/upload/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/website/upload/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/website/upload/views.py b/website/upload/views.py new file mode 100644 index 00000000..335201ac --- /dev/null +++ b/website/upload/views.py @@ -0,0 +1,30 @@ +from django.shortcuts import render, redirect +import os.path + +def uploadContent(request): + if request.method == "GET": + return render(request, "uploadChoice.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 + +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"static/{image}","wb") + for i in image: + savingImage.write(i) + savingImage.close() + return redirect(f"/static/{image}") + else: + return diff --git a/website/users/__pycache__/admin.cpython-36.pyc b/website/users/__pycache__/admin.cpython-36.pyc new file mode 100644 index 00000000..8573692b Binary files /dev/null and b/website/users/__pycache__/admin.cpython-36.pyc differ diff --git a/website/users/__pycache__/models.cpython-36.pyc b/website/users/__pycache__/models.cpython-36.pyc new file mode 100644 index 00000000..813ec63e Binary files /dev/null and b/website/users/__pycache__/models.cpython-36.pyc differ diff --git a/website/users/__pycache__/urls.cpython-36.pyc b/website/users/__pycache__/urls.cpython-36.pyc new file mode 100644 index 00000000..4bf10ac2 Binary files /dev/null and b/website/users/__pycache__/urls.cpython-36.pyc differ diff --git a/website/users/__pycache__/views.cpython-36.pyc b/website/users/__pycache__/views.cpython-36.pyc new file mode 100644 index 00000000..f6c59961 Binary files /dev/null and b/website/users/__pycache__/views.cpython-36.pyc differ diff --git a/website/website/__pycache__/settings.cpython-36.pyc b/website/website/__pycache__/settings.cpython-36.pyc new file mode 100644 index 00000000..c6a04d2d Binary files /dev/null and b/website/website/__pycache__/settings.cpython-36.pyc differ diff --git a/website/website/__pycache__/urls.cpython-36.pyc b/website/website/__pycache__/urls.cpython-36.pyc new file mode 100644 index 00000000..e493a111 Binary files /dev/null and b/website/website/__pycache__/urls.cpython-36.pyc differ diff --git a/website/website/__pycache__/wsgi.cpython-36.pyc b/website/website/__pycache__/wsgi.cpython-36.pyc new file mode 100644 index 00000000..b1ac2cfa Binary files /dev/null and b/website/website/__pycache__/wsgi.cpython-36.pyc differ diff --git a/website/website/settings.py b/website/website/settings.py index 73035865..c199d45b 100644 --- a/website/website/settings.py +++ b/website/website/settings.py @@ -40,6 +40,7 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'home', 'users', + 'upload' ] MIDDLEWARE = [ @@ -121,8 +122,10 @@ USE_TZ = True # https://docs.djangoproject.com/en/3.1/howto/static-files/ STATIC_URL = '/static/' -STATIC_ROOT= "/media/kanina/AtmoSphere/Projects/CurrencySite/website/static/" +STATIC_ROOT= str(BASE_DIR.joinpath('static')) +MEDIA_URL = '/media/' +MEDIA_ROOT = str(BASE_DIR.joinpath('media')) LOGIN_REDIRECT_URL = "/" LOGOUT_REDIRECT_URL = "/" diff --git a/website/website/urls.py b/website/website/urls.py index ae37dbef..bc6ddbc1 100644 --- a/website/website/urls.py +++ b/website/website/urls.py @@ -20,11 +20,13 @@ from django.conf import settings from django.conf.urls.static import static from django.contrib.auth import views from django.views.generic.base import TemplateView +from upload.views import uploadContent, imageUpload urlpatterns = [ path("", homePage, name='home'), path('admin/', admin.site.urls), path("users/", include('django.contrib.auth.urls')), path('users/', include('users.urls')), + path("upload/", uploadContent, name="Upload"), + path("upload_image/", imageUpload, name="Image") ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) -