fixes
authorRadek Czajka <rczajka@rczajka.pl>
Mon, 5 Sep 2022 23:27:16 +0000 (01:27 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Mon, 5 Sep 2022 23:27:16 +0000 (01:27 +0200)
src/catalogue/models/tag.py
src/chunks/models.py
src/chunks/urls.py [new file with mode: 0644]
src/chunks/views.py [new file with mode: 0644]
src/pz/admin.py
src/wolnelektury/templates/2022/hotjar.html
src/wolnelektury/urls.py

index 3c2a536..5442213 100644 (file)
@@ -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)
index 56166a3..f5fdbbf 100644 (file)
@@ -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 (file)
index 0000000..a1abc7d
--- /dev/null
@@ -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/<key>.<slug:ext>', views.attachment, name='chunks_attachment'),
+]
diff --git a/src/chunks/views.py b/src/chunks/views.py
new file mode 100644 (file)
index 0000000..e126c93
--- /dev/null
@@ -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)
+
index bc1ee8a..23ad9c2 100644 (file)
@@ -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, {
index 3e41800..a4cbd22 100644 (file)
@@ -9,3 +9,16 @@
      a.appendChild(r);
  })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');
 </script>
+
+
+<script>
+  window.markerConfig = {
+    destination: '6177df91cd90df729b89c94d', 
+    source: 'snippet'
+  };
+</script>
+
+<script>
+!function(e,r,a){if(!e.__Marker){e.__Marker={};var t=[],n={__cs:t};["show","hide","isVisible","capture","cancelCapture","unload","reload","isExtensionInstalled","setReporter","setCustomData","on","off"].forEach(function(e){n[e]=function(){var r=Array.prototype.slice.call(arguments);r.unshift(e),t.push(r)}}),e.Marker=n;var s=r.createElement("script");s.async=1,s.src="https://edge.marker.io/latest/shim.js";var i=r.getElementsByTagName("script")[0];i.parentNode.insertBefore(s,i)}}(window,document);
+</script>
+
index 749b6e6..4de5f49 100644 (file)
@@ -58,6 +58,8 @@ urlpatterns += [
     path('towarzystwo/<path:path>', 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'),