e
This commit is contained in:
0
website/upload/__init__.py
Normal file
0
website/upload/__init__.py
Normal file
BIN
website/upload/__pycache__/__init__.cpython-36.pyc
Normal file
BIN
website/upload/__pycache__/__init__.cpython-36.pyc
Normal file
Binary file not shown.
BIN
website/upload/__pycache__/admin.cpython-36.pyc
Normal file
BIN
website/upload/__pycache__/admin.cpython-36.pyc
Normal file
Binary file not shown.
BIN
website/upload/__pycache__/models.cpython-36.pyc
Normal file
BIN
website/upload/__pycache__/models.cpython-36.pyc
Normal file
Binary file not shown.
BIN
website/upload/__pycache__/views.cpython-36.pyc
Normal file
BIN
website/upload/__pycache__/views.cpython-36.pyc
Normal file
Binary file not shown.
3
website/upload/admin.py
Normal file
3
website/upload/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
5
website/upload/apps.py
Normal file
5
website/upload/apps.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class UploadConfig(AppConfig):
|
||||
name = 'upload'
|
9
website/upload/forms.py
Normal file
9
website/upload/forms.py
Normal file
@ -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')
|
0
website/upload/migrations/__init__.py
Normal file
0
website/upload/migrations/__init__.py
Normal file
BIN
website/upload/migrations/__pycache__/__init__.cpython-36.pyc
Normal file
BIN
website/upload/migrations/__pycache__/__init__.cpython-36.pyc
Normal file
Binary file not shown.
4
website/upload/models.py
Normal file
4
website/upload/models.py
Normal file
@ -0,0 +1,4 @@
|
||||
from django.db import models
|
||||
|
||||
class Image(models.Model):
|
||||
image = models.ImageField(upload_to='static/%Y/%m/%d/', blank=True)
|
3
website/upload/tests.py
Normal file
3
website/upload/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
30
website/upload/views.py
Normal file
30
website/upload/views.py
Normal file
@ -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
|
Reference in New Issue
Block a user