Clean up file app

This commit is contained in:
Anna Sidwell 2019-08-20 01:17:23 +02:00
parent 0d65c3c7b9
commit 9e9793ba06
2 changed files with 11 additions and 16 deletions

View File

@ -1,19 +1,14 @@
from django.conf.urls import url from django.urls import path
from .views import FileDeleteView from . import views
from .views import FileUploadView
from .views import ImageFileDeleteView
from .views import ImageFileUploadView
app_name = "files" app_name = "files"
urlpatterns = [ urlpatterns = [
url(r"^upload/$", FileUploadView.as_view(), name="upload"), path("upload/", views.FileUpload.as_view(), name="upload"),
url(r"^upload/image/$", ImageFileUploadView.as_view(), name="upload_image"), path("upload/image/", views.ImageFileUpload.as_view(), name="upload_image"),
url(r"^delete/(?P<pk>\d+)/$", FileDeleteView.as_view(), name="delete"), path("delete/<int:pk>/", views.FileDelete.as_view(), name="delete"),
url( path(
r"^delete/image/(?P<pk>\d+)/$", "delete/image/<int:pk>/", views.ImageFileDelete.as_view(), name="delete_image"
ImageFileDeleteView.as_view(),
name="delete_image",
), ),
] ]

View File

@ -10,7 +10,7 @@ from .models import File
from .models import ImageFile from .models import ImageFile
class FileUploadView(LoginRequiredMixin, FormView): class FileUpload(LoginRequiredMixin, FormView):
model = File model = File
form_class = FileForm form_class = FileForm
@ -32,12 +32,12 @@ class FileUploadView(LoginRequiredMixin, FormView):
return JsonResponse({"is_valid": False, "errors": form.errors}) return JsonResponse({"is_valid": False, "errors": form.errors})
class ImageFileUploadView(FileUploadView): class ImageFileUpload(FileUpload):
model = ImageFile model = ImageFile
form_class = ImageFileForm form_class = ImageFileForm
class FileDeleteView(LoginRequiredMixin, DetailView): class FileDelete(LoginRequiredMixin, DetailView):
model = File model = File
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
@ -54,5 +54,5 @@ class FileDeleteView(LoginRequiredMixin, DetailView):
return JsonResponse({"success": True}) return JsonResponse({"success": True})
class ImageFileDeleteView(FileDeleteView): class ImageFileDelete(FileDelete):
model = ImageFile model = ImageFile