From 251dba7da16650b469a3ea3b3a473936c6ce3039 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 5 Feb 2024 08:36:44 +0100 Subject: [PATCH 01/16] fix --- src/wolnelektury/static/2022/styles/layout/_text.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wolnelektury/static/2022/styles/layout/_text.scss b/src/wolnelektury/static/2022/styles/layout/_text.scss index 3fcae7c68..430112c1f 100644 --- a/src/wolnelektury/static/2022/styles/layout/_text.scss +++ b/src/wolnelektury/static/2022/styles/layout/_text.scss @@ -96,6 +96,7 @@ right: 0px; top: 50px; width: 80vw; + max-width: 600px; height: 300px; padding: 30px; overflow: auto; -- 2.20.1 From 7226da0450b08dd90714bd8e78cfe4920848415b Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 5 Feb 2024 08:44:37 +0100 Subject: [PATCH 02/16] fix themes --- .../static/2022/styles/layout/_text.scss | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/wolnelektury/static/2022/styles/layout/_text.scss b/src/wolnelektury/static/2022/styles/layout/_text.scss index 430112c1f..20aa174b1 100644 --- a/src/wolnelektury/static/2022/styles/layout/_text.scss +++ b/src/wolnelektury/static/2022/styles/layout/_text.scss @@ -514,6 +514,31 @@ table.border td, table.border th { } + + +.theme-begin { + font-size: .9em; + position: relative; + float: right; + margin-bottom: 8px; + clear: both; + line-height: 1.5em; + text-align: left; + z-index: 60; + + font-style: normal; + font-weight: normal; + font-variant: normal; + letter-spacing: 0; + text-transform: none; + text-decoration: none; + user-select: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + + margin-right: -160px; +} } -- 2.20.1 From c36c3891e56611e2ad4c518daa46b8cc3f28188e Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 5 Feb 2024 09:20:44 +0100 Subject: [PATCH 03/16] progress --- src/catalogue/models/book.py | 3 +++ src/catalogue/templates/catalogue/book_text.html | 4 ++-- src/wolnelektury/settings/static.py | 1 + src/wolnelektury/static/2022/styles/layout/_text.scss | 1 - 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index b2d960b67..10e9d22e3 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -331,6 +331,9 @@ class Book(models.Model): total += app_settings.GET_MP3_LENGTH(media.file.path) return int(total) + def get_time(self): + return round(self.xml_file.size / 1000 * 40) + def has_media(self, type_): if type_ in Book.formats: return bool(getattr(self, "%s_file" % type_)) diff --git a/src/catalogue/templates/catalogue/book_text.html b/src/catalogue/templates/catalogue/book_text.html index a494e24b6..421d439fe 100644 --- a/src/catalogue/templates/catalogue/book_text.html +++ b/src/catalogue/templates/catalogue/book_text.html @@ -133,14 +133,14 @@ {% block main %} -
+
- Szacowany czas do końca: 56 min + Szacowany czas do końca: -
diff --git a/src/wolnelektury/settings/static.py b/src/wolnelektury/settings/static.py index dfc84d1c5..b3edb72cb 100644 --- a/src/wolnelektury/settings/static.py +++ b/src/wolnelektury/settings/static.py @@ -76,6 +76,7 @@ PIPELINE = { 'js/book_text/references.js', 'js/book_text/settings.js', 'js/book_text/toc.js', + 'js/book_text/progress.js', 'js/contrib/jquery.countdown.js', 'js/contrib/jquery.countdown-pl.js', 'js/contrib/jquery.countdown-de.js', 'js/contrib/jquery.countdown-uk.js', diff --git a/src/wolnelektury/static/2022/styles/layout/_text.scss b/src/wolnelektury/static/2022/styles/layout/_text.scss index 20aa174b1..8959c62f2 100644 --- a/src/wolnelektury/static/2022/styles/layout/_text.scss +++ b/src/wolnelektury/static/2022/styles/layout/_text.scss @@ -1,5 +1,4 @@ #global-progress { - display: none; position: sticky; top: 0; background: white; -- 2.20.1 From 6db272cdb367187394dbb01e93e2e03dab14f9ab Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 5 Feb 2024 09:22:59 +0100 Subject: [PATCH 04/16] fix --- .../static/js/book_text/progress.js | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/wolnelektury/static/js/book_text/progress.js diff --git a/src/wolnelektury/static/js/book_text/progress.js b/src/wolnelektury/static/js/book_text/progress.js new file mode 100644 index 000000000..8175de666 --- /dev/null +++ b/src/wolnelektury/static/js/book_text/progress.js @@ -0,0 +1,33 @@ +(function($){$(function(){ + + t = $('#global-progress').data('t'); + function upd_t() { + $text = $('#main-text #book-text'); + texttop = $text.offset().top; + + $footnotes = $('#footnotes', $text); + if ($footnotes.length) { + textbottom = $footnotes.offset().top; + } else { + textbottom = texttop + $text.height(); + } + + textlen = textbottom - texttop; + progress = (window.scrollY - texttop) / textlen; + progress = Math.max(0, Math.min(progress, 1)) + console.log('SCROLL BODY', progress); + + $('#global-progress .filled').css('right', (1 - progress) * 100 + '%'); + tleft = Math.round((1 - progress) * t / 60); + tt = ''; + if (tleft > 60) { + h = Math.floor(tleft / 60); + tt = h + ' h '; + tleft -= h * 60; + } + tt += tleft + ' min'; + $('#global-progress .progress-text-value').text(tt); + } + upd_t(); + $(window).scroll(upd_t); +})})(jQuery); -- 2.20.1 From 6dd6758582da7f138885dc1eee41c8f9031da410 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 7 Feb 2024 15:24:50 +0100 Subject: [PATCH 05/16] fix reader --- .../static/2022/styles/layout/_text.scss | 67 ++++++++++++++++++- .../static/js/book_text/progress.js | 1 - 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/wolnelektury/static/2022/styles/layout/_text.scss b/src/wolnelektury/static/2022/styles/layout/_text.scss index 8959c62f2..0a0e2a5a2 100644 --- a/src/wolnelektury/static/2022/styles/layout/_text.scss +++ b/src/wolnelektury/static/2022/styles/layout/_text.scss @@ -120,7 +120,61 @@ } #reference-box { display: none; + width: 300px; + position: fixed; + top: 0; + right: 0; + z-index:100; + background: #eee; + + img { + margin: 0; + } + + #reference-map { + height:400px; + width: 300px; + @media screen and (max-height: 800px) { + height: 300px; + } + } + #reference-images { + padding: 10px; + white-space: nowrap; + overflow-x: auto; + a { + display: inline-block; + vertical-align: middle; + margin: 0 10px 0 0; + img { + width: auto; + border: 5px solid white; + box-shadow: 4px 4px 4px #666; + max-width: 240px; + max-height: 200px; + } + } + } + #reference-link { + display: block; + font-size: 1.5em; + padding: 10px; + } + + #reference-close { + font-size: 30px; + position: absolute; + top: 10px; + right: 10px; + z-index: 1000; + font-family: sans-serif; + color: black; + } } + + + + #menu #info { padding-top: 0; display: none; @@ -536,7 +590,18 @@ table.border td, table.border th { -moz-user-select: none; -ms-user-select: none; - margin-right: -160px; + margin-right: -227px; + width: 170px; + text-indent: 0; + color: inherit; + padding-left: 12px; + border-left: 1px solid #333; +} + + +a.reference.interesting:after { + content: url('../images/pin.svg'); + padding: 3px; } } diff --git a/src/wolnelektury/static/js/book_text/progress.js b/src/wolnelektury/static/js/book_text/progress.js index 8175de666..d57a32fbd 100644 --- a/src/wolnelektury/static/js/book_text/progress.js +++ b/src/wolnelektury/static/js/book_text/progress.js @@ -15,7 +15,6 @@ textlen = textbottom - texttop; progress = (window.scrollY - texttop) / textlen; progress = Math.max(0, Math.min(progress, 1)) - console.log('SCROLL BODY', progress); $('#global-progress .filled').css('right', (1 - progress) * 100 + '%'); tleft = Math.round((1 - progress) * t / 60); -- 2.20.1 From 49fd68327eee961b167b0dbbb80e99d6295afe10 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Fri, 9 Feb 2024 12:03:03 +0100 Subject: [PATCH 06/16] Add pz field --- src/pz/admin.py | 1 + .../migrations/0014_directdebit_nosignature.py | 18 ++++++++++++++++++ src/pz/models.py | 2 ++ 3 files changed, 21 insertions(+) create mode 100644 src/pz/migrations/0014_directdebit_nosignature.py diff --git a/src/pz/admin.py b/src/pz/admin.py index daacdce15..1bbb1da6d 100644 --- a/src/pz/admin.py +++ b/src/pz/admin.py @@ -117,6 +117,7 @@ class DirectDebitAdmin(admin.ModelAdmin): fieldsets = [ (None, { "fields": [ + 'nosignature', ('first_name', 'sex', 'date_of_birth'), 'last_name', ('street', 'building'), diff --git a/src/pz/migrations/0014_directdebit_nosignature.py b/src/pz/migrations/0014_directdebit_nosignature.py new file mode 100644 index 000000000..6f6c699dc --- /dev/null +++ b/src/pz/migrations/0014_directdebit_nosignature.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.8 on 2024-02-05 12:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pz', '0013_alter_campaign_options_alter_directdebit_options_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='directdebit', + name='nosignature', + field=models.BooleanField(default=False, verbose_name='Bez podpisu'), + ), + ] diff --git a/src/pz/models.py b/src/pz/models.py index 6bf77ad5a..05dead2e8 100644 --- a/src/pz/models.py +++ b/src/pz/models.py @@ -78,6 +78,8 @@ class DirectDebit(models.Model): campaign = models.ForeignKey(Campaign, models.PROTECT, null=True, blank=True, verbose_name='kampania') latest_status = models.CharField(max_length=255, blank=True) + + nosignature = models.BooleanField('Bez podpisu', default=False) class Meta: verbose_name = 'polecenie zapłaty' -- 2.20.1 From dbe0a80a192f561f29f917cd741b78329834a89f Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 13 Feb 2024 11:41:18 +0100 Subject: [PATCH 07/16] procent --- src/wolnelektury/templates/banner_procent.html | 8 ++++++++ src/wolnelektury/templates/base.html | 2 ++ 2 files changed, 10 insertions(+) create mode 100644 src/wolnelektury/templates/banner_procent.html diff --git a/src/wolnelektury/templates/banner_procent.html b/src/wolnelektury/templates/banner_procent.html new file mode 100644 index 000000000..25a20d442 --- /dev/null +++ b/src/wolnelektury/templates/banner_procent.html @@ -0,0 +1,8 @@ +
+

Przekaż 1,5%

+

+ Przekaż 1,5% podatku na Wolne Lektury KRS 00000 70056
+ Ufunduj darmowe książki dla tysięcy dzieciaków.
+ WIĘCEJ +

+
diff --git a/src/wolnelektury/templates/base.html b/src/wolnelektury/templates/base.html index f1a7bf685..170a0797b 100644 --- a/src/wolnelektury/templates/base.html +++ b/src/wolnelektury/templates/base.html @@ -30,6 +30,8 @@ {% block under-menu %}{% endblock %} + {% include 'banner_procent.html' %} + {% if not funding_no_show_current %}
{% cache 120 funding_top_bar LANGUAGE_CODE %} -- 2.20.1 From dce88babe4ba454ab67da205cacc5441c4953809 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 21 Feb 2024 10:16:55 +0100 Subject: [PATCH 08/16] infopage blog --- src/wolnelektury/static/2022/styles/layout/_article.scss | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wolnelektury/static/2022/styles/layout/_article.scss b/src/wolnelektury/static/2022/styles/layout/_article.scss index 8655babc0..ba7e14546 100644 --- a/src/wolnelektury/static/2022/styles/layout/_article.scss +++ b/src/wolnelektury/static/2022/styles/layout/_article.scss @@ -218,3 +218,11 @@ text-decoration: underline; } } + +.infopage-blog { + padding: 0; + list-style: none; + li { + margin-bottom: .7em; + } +} -- 2.20.1 From 7a8610e5869654bd2e8351b34b9e722ce6de73bd Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 21 Feb 2024 15:14:57 +0100 Subject: [PATCH 09/16] Funding balance sheet changed. --- ..._annotation_spent_link_alter_spent_book.py | 30 ++++++++++++++ src/funding/migrations/0013_missing_spent.py | 41 +++++++++++++++++++ src/funding/models.py | 4 +- src/funding/templates/funding/wlfund.html | 22 +++++++--- src/funding/views.py | 13 ++---- 5 files changed, 94 insertions(+), 16 deletions(-) create mode 100644 src/funding/migrations/0012_spent_annotation_spent_link_alter_spent_book.py create mode 100644 src/funding/migrations/0013_missing_spent.py diff --git a/src/funding/migrations/0012_spent_annotation_spent_link_alter_spent_book.py b/src/funding/migrations/0012_spent_annotation_spent_link_alter_spent_book.py new file mode 100644 index 000000000..4277fb757 --- /dev/null +++ b/src/funding/migrations/0012_spent_annotation_spent_link_alter_spent_book.py @@ -0,0 +1,30 @@ +# Generated by Django 4.0.8 on 2024-02-21 11:52 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('catalogue', '0046_alter_book_options_alter_bookmedia_options_and_more'), + ('funding', '0011_alter_funding_customer_ip_alter_funding_notify_key_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='spent', + name='annotation', + field=models.CharField(blank=True, help_text="np. 'audiobook'", max_length=255, verbose_name='adnotacja'), + ), + migrations.AddField( + model_name='spent', + name='link', + field=models.URLField(blank=True, help_text='zamiast książki, np. kolekcja'), + ), + migrations.AlterField( + model_name='spent', + name='book', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='catalogue.book'), + ), + ] diff --git a/src/funding/migrations/0013_missing_spent.py b/src/funding/migrations/0013_missing_spent.py new file mode 100644 index 000000000..d7da1bfe0 --- /dev/null +++ b/src/funding/migrations/0013_missing_spent.py @@ -0,0 +1,41 @@ +# Generated by Django 4.0.8 on 2024-02-21 11:55 + +from django.db import migrations, models + + +def populate_spent(apps, schema_editor): + Offer = apps.get_model('funding', 'Offer') + Spent = apps.get_model('funding', 'Spent') + Book = apps.get_model('catalogue', 'Book') + for o in Offer.objects.all(): + if Spent.objects.filter(book__slug=o.slug).exists(): + continue + s = o.funding_set.exclude(completed_at=None).aggregate(s=models.Sum('amount'))['s'] or 0 + if s >= o.target: + try: + book = Book.objects.get(slug=o.slug) + link = '' + except Book.DoesNotExist: + book = None + link = o.slug + Spent.objects.create( + book=book, + link=link, + amount=o.target, + timestamp=o.end, + annotation='auto' + ) + + +class Migration(migrations.Migration): + + dependencies = [ + ('funding', '0012_spent_annotation_spent_link_alter_spent_book'), + ] + + operations = [ + migrations.RunPython( + populate_spent, + migrations.RunPython.noop + ) + ] diff --git a/src/funding/models.py b/src/funding/models.py index 23afa3c04..12fa0ca3e 100644 --- a/src/funding/models.py +++ b/src/funding/models.py @@ -372,9 +372,11 @@ class PayUNotification(club.payu.models.Notification): class Spent(models.Model): """ Some of the remaining money spent on a book. """ - book = models.ForeignKey(Book, models.PROTECT) + book = models.ForeignKey(Book, models.PROTECT, null=True, blank=True) + link = models.URLField(blank=True, help_text='zamiast książki, np. kolekcja') amount = models.DecimalField('kwota', decimal_places=2, max_digits=10) timestamp = models.DateField('kiedy') + annotation = models.CharField('adnotacja', max_length=255, blank=True, help_text="np. 'audiobook'") class Meta: verbose_name = 'pieniądze wydane na książkę' diff --git a/src/funding/templates/funding/wlfund.html b/src/funding/templates/funding/wlfund.html index 5a1ba61b4..bff10921e 100644 --- a/src/funding/templates/funding/wlfund.html +++ b/src/funding/templates/funding/wlfund.html @@ -26,7 +26,8 @@ {% trans "Data" %}: {% trans "Rozdysponowanie środków" %}: - {% trans "Kwota" %}: + {% trans "Zebrane" %}: + {% trans "Wydane" %}: {% trans "Bilans" %}: @@ -35,20 +36,29 @@ {{ entry.timestamp }} - {% trans "Pieniądze przeznaczone na opublikowanie książki" %}: - {{ entry.book }} + {% trans "Pieniądze przeznaczone na publikację" %}: + {% if entry.book %} + {{ entry.book }} + {% if entry.annotation %} + ({{ entry.annotation }}) + {% endif %} + {% else %} + {{ entry.annotation }} + {% endif %} - -{{ entry.amount }} zł + + {{ entry.amount }} zł {{ entry.total }} zł {% else %} {{ entry.end }} - {% trans "Pieniądze pozostałe ze zbiórki na" %}: + {% trans "Zbiórka" %}: {{ entry }} - +{{ entry.wlfund }} zł + {{ entry.wlfund }} zł + {{ entry.total }} zł {% endif %} diff --git a/src/funding/views.py b/src/funding/views.py index 9b4378062..5be8c4b89 100644 --- a/src/funding/views.py +++ b/src/funding/views.py @@ -51,20 +51,15 @@ class WLFundView(TemplateView): offers = [] for o in Offer.past(): - if o.is_win(): - o.wlfund = o.sum() - o.target - if o.wlfund > 0: - offers.append(o) - else: - o.wlfund = o.sum() - if o.wlfund > 0: - offers.append(o) + o.wlfund = o.sum() + if o.wlfund > 0: + offers.append(o) amount = sum(o.wlfund for o in offers) - sum(o.amount for o in Spent.objects.all()) ctx['amount'] = amount ctx['log'] = add_total(amount, mix( - (offers, lambda x: x.end, 'offer'), (Spent.objects.all().select_related(), lambda x: x.timestamp, 'spent'), + (offers, lambda x: x.end, 'offer'), )) return ctx -- 2.20.1 From 0b270a76ad73162f894285c360a0ee87fa84e536 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 12 Mar 2024 10:00:44 +0100 Subject: [PATCH 10/16] Hidden infopages. --- src/infopages/admin.py | 2 +- ...05_infopage_findable_infopage_published.py | 25 ++++++++++++++++ src/infopages/models.py | 5 ++++ .../templates/infopages/infopage.html | 29 ++++++++++++------- src/infopages/views.py | 5 +++- src/search/views.py | 2 ++ 6 files changed, 55 insertions(+), 13 deletions(-) create mode 100644 src/infopages/migrations/0005_infopage_findable_infopage_published.py diff --git a/src/infopages/admin.py b/src/infopages/admin.py index b8001a625..e681445a3 100644 --- a/src/infopages/admin.py +++ b/src/infopages/admin.py @@ -8,6 +8,6 @@ from infopages.models import InfoPage class InfoPageAdmin(TranslationAdmin): - list_display = ('title', 'slug') + list_display = ('title', 'slug', 'published', 'findable') admin.site.register(InfoPage, InfoPageAdmin) diff --git a/src/infopages/migrations/0005_infopage_findable_infopage_published.py b/src/infopages/migrations/0005_infopage_findable_infopage_published.py new file mode 100644 index 000000000..8e1e47ad9 --- /dev/null +++ b/src/infopages/migrations/0005_infopage_findable_infopage_published.py @@ -0,0 +1,25 @@ +# Generated by Django 4.0.8 on 2024-03-12 08:50 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('infopages', '0004_alter_infopage_options_alter_infopage_left_column_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='infopage', + name='findable', + field=models.BooleanField(default=True, verbose_name='wyszukiwalna'), + preserve_default=False, + ), + migrations.AddField( + model_name='infopage', + name='published', + field=models.BooleanField(default=True, help_text='Nieopublikowane strony są widoczne tylko dla administratorów.', verbose_name='opublikowana'), + preserve_default=False, + ), + ] diff --git a/src/infopages/models.py b/src/infopages/models.py index d398c75a5..d273b54a1 100644 --- a/src/infopages/models.py +++ b/src/infopages/models.py @@ -10,6 +10,11 @@ class InfoPage(models.Model): slug = models.SlugField('slug', max_length=120, unique=True, db_index=True) title = models.CharField('tytuł', max_length=120, blank=True) + published = models.BooleanField( + 'opublikowana', + help_text='Nieopublikowane strony są widoczne tylko dla administratorów.' + ) + findable = models.BooleanField('wyszukiwalna') left_column = models.TextField('lewa kolumna', blank=True) right_column = models.TextField('prawa kolumna', blank=True) diff --git a/src/infopages/templates/infopages/infopage.html b/src/infopages/templates/infopages/infopage.html index 5c6da3510..7bd5faa60 100644 --- a/src/infopages/templates/infopages/infopage.html +++ b/src/infopages/templates/infopages/infopage.html @@ -7,17 +7,24 @@ {% block main %} -
-

