fnp
/
redakcja.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
81f5e74
)
ad hoc changes
author
Radek Czajka
<rczajka@rczajka.pl>
Mon, 19 Sep 2022 08:15:30 +0000
(10:15 +0200)
committer
Radek Czajka
<rczajka@rczajka.pl>
Mon, 19 Sep 2022 08:15:30 +0000
(10:15 +0200)
src/catalogue/admin.py
patch
|
blob
|
history
src/documents/templates/documents/active_users_list.html
patch
|
blob
|
history
src/documents/urls.py
patch
|
blob
|
history
src/documents/views.py
patch
|
blob
|
history
src/wlxml/views.py
patch
|
blob
|
history
diff --git
a/src/catalogue/admin.py
b/src/catalogue/admin.py
index
2cab170
..
54c232f
100644
(file)
--- a/
src/catalogue/admin.py
+++ b/
src/catalogue/admin.py
@@
-25,6
+25,7
@@
class AuthorAdmin(WikidataAdminMixin, admin.ModelAdmin):
"slug",
]
list_filter = ["year_of_death", "priority", "collections", "status", "gender", "nationality"]
"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"]
search_fields = ["first_name", "last_name", "wikidata"]
prepopulated_fields = {"slug": ("first_name", "last_name")}
autocomplete_fields = ["collections"]
@@
-71,6
+72,15
@@
class CoverLicenseFilter(LicenseFilter):
license_name_field = 'document_book__dc_cover_image__license_name'
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",
class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin):
list_display = [
"smart_title",
@@
-95,16
+105,22
@@
class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin):
("pd_year", RangeNumericFilter),
"collections",
"collections__category",
("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",
"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,
]
LicenseFilter,
CoverLicenseFilter,
]
+ list_per_page = 1000000
+
readonly_fields = ["wikidata_link", "estimated_costs", "documents_book_link"]
actions = [export_as_csv_action()]
fieldsets = [
readonly_fields = ["wikidata_link", "estimated_costs", "documents_book_link"]
actions = [export_as_csv_action()]
fieldsets = [
diff --git
a/src/documents/templates/documents/active_users_list.html
b/src/documents/templates/documents/active_users_list.html
index
ef9532f
..
f58febf
100644
(file)
--- a/
src/documents/templates/documents/active_users_list.html
+++ b/
src/documents/templates/documents/active_users_list.html
@@
-11,6
+11,8
@@
{% trans "Users active in the year" %} {{ year }}
</h1>
{% trans "Users active in the year" %} {{ year }}
</h1>
+<p><a href="{% url 'active_users_csv' %}?y={{ year }}">Pobierz jako CSV</a></p>
+
<ul>
{% for email, names, count in users %}
<li>{% for name in names %}{{ name }}, {% endfor %}<a href="mailto:{{ email }}">{{ email }}</a> ({{ count }})</li>
<ul>
{% for email, names, count in users %}
<li>{% for name in names %}{{ name }}, {% endfor %}<a href="mailto:{{ email }}">{{ email }}</a> ({{ count }})</li>
diff --git
a/src/documents/urls.py
b/src/documents/urls.py
index
1a1f185
..
71ce10a
100644
(file)
--- a/
src/documents/urls.py
+++ b/
src/documents/urls.py
@@
-58,6
+58,7
@@
urlpatterns = [
path('track/<slug:slug>/', PublishTrackFeed()),
path('active/', views.active_users_list, name='active_users_list'),
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'),
path('mark-final/', views.mark_final, name='mark_final'),
path('mark-final-completed/', views.mark_final_completed, name='mark_final_completed'),
diff --git
a/src/documents/views.py
b/src/documents/views.py
index
6c9f29e
..
ea22236
100644
(file)
--- a/
src/documents/views.py
+++ b/
src/documents/views.py
@@
-634,7
+634,7
@@
class GalleryView(UploadView):
return "%s%s/" % (settings.IMAGE_DIR, self.object.gallery)
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)
year = int(request.GET.get('y', date.today().year))
by_user = defaultdict(lambda: 0)
by_email = defaultdict(lambda: 0)
@@
-659,10
+659,24
@@
def active_users_list(request):
for email, count in by_email.items():
active_users.append((email, names_by_email[email], count))
active_users.sort(key=lambda x: -x[2])
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)
@user_passes_test(lambda u: u.is_superuser)
diff --git
a/src/wlxml/views.py
b/src/wlxml/views.py
index
281ced5
..
edf8a92
100644
(file)
--- a/
src/wlxml/views.py
+++ b/
src/wlxml/views.py
@@
-48,7
+48,7
@@
class TagView(DetailView):
VALUE_TYPES = {
LegimiCategory: {
'widget': 'select',
VALUE_TYPES = {
LegimiCategory: {
'widget': 'select',
- 'options': list(legimi.CATEGORIES.keys()),
+ 'options':
[''] +
list(legimi.CATEGORIES.keys()),
},
Epoch: {
'autocomplete': {
},
Epoch: {
'autocomplete': {
@@
-104,6
+104,7
@@
VALUE_TYPES = {
"language": {
'widget': 'select',
'options': [
"language": {
'widget': 'select',
'options': [
+ '',
'pol',
'eng',
'fre',
'pol',
'eng',
'fre',