Skip to content

Commit

Permalink
Add admin action to generate missing encodings for a particular Media (
Browse files Browse the repository at this point in the history
…#883)

* Add admin action to generate missing encodings for a particular Media
* Only regenerate the encodings that are missing
  • Loading branch information
KyleMaas committed Nov 10, 2023
1 parent 4829adf commit e7ce9ef
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions files/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down

0 comments on commit e7ce9ef

Please sign in to comment.