{{ page.title }}

+ {% if not page.published %} +
+ (Strona nie opublikowana, podgląd tylko dla zespołu.)
-
-
-
- {{ left_column }} -
-
- {{ right_column }} -
+ + {% endif %} + +
+

{{ page.title }}

+
+
+
+
+ {{ left_column }}
-
+
+ {{ right_column }} +
+
+
{% endblock %} diff --git a/src/infopages/views.py b/src/infopages/views.py index a32131024..3d1749f67 100644 --- a/src/infopages/views.py +++ b/src/infopages/views.py @@ -8,7 +8,10 @@ from infopages.models import InfoPage def infopage(request, slug): - page = get_object_or_404(InfoPage, slug=slug) + if request.user.is_staff: + page = get_object_or_404(InfoPage, slug=slug) + else: + page = get_object_or_404(InfoPage, slug=slug, published=True) rc = RequestContext(request) try: diff --git a/src/search/views.py b/src/search/views.py index 2f9adab36..dc7559fc9 100644 --- a/src/search/views.py +++ b/src/search/views.py @@ -116,6 +116,8 @@ def hint(request, mozhint=False, param='term'): ]) if len(data) < limit: infos = infopages.models.InfoPage.objects.filter( + published=True, + findable=True, title_pl__iregex='\m' + prefix).only('title', 'id', 'slug') data.extend([ { -- 2.20.1 From f812cdbfdb99f51ba98c13d673dd0da1180c8dc2 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 19 Mar 2024 11:51:51 +0100 Subject: [PATCH 11/16] fix toc --- src/wolnelektury/static/2022/styles/layout/_text.scss | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wolnelektury/static/2022/styles/layout/_text.scss b/src/wolnelektury/static/2022/styles/layout/_text.scss index 0a0e2a5a2..22ad16c9f 100644 --- a/src/wolnelektury/static/2022/styles/layout/_text.scss +++ b/src/wolnelektury/static/2022/styles/layout/_text.scss @@ -89,6 +89,11 @@ } + +#heretoc { + margin-top: .5em; +} + #menu .box { display: none; position: absolute; @@ -99,7 +104,7 @@ height: 300px; padding: 30px; overflow: auto; - background: #F7BA00; + background: #FFE79E; box-shadow: 0px 0px 20px rgba(1, 129, 137, 0.2); border-radius: 10px; } @@ -185,7 +190,6 @@ height: 300px; padding: 0px 30px 30px; overflow: auto; - background: #F7BA00; box-shadow: 0px 0px 20px rgba(1, 129, 137, 0.2); border-radius: 10px; -- 2.20.1 From 7a27a3fbc14b2049b8d110db15855a625e4c2455 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 19 Mar 2024 12:10:46 +0100 Subject: [PATCH 12/16] fix --- src/wolnelektury/static/2022/styles/layout/_text.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wolnelektury/static/2022/styles/layout/_text.scss b/src/wolnelektury/static/2022/styles/layout/_text.scss index 22ad16c9f..dd48d4f25 100644 --- a/src/wolnelektury/static/2022/styles/layout/_text.scss +++ b/src/wolnelektury/static/2022/styles/layout/_text.scss @@ -92,6 +92,11 @@ #heretoc { margin-top: .5em; + + // Workaround for missing li's. + ol a { + line-height: 30px; + } } #menu .box { -- 2.20.1 From dee22de65cab11aa05b68313e22e0201308de826 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 10 Apr 2024 12:56:20 +0200 Subject: [PATCH 13/16] Funding: help texts for Spent objects. --- src/funding/admin.py | 1 + ...nt_annotation_alter_spent_book_and_more.py | 30 +++++++++++++++++++ src/funding/models.py | 22 +++++++++++--- 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 src/funding/migrations/0014_alter_spent_annotation_alter_spent_book_and_more.py diff --git a/src/funding/admin.py b/src/funding/admin.py index bb44cd451..7402c2a95 100644 --- a/src/funding/admin.py +++ b/src/funding/admin.py @@ -73,6 +73,7 @@ class SpentAdmin(admin.ModelAdmin): model = Spent list_display = ['book', 'amount', 'timestamp'] search_fields = ['book__title'] + autocomplete_fields = ['book'] admin.site.register(Offer, OfferAdmin) diff --git a/src/funding/migrations/0014_alter_spent_annotation_alter_spent_book_and_more.py b/src/funding/migrations/0014_alter_spent_annotation_alter_spent_book_and_more.py new file mode 100644 index 000000000..0e6ea3bb1 --- /dev/null +++ b/src/funding/migrations/0014_alter_spent_annotation_alter_spent_book_and_more.py @@ -0,0 +1,30 @@ +# Generated by Django 4.0.8 on 2024-04-10 10:54 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('catalogue', '0046_alter_book_options_alter_bookmedia_options_and_more'), + ('funding', '0013_missing_spent'), + ] + + operations = [ + migrations.AlterField( + model_name='spent', + name='annotation', + field=models.CharField(blank=True, help_text='Adnotacja pojawi się w nawiasie w rozliczeniu, by wyjaśnić sytuację w której do tej samej książki może być przypisany więcej niż jeden wydatek. Np. osobny wydatek na audiobook może mieć adnotację „audiobook”.', max_length=255, verbose_name='adnotacja'), + ), + migrations.AlterField( + model_name='spent', + name='book', + field=models.ForeignKey(blank=True, help_text='Książka, na którą zostały wydatkowane środki. Powinny tu być uwzględnione zarówno książki na które zbierano środki, jak i dodatkowe książki sfinansowane z nadwyżek ze zbiórek.', null=True, on_delete=django.db.models.deletion.PROTECT, to='catalogue.book', verbose_name='książka'), + ), + migrations.AlterField( + model_name='spent', + name='link', + field=models.URLField(blank=True, help_text='Jeśli wydatek nie dotyczy pojedynczej książki, to zamiast pola „Książka” powinien zostać uzupełniony link do sfinansowanego obiektu (np. kolekcji).'), + ), + ] diff --git a/src/funding/models.py b/src/funding/models.py index 12fa0ca3e..5afdc2259 100644 --- a/src/funding/models.py +++ b/src/funding/models.py @@ -372,11 +372,25 @@ class PayUNotification(club.payu.models.Notification): class Spent(models.Model): """ Some of the remaining money spent on a book. """ - book = models.ForeignKey(Book, models.PROTECT, null=True, blank=True) - link = models.URLField(blank=True, help_text='zamiast książki, np. kolekcja') + book = models.ForeignKey( + Book, models.PROTECT, null=True, blank=True, + verbose_name='książka', + help_text='Książka, na którą zostały wydatkowane środki. ' + 'Powinny tu być uwzględnione zarówno książki na które zbierano środki, jak i dodatkowe książki ' + 'sfinansowane z nadwyżek ze zbiórek.' + ) + link = models.URLField( + blank=True, + help_text="Jeśli wydatek nie dotyczy pojedynczej książki, to zamiast pola „Książka” " + "powinien zostać uzupełniony link do sfinansowanego obiektu (np. kolekcji)." + ) amount = models.DecimalField('kwota', decimal_places=2, max_digits=10) timestamp = models.DateField('kiedy') - annotation = models.CharField('adnotacja', max_length=255, blank=True, help_text="np. 'audiobook'") + annotation = models.CharField( + 'adnotacja', max_length=255, blank=True, + help_text="Adnotacja pojawi się w nawiasie w rozliczeniu, by wyjaśnić sytuację w której " + "do tej samej książki może być przypisany więcej niż jeden wydatek. " + "Np. osobny wydatek na audiobook może mieć adnotację „audiobook”.") class Meta: verbose_name = 'pieniądze wydane na książkę' @@ -384,5 +398,5 @@ class Spent(models.Model): ordering = ['-timestamp'] def __str__(self): - return "Spent: %s" % str(self.book) + return "Wydane na: %s" % str(self.book or self.link) -- 2.20.1 From 1959361810afbb5f1de88b7d717da32979c7235d Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 10 Apr 2024 13:34:15 +0200 Subject: [PATCH 14/16] Fundraising in PDF. --- requirements/requirements.txt | 2 +- src/annoy/models.py | 1 + src/catalogue/fields.py | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 0fa614370..eede89479 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -39,7 +39,7 @@ mutagen==1.45.1 sorl-thumbnail==12.8.0 # home-brewed & dependencies -librarian==24.1 +librarian==24.4.1 # celery tasks celery[redis]==5.2.7 diff --git a/src/annoy/models.py b/src/annoy/models.py index da371fc43..e60e3c024 100644 --- a/src/annoy/models.py +++ b/src/annoy/models.py @@ -116,6 +116,7 @@ class MediaInsertSet(models.Model): file_format = models.CharField(max_length=8, choices=[ ('epub', 'epub'), ('mobi', 'mobi'), + ('pdf', 'pdf'), ]) etag = models.CharField(max_length=64, blank=True) diff --git a/src/catalogue/fields.py b/src/catalogue/fields.py index 94bdb6097..c4dec7e3f 100644 --- a/src/catalogue/fields.py +++ b/src/catalogue/fields.py @@ -251,10 +251,13 @@ class PdfField(EbookField): @staticmethod def transform(wldoc, book): + MediaInsertSet = apps.get_model('annoy', 'MediaInsertSet') return wldoc.as_pdf( morefloats=settings.LIBRARIAN_PDF_MOREFLOATS, cover=get_make_cover(book), - base_url=absolute_url(gallery_url(wldoc.book_info.url.slug)), customizations=['notoc']) + base_url=absolute_url(gallery_url(wldoc.book_info.url.slug)), customizations=['notoc'], + fundraising=MediaInsertSet.get_texts_for('pdf'), + ) def build(self, fieldfile): super().build(fieldfile) -- 2.20.1 From f3ee4c1bfbf4e3856268fa79c63465f591f3499e Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 20 May 2024 15:19:37 +0200 Subject: [PATCH 15/16] Translators as authors. --- .../migrations/0047_book_translators.py | 18 +++++++++++++++ src/catalogue/models/book.py | 14 +++++------- src/catalogue/models/tag.py | 22 +++++++++++-------- .../templates/catalogue/book_detail.html | 15 ++++++------- .../templates/catalogue/book_list.html | 11 ++++++++++ .../templates/catalogue/book_text.html | 19 ++++++++-------- src/catalogue/views.py | 2 ++ src/picture/models.py | 2 +- 8 files changed, 67 insertions(+), 36 deletions(-) create mode 100644 src/catalogue/migrations/0047_book_translators.py diff --git a/src/catalogue/migrations/0047_book_translators.py b/src/catalogue/migrations/0047_book_translators.py new file mode 100644 index 000000000..6146f6495 --- /dev/null +++ b/src/catalogue/migrations/0047_book_translators.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.8 on 2024-05-20 12:31 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('catalogue', '0046_alter_book_options_alter_bookmedia_options_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='book', + name='translators', + field=models.ManyToManyField(to='catalogue.tag'), + ), + ] diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index 10e9d22e3..9e0ec50ff 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -91,6 +91,7 @@ class Book(models.Model): tagged = managers.ModelTaggedItemManager(Tag) tags = managers.TagDescriptor(Tag) tag_relations = GenericRelation(Tag.intermediary_table_model) + translators = models.ManyToManyField(Tag) html_built = django.dispatch.Signal() published = django.dispatch.Signal() @@ -154,12 +155,6 @@ class Book(models.Model): def genre_unicode(self): return self.tag_unicode('genre') - def translators(self): - translators = self.get_extra_info_json().get('translators') or [] - return [ - '\xa0'.join(reversed(translator.split(', ', 1))) for translator in translators - ] - def translator(self): translators = self.get_extra_info_json().get('translators') if not translators: @@ -658,14 +653,17 @@ class Book(models.Model): meta_tags = Tag.tags_from_info(book_info) - for tag in meta_tags: + for tag, relationship in meta_tags: if not tag.for_books: tag.for_books = True tag.save() - book.tags = set(meta_tags + book_shelves) + just_tags = [t for (t, rel) in meta_tags if not rel] + book.tags = set(just_tags + book_shelves) book.save() # update sort_key_author + book.translators.set([t for (t, rel) in meta_tags if rel == 'translator']) + cover_changed = old_cover != book.cover_info() obsolete_children = set(b for b in book.children.all() if b not in children) diff --git a/src/catalogue/models/tag.py b/src/catalogue/models/tag.py index cdc1dc8a2..a5c96d542 100644 --- a/src/catalogue/models/tag.py +++ b/src/catalogue/models/tag.py @@ -213,16 +213,20 @@ class Tag(models.Model): from slugify import slugify from sortify import sortify meta_tags = [] - categories = (('kinds', 'kind'), ('genres', 'genre'), ('authors', 'author'), ('epochs', 'epoch')) - for field_name, category in categories: + categories = ( + # BookInfo field names, Tag category, relationship + ('kinds', 'kind', None), + ('genres', 'genre', None), + ('epochs', 'epoch', None), + ('authors', 'author', None), + ('translators', 'author', 'translator'), + ) + for field_name, category, relationship in categories: try: tag_names = getattr(info, field_name) except (AttributeError, KeyError): # TODO: shouldn't be KeyError here at all. - try: - tag_names = [getattr(info, category)] - except KeyError: - # For instance, Pictures do not have 'genre' field. - continue + # For instance, Pictures do not have 'genre' field. + continue for tag_name in tag_names: lang = getattr(tag_name, 'lang', None) or settings.LANGUAGE_CODE tag_sort_key = tag_name @@ -243,9 +247,9 @@ class Tag(models.Model): tag.sort_key = sortify(tag_sort_key.lower()) tag.save() - meta_tags.append(tag) + meta_tags.append((tag, relationship)) else: - meta_tags.append(tag) + meta_tags.append((tag, relationship)) return meta_tags diff --git a/src/catalogue/templates/catalogue/book_detail.html b/src/catalogue/templates/catalogue/book_detail.html index 6586970dd..eb1ab8a7d 100644 --- a/src/catalogue/templates/catalogue/book_detail.html +++ b/src/catalogue/templates/catalogue/book_detail.html @@ -90,18 +90,17 @@

{% for author in book.authors %}{{ author.name }}{% if not forloop.last %}, {% endif %}{% endfor %}

{{ book.title }}

- {% with translators=book.translators %} - {% if translators %} + {% if book.translators.exists %}

- {% if translators.0 != 'tłumacz nieznany' %} - {% trans "tłum." %} - {% endif %} - {% for translator in translators %} - {{ translator }}{% if not forloop.last %}, {% endif %} + {% for translator in book.translators.all %} + {% if forloop.first and translator.name != 'tłumacz nieznany' %} + {% trans "tłum." %} + {% endif %} + + {{ translator }}{% if not forloop.last %}, {% endif %} {% endfor %}

{% endif %} - {% endwith %}
diff --git a/src/catalogue/templates/catalogue/book_list.html b/src/catalogue/templates/catalogue/book_list.html index dabb0ca48..e8debd975 100644 --- a/src/catalogue/templates/catalogue/book_list.html +++ b/src/catalogue/templates/catalogue/book_list.html @@ -117,6 +117,17 @@ {% paginate %}
+ {% if translation_list %} +
+

Tłumaczenia

+
+ {% for book in translation_list %} + {% include "catalogue/book_box.html" %} + {% endfor %} +
+
+ {% endif %} + {% if main_tag %}
diff --git a/src/catalogue/templates/catalogue/book_text.html b/src/catalogue/templates/catalogue/book_text.html index 421d439fe..52f281b05 100644 --- a/src/catalogue/templates/catalogue/book_text.html +++ b/src/catalogue/templates/catalogue/book_text.html @@ -151,18 +151,17 @@

{% for author in book.authors %}{{ author.name }}{% if not forloop.last %}, {% endif %}{% endfor %}

{{ book.title }}

- {% with translators=book.translators %} - {% if translators %} -

- {% if translators.0 != 'tłumacz nieznany' %} + {% if book.translators.exists %} +

+ {% for translator in book.translators.all %} + {% if forloop.first and translator.name != 'tłumacz nieznany' %} {% trans "tłum." %} {% endif %} - {% for translator in translators %} - {{ translator }}{% if not forloop.last %}, {% endif %} - {% endfor %} -

- {% endif %} - {% endwith %} + + {{ translator }}{% if not forloop.last %}, {% endif %} + {% endfor %} +

+ {% endif %}
{% content_warning book %}
diff --git a/src/catalogue/views.py b/src/catalogue/views.py index af4d1e3b5..588cdb073 100644 --- a/src/catalogue/views.py +++ b/src/catalogue/views.py @@ -253,6 +253,8 @@ class TaggedObjectList(BookList): t for t in self.ctx['tags'] if t is not self.ctx['main_tag'] ] + if len(self.ctx['tags']) == 1 and self.ctx['main_tag'].category == 'author': + self.ctx['translation_list'] = self.ctx['main_tag'].book_set.all() def get_queryset(self): qs = Book.tagged.with_all(self.ctx['work_tags']).filter(findable=True) diff --git a/src/picture/models.py b/src/picture/models.py index dec9960cb..98fd382f3 100644 --- a/src/picture/models.py +++ b/src/picture/models.py @@ -202,7 +202,7 @@ class Picture(models.Model): picture.title = str(picture_xml.picture_info.title) picture.extra_info = json.dumps(picture_xml.picture_info.to_dict()) - picture_tags = set(catalogue.models.Tag.tags_from_info(picture_xml.picture_info)) + picture_tags = set([t for (t, rel) in catalogue.models.Tag.tags_from_info(picture_xml.picture_info)]) for tag in picture_tags: if not tag.for_pictures: tag.for_pictures = True -- 2.20.1 From 2c101e78aee8cd3ccf3f24a0ecaa22fa77593c5c Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 20 May 2024 15:21:30 +0200 Subject: [PATCH 16/16] remove the banner --- src/wolnelektury/templates/base.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/wolnelektury/templates/base.html b/src/wolnelektury/templates/base.html index 170a0797b..f1a7bf685 100644 --- a/src/wolnelektury/templates/base.html +++ b/src/wolnelektury/templates/base.html @@ -30,8 +30,6 @@ {% block under-menu %}{% endblock %} - {% include 'banner_procent.html' %} - {% if not funding_no_show_current %}
{% cache 120 funding_top_bar LANGUAGE_CODE %} -- 2.20.1