diff --git a/gallery/admin.py b/gallery/admin.py index f3d77f8..0c23b74 100644 --- a/gallery/admin.py +++ b/gallery/admin.py @@ -75,11 +75,11 @@ class AlbumAdmin(admin.ModelAdmin): """Add custom upload route to admin.""" urls = super().get_urls() custom_urls = [ - path('/upload/', self.admin_site.admin_view(self.upload_photos), name="gallery_album_upload"), + path('/upload/', self.admin_site.admin_view(self.photo_upload), name="gallery_album_upload"), ] return custom_urls + urls - def upload_photos(self, request, album_id, *args, **kwargs): + def photo_upload(self, request, album_id, *args, **kwargs): """Handle photo upload via admin UI.""" album = get_object_or_404(Album, id=album_id) if request.method == 'POST' and request.FILES: @@ -91,7 +91,7 @@ class AlbumAdmin(admin.ModelAdmin): Photo.objects.create(album=album, photo=file) return JsonResponse({"message": "Photos uploaded successfully!"}) - return render(request, 'admin/upload_photos.html', {'album': album}) + return render(request, 'admin/photo_upload.html', {'album': album}) def upload_link(self, obj): """Show 'Upload Photos' button in album list.""" diff --git a/gallery/templates/admin/photo_upload.html b/gallery/templates/admin/photo_upload.html new file mode 100644 index 0000000..7a49a12 --- /dev/null +++ b/gallery/templates/admin/photo_upload.html @@ -0,0 +1,206 @@ +{% extends "admin/base_site.html" %} +{% block content %} + + + + + + + + +
+

Upload: {{ album.name }}

+
+ +
+ + + Drop photos here or select + + +
+ +
    +
    + + + + +
    +
    + + + +{% endblock %} \ No newline at end of file diff --git a/gallery/templates/admin/upload_photos.html b/gallery/templates/admin/upload_photos.html deleted file mode 100644 index a0f2e65..0000000 --- a/gallery/templates/admin/upload_photos.html +++ /dev/null @@ -1,162 +0,0 @@ -{% extends "admin/base_site.html" %} -{% block content %} -
    -

    Upload Photos to {{ album.name }}

    - -
    - {% csrf_token %} - -
    -
    -

    Drag files here or click below to select

    - -
    -
    - -
      -

      Total size: 0 MB

      - - - -
      - -
      -
      -
      - - - - -{% endblock %} \ No newline at end of file