コード例 #1
0
        def queryset(self, request, queryset):
            all_count = queryset.count()
            translated_count = queryset.exclude(translation='').count()
            untranslated_count = all_count - translated_count

            translated_title = u'{translated_label} ({translated_count} / {all_count})'.format(
                translated_label=self.lookup_choices[0][1],
                translated_count=translated_count,
                all_count=all_count,
            )

            untranslated_title = u'{translated_label} ({untranslated_count} / {all_count})'.format(
                translated_label=self.lookup_choices[1][1],
                untranslated_count=untranslated_count,
                all_count=all_count,
            )

            self.lookup_choices = [
                (choices.TRANSLATIONS_TRANSLATED, cf(translated_title)),
                (choices.TRANSLATIONS_UNTRANSLATED, cf(untranslated_title)),
            ]

            if self.value() == choices.TRANSLATIONS_TRANSLATED:
                return queryset.exclude(translation="")
            if self.value() == choices.TRANSLATIONS_UNTRANSLATED:
                return queryset.filter(translation="")
コード例 #2
0
        def queryset(self, request, queryset):
            all_count = queryset.count()
            translated_count = queryset.exclude(translation='').count()
            untranslated_count = all_count - translated_count

            translated_title = u'{translated_label} ({translated_count} / {all_count})'.format(
                translated_label=self.lookup_choices[0][1],
                translated_count=translated_count,
                all_count=all_count,
            )

            untranslated_title = u'{translated_label} ({untranslated_count} / {all_count})'.format(
                translated_label=self.lookup_choices[1][1],
                untranslated_count=untranslated_count,
                all_count=all_count,
            )

            self.lookup_choices = [
                (choices.TRANSLATIONS_TRANSLATED, cf(translated_title)),
                (choices.TRANSLATIONS_UNTRANSLATED, cf(untranslated_title)),
            ]

            if self.value() == choices.TRANSLATIONS_TRANSLATED:
                return queryset.exclude(translation="")
            if self.value() == choices.TRANSLATIONS_UNTRANSLATED:
                return queryset.filter(translation="")
コード例 #3
0
 def lookups(self, request, model_admin):
     return [(i, cf(_(label))) for i, (group_filter, label) in enumerate(get_settings('TRANSLATIONS_CUSTOM_FILTERS'))]
コード例 #4
0
 def __init__(self, *args, **kwargs):
     self.title = cf(_(get_settings('TRANSLATIONS_CUSTOM_FILTERS_LABEL')))
     super(CustomFilter, self).__init__(*args, **kwargs)
コード例 #5
0
 def lookups(self, request, model_admin):
     return [(i, cf(_(label))) for i, (group_filter, label) in enumerate(get_settings('TRANSLATIONS_CUSTOM_FILTERS'))]
コード例 #6
0
 def __init__(self, *args, **kwargs):
     self.title = cf(_(get_settings('TRANSLATIONS_CUSTOM_FILTERS_LABEL')))
     super(CustomFilter, self).__init__(*args, **kwargs)