From e7ce9ef5c0d684cc4f3042fde059fee2a31fe078 Mon Sep 17 00:00:00 2001 From: Kyle Maas Date: Fri, 10 Nov 2023 08:41:20 -0500 Subject: [PATCH] Add admin action to generate missing encodings for a particular Media (#883) * Add admin action to generate missing encodings for a particular Media * Only regenerate the encodings that are missing --- files/admin.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/files/admin.py b/files/admin.py index fa59dfa..31233af 100644 --- a/files/admin.py +++ b/files/admin.py @@ -40,6 +40,12 @@ class MediaAdmin(admin.ModelAdmin): def get_comments_count(self, obj): return obj.comments.count() + @admin.action(description="Generate missing encoding(s)", permissions=["change"]) + def generate_missing_encodings(modeladmin, request, queryset): + for m in queryset: + m.encode(force=False) + + actions = [generate_missing_encodings] get_comments_count.short_description = "Comments count"