From: Radek Czajka Date: Mon, 5 Sep 2022 23:27:16 +0000 (+0200) Subject: fixes X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/165161a173154072eb7b999386a13562e110bd0a?hp=fd1a9915dd65789cccf27041a1f01cd4077273fc fixes --- diff --git a/src/catalogue/models/tag.py b/src/catalogue/models/tag.py index 3c2a53610..5442213c6 100644 --- a/src/catalogue/models/tag.py +++ b/src/catalogue/models/tag.py @@ -192,7 +192,7 @@ class Tag(models.Model): # For instance, Pictures do not have 'genre' field. continue for tag_name in tag_names: - lang = getattr(tag_name, 'lang', settings.LANGUAGE_CODE) + lang = getattr(tag_name, 'lang', None) or settings.LANGUAGE_CODE tag_sort_key = tag_name if category == 'author': tag_sort_key = ' '.join((tag_name.last_name,) + tag_name.first_names) diff --git a/src/chunks/models.py b/src/chunks/models.py index 56166a33e..f5fdbbf77 100644 --- a/src/chunks/models.py +++ b/src/chunks/models.py @@ -4,6 +4,7 @@ from django.conf import settings from django.core.cache import cache from django.db import models +from django.urls import reverse from django.utils.translation import ugettext_lazy as _ @@ -42,3 +43,6 @@ class Attachment(models.Model): def __str__(self): return self.key + + def get_absolute_url(self): + return reverse('chunks_attachment', args=[self.key, self.attachment.name.rsplit('.', 1)[-1]]) diff --git a/src/chunks/urls.py b/src/chunks/urls.py new file mode 100644 index 000000000..a1abc7df2 --- /dev/null +++ b/src/chunks/urls.py @@ -0,0 +1,9 @@ +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +from django.urls import path +from . import views + +urlpatterns = [ + path('attachment/.', views.attachment, name='chunks_attachment'), +] diff --git a/src/chunks/views.py b/src/chunks/views.py new file mode 100644 index 000000000..e126c9304 --- /dev/null +++ b/src/chunks/views.py @@ -0,0 +1,9 @@ +from django.shortcuts import get_object_or_404 +from . import models +from fnpdjango.utils.views import serve_file + + +def attachment(request, key, ext): + att = get_object_or_404(models.Attachment, key=key) + return serve_file(att.attachment.url) + diff --git a/src/pz/admin.py b/src/pz/admin.py index bc1ee8afd..23ad9c249 100644 --- a/src/pz/admin.py +++ b/src/pz/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from django.contrib.admin.filters import FieldListFilter +from django.contrib.admin.filters import FieldListFilter, SimpleListFilter from django.contrib import messages from django.db.models import Q from django.shortcuts import get_object_or_404, redirect @@ -50,6 +50,23 @@ class EmptyFieldListFilter(FieldListFilter): } +class PayedListFilter(SimpleListFilter): + title = 'pobrane' + parameter_name = 'payed' + def lookups(self, request, model_admin): + return ( + ('yes', 'tak'), + ('no', 'nie'), + ) + + def queryset(self, request, queryset): + if self.value() == 'yes': + return queryset.filter(payment__is_dd=True, payment__realised=True).distinct() + if self.value() == 'no': + return queryset.exclude(payment__is_dd=True, payment__realised=True).distinct() + + + class BankExportFeedbackLineInline(admin.TabularInline): model = models.BankExportFeedbackLine extra = 0 @@ -90,6 +107,7 @@ class DirectDebitAdmin(admin.ModelAdmin): 'is_consumer', ('fundraiser_commission', EmptyFieldListFilter), ('fundraiser_bonus', EmptyFieldListFilter), + PayedListFilter, ] fieldsets = [ (None, { diff --git a/src/wolnelektury/templates/2022/hotjar.html b/src/wolnelektury/templates/2022/hotjar.html index 3e41800e3..a4cbd22f9 100644 --- a/src/wolnelektury/templates/2022/hotjar.html +++ b/src/wolnelektury/templates/2022/hotjar.html @@ -9,3 +9,16 @@ a.appendChild(r); })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv='); + + + + + + diff --git a/src/wolnelektury/urls.py b/src/wolnelektury/urls.py index 749b6e638..4de5f4909 100644 --- a/src/wolnelektury/urls.py +++ b/src/wolnelektury/urls.py @@ -58,6 +58,8 @@ urlpatterns += [ path('towarzystwo/', RedirectView.as_view( url='/pomagam/%(path)s', permanent=False)), + path('chunks/', include('chunks.urls')), + # Admin panel path('admin/catalogue/book/import', catalogue.views.import_book, name='import_book'), path('admin/catalogue/picture/import', picture.views.import_picture, name='import_picture'),