Conversation
The FeaturedContent admin now supports uploading images directly from the change form instead of requiring manual Cloudinary uploads and URL pasting. A reusable CloudinaryUploadWidget renders a file input, image preview, and URL fallback for each image field. On save, the CloudinaryUploadMixin intercepts uploaded files, sends them to Cloudinary via a new generic upload method, and auto-populates both the URL and public_id fields. Old images are deleted from Cloudinary when replaced, and a clear checkbox allows removing images entirely. The mixin is reusable for any future admin model with Cloudinary fields. ## Claude Implementation Notes - utils/admin_widgets.py: New CloudinaryUploadWidget with multipart form support, preview, file input, URL fallback, and clear checkbox - utils/admin_mixins.py: New CloudinaryUploadMixin that injects upload widgets via get_form(), hides public_id fields via get_exclude(), and handles upload/clear/delete in save_model() - templates/admin/widgets/cloudinary_upload.html: Widget template with image preview, file input, URL input, and clear checkbox - users/cloudinary_service.py: Added generic upload_image() class method for admin use - contributions/admin.py: Applied CloudinaryUploadMixin to FeaturedContentAdmin with 4 image field pairs configured, removed Cloudinary Metadata fieldset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CloudinaryUploadMixinandCloudinaryUploadWidgetcan be applied to any future admin model with Cloudinary image fieldsChanges
backend/utils/admin_widgets.py—CloudinaryUploadWidgetwith multipart support, thumbnail preview, file input, URL input, and clear checkboxbackend/utils/admin_mixins.py—CloudinaryUploadMixinthat injects upload widgets, hides public_id fields, and handles upload/clear/delete on savebackend/templates/admin/widgets/cloudinary_upload.html— Widget templatebackend/users/cloudinary_service.py— Added genericupload_image()methodbackend/contributions/admin.py— Applied mixin toFeaturedContentAdminwith 4 image field pairsTest plan