Skip to content

Commit

Permalink
Additional filter for the Subtitles model to check for draft subtitle…
Browse files Browse the repository at this point in the history
… files
  • Loading branch information
percidae committed Jan 14, 2024
1 parent c2da210 commit 3bc6013
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion www/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,26 @@ def queryset(self, request, queryset):
else:
return queryset.exclude(state=4)

class HasDraftSubtitleFileFilter(admin.SimpleListFilter):
title = 'Has Draft Subtitle File'
parameter_name = 'draft_subtitle_file'

def lookups(self, request, model_admin):
return (('yes', 'Yes'),
('no', 'No'),
)

def queryset(self, request, queryset):
ans = self.value()

if ans == "no":
return queryset.filter(has_draft_subtitle_file = False)
elif ans == "yes":
return queryset.filter(has_draft_subtitle_file = True)
else:
return queryset



@admin.register(Subtitle)
class SubtitleAdmin(admin.ModelAdmin):
Expand Down Expand Up @@ -397,7 +417,7 @@ def transforms_dwim(self, request, queryset):
list_display = ('id', 'talk_id_link', 'talk_frab_id', 'talk', 'language', 'is_original_lang',
'status', 'complete', 'unlisted', 'touched',)
list_filter = (WorkflowFilter, LanguageFilter, 'is_original_lang',
'state', 'complete', 'unlisted',)
'state', 'complete', 'unlisted', HasDraftSubtitleFileFilter, )
raw_id_fields = ('talk',)
search_fields = ('talk__event__acronym', 'talk__title', 'talk__frab_id_talk', 'id', 'talk__subtitle_talk', 'talk__id')

Expand Down

0 comments on commit 3bc6013

Please # to comment.