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 .views import FileUploadView
from .views import ImageFileDeleteView
from .views import ImageFileUploadView
from . import views
app_name = "files"
urlpatterns = [
url(r"^upload/$", FileUploadView.as_view(), name="upload"),
url(r"^upload/image/$", ImageFileUploadView.as_view(), name="upload_image"),
url(r"^delete/(?P<pk>\d+)/$", FileDeleteView.as_view(), name="delete"),
url(
r"^delete/image/(?P<pk>\d+)/$",
ImageFileDeleteView.as_view(),
name="delete_image",
path("upload/", views.FileUpload.as_view(), name="upload"),
path("upload/image/", views.ImageFileUpload.as_view(), name="upload_image"),
path("delete/<int:pk>/", views.FileDelete.as_view(), name="delete"),
path(
"delete/image/<int:pk>/", views.ImageFileDelete.as_view(), name="delete_image"
),
]

View File

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