"slug",
]
list_filter = ["year_of_death", "priority", "collections", "status", "gender", "nationality"]
+ list_per_page = 10000000
search_fields = ["first_name", "last_name", "wikidata"]
prepopulated_fields = {"slug": ("first_name", "last_name")}
autocomplete_fields = ["collections"]
license_name_field = 'document_book__dc_cover_image__license_name'
+def add_title(base_class, suffix):
+ class TitledCategoryFilter(base_class):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.title += suffix
+ return TitledCategoryFilter
+
+
+
class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin):
list_display = [
"smart_title",
("pd_year", RangeNumericFilter),
"collections",
"collections__category",
+ ("authors__collections", add_title(admin.RelatedFieldListFilter, ' autora')),
+ ("authors__collections__category", add_title(admin.RelatedFieldListFilter, ' autora')),
+ ("translators__collections", add_title(admin.RelatedFieldListFilter, ' tłumacza')),
+ ("translators__collections__category", add_title(admin.RelatedFieldListFilter, ' tłumacza')),
"epochs", "kinds", "genres",
"priority",
"authors__gender", "authors__nationality",
"translators__gender", "translators__nationality",
"document_book__chunk__stage",
- "document_book__chunk__user",
+ #"document_book__chunk__user",
LicenseFilter,
CoverLicenseFilter,
]
+ list_per_page = 1000000
+
readonly_fields = ["wikidata_link", "estimated_costs", "documents_book_link"]
actions = [export_as_csv_action()]
fieldsets = [
path('track/<slug:slug>/', PublishTrackFeed()),
path('active/', views.active_users_list, name='active_users_list'),
+ path('active.csv', views.active_users_list, kwargs={'csv': True}, name='active_users_csv'),
path('mark-final/', views.mark_final, name='mark_final'),
path('mark-final-completed/', views.mark_final_completed, name='mark_final_completed'),
return "%s%s/" % (settings.IMAGE_DIR, self.object.gallery)
-def active_users_list(request):
+def active_users_list(request, csv=False):
year = int(request.GET.get('y', date.today().year))
by_user = defaultdict(lambda: 0)
by_email = defaultdict(lambda: 0)
for email, count in by_email.items():
active_users.append((email, names_by_email[email], count))
active_users.sort(key=lambda x: -x[2])
- return render(request, 'documents/active_users_list.html', {
- 'users': active_users,
- 'year': year,
- })
+ if csv:
+ return http.HttpResponse(
+ '\n'.join((
+ ','.join(
+ (str(x[2]), x[0], ','.join(x[1]))
+ )
+ for x in active_users
+ )),
+ content_type='text/csv',
+ headers={
+ 'Content-Disposition': f'attachment; filename=redakcja-{year}.csv',
+ }
+ )
+ else:
+ return render(request, 'documents/active_users_list.html', {
+ 'users': active_users,
+ 'year': year,
+ })
@user_passes_test(lambda u: u.is_superuser)