From 7875aab03fcc043840567f873c9e38e4ee9f638c Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 24 May 2021 17:26:13 +0200 Subject: [PATCH 01/16] comma --- src/catalogue/locale/pl/LC_MESSAGES/django.mo | Bin 12739 -> 12740 bytes src/catalogue/locale/pl/LC_MESSAGES/django.po | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/catalogue/locale/pl/LC_MESSAGES/django.mo b/src/catalogue/locale/pl/LC_MESSAGES/django.mo index 7c003bf20052ad84143bd3c950cf6711970adf45..110d99c09f7341351a7904b6ea02a824cadb8af3 100644 GIT binary patch delta 1389 zcmXZaOGwmF6vy#vjgF(vXuj#CmYUPUR2nKP-9(0oMMPLGBBhYpahU^)h?eZxq|6<{9jM`i9M(aG+F;?>+iC5pS1@tlX3S@6@6%NZ`=ZNsFNiz z6IbvcrbYd$X~GS(+fbG2K`nF>^%fqWDlmdt=c%>h*8dK5&<}VN|KN7V{WtSHMBoyJ za1`}OCQx@ak9reHa|t_X|3uw&JN4DZr;uB5ow%Il+zr&-U)klaH;h_m4E46AFwFig z&W{ErQ5*ilUd*laD=~oev~Q#Or%@XxFo+AN#NVT?Y6&Cw+v0)Uet!ftzZ6yBsAPZF zz)vK;_a9+u->%*6=|;0!9Ec{5=ypemU{jr)e$_!lbSRrGX%j5_}$ z5zL}pj4D+HDzRGBgho`U51YqO^G~A2okh*Rh)Spzl|Vmg{vGQdMy>O>j{55njS>js zG^%uQ)B-8g!XGXE6}7=%R7KLc7oDgCl}Nc+gF0~?=3xx=Xpf*0Id5LBKknRG0(}HD z;VNq5>!=I|ZQu}U`k{Dzvpid9(I=Omc_zbWaR zXn?>50#9u~233)~`N`s6P>HOdPF~yWov0p*XzxJH>$Y|Rx6M zFn}w#8{KB_YT~$&<^fcthENM#N4;5aqb%G?$5V+>rJ56nMS>>Sq!qj z%kZOtIn;*#@FIq`d6gK&cG@>l{d1^|v*^b~RO0VYSG9y8{B7}qHm^U3nqP~maEoMr z*UnEVc3DRPb*Fu(S3QKv_$o&6HkM-wefSEM(1MvY7g3eWqsA?xHvWZ5coma6L1D~0 zNf1kDSEEW5MJ3jXny?F1>OJOu)cixJamP^e&!7^zfJ$HlHUF0NPoUO$7^D7rL{kKU zIEN}-2DLyQweSave?@KZ7gZ4-_o5Tkpc09g&8QQ%VFh-g9_?OKBB#uA?S0M_5Ev$) x371eCUqNMf!v>C{Hoj}|2dH_EEIy4o!1HvbY$@#P=!$Jmry~8nbV\n" "Language-Team: Fundacja Nowoczesna Polska \n" @@ -554,7 +554,7 @@ msgstr "Jak na razie ten utwór jest dostępny wyłącznie dla naszych Przyjaci #: catalogue/templates/catalogue/book_text.html:24 msgid "Click to download" -msgstr "Kliknij by pobrać" +msgstr "Kliknij, by pobrać" #: catalogue/templates/catalogue/book_text.html:42 msgid "Table of contents" -- 2.20.1 From cbe7ef2f04d751e6f719299632d77cfcb29be8f1 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 26 May 2021 14:36:59 +0200 Subject: [PATCH 02/16] Filter schedules by source. --- src/club/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/club/admin.py b/src/club/admin.py index 0cf7d342c..0a23c20cf 100644 --- a/src/club/admin.py +++ b/src/club/admin.py @@ -57,7 +57,7 @@ class ExpiredFilter(YesNoFilter): class ScheduleAdmin(admin.ModelAdmin): list_display = ['email', 'started_at', 'payed_at', 'expires_at', 'amount', 'monthly', 'yearly', 'is_cancelled'] search_fields = ['email'] - list_filter = ['is_cancelled', 'monthly', 'yearly', PayedFilter, ExpiredFilter] + list_filter = ['is_cancelled', 'monthly', 'yearly', PayedFilter, ExpiredFilter, 'source'] date_hierarchy = 'started_at' raw_id_fields = ['membership'] inlines = [PayUOrderInline, PayUCardTokenInline] -- 2.20.1 From 1f4c831ff6f96b3a34fcca497adfd16838abc569 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 31 May 2021 15:37:27 +0200 Subject: [PATCH 03/16] Download visit stats. --- src/stats/admin.py | 5 +++++ src/stats/models.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/stats/admin.py diff --git a/src/stats/admin.py b/src/stats/admin.py new file mode 100644 index 000000000..979f18022 --- /dev/null +++ b/src/stats/admin.py @@ -0,0 +1,5 @@ +from django.contrib import admin +from . import models + + +admin.site.register(models.Visits) diff --git a/src/stats/models.py b/src/stats/models.py index e69de29bb..ea1a79042 100644 --- a/src/stats/models.py +++ b/src/stats/models.py @@ -0,0 +1,36 @@ +import re +from django.conf import settings +from django.db import models + + +class Visits(models.Model): + book = models.ForeignKey('catalogue.Book', models.CASCADE) + year = models.PositiveSmallIntegerField() + month = models.PositiveSmallIntegerField() + views = models.IntegerField() + unique_views = models.IntegerField() + + @classmethod + def build_month(cls, year, month): + ### TODO: Delete existing? + + date = f'{year}-{month:02d}' + url = f'{settings.PIWIK_URL}?date={date}&filter_limit=-1&format=CSV&idSite={settings.PIWIK_SITE_ID}&language=pl&method=Actions.getPageUrls&module=API&period=month&segment=&token_auth={settings.PIWIK_TOKEN}&flat=1' + data = urlopen(url).read().decode('utf-16') + lines = data.split('\n')[1:] + for line in lines: + m = re.match('^/katalog/lektura/([^,]+)\.html,', line) + if m is not None: + slug = m.group(1) + _url, uviews, views = line.split(',', 3) + uviews = int(uviews) + views = int(views) + try: + book = Book.objects.get(slug=slug) + except Book.DoesNotExists: + continue + else: + cls.objects.create( + book=book, year=year, month=month, + views=views, uviews=uviews + ) -- 2.20.1 From 01fd09f3c7d265ad5debb7e4fc78ab17ec7341b6 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 31 May 2021 15:38:35 +0200 Subject: [PATCH 04/16] A migration. --- src/stats/migrations/0001_initial.py | 27 +++++++++++++++++++++++++++ src/stats/migrations/__init__.py | 0 2 files changed, 27 insertions(+) create mode 100644 src/stats/migrations/0001_initial.py create mode 100644 src/stats/migrations/__init__.py diff --git a/src/stats/migrations/0001_initial.py b/src/stats/migrations/0001_initial.py new file mode 100644 index 000000000..691701b0b --- /dev/null +++ b/src/stats/migrations/0001_initial.py @@ -0,0 +1,27 @@ +# Generated by Django 2.2.19 on 2021-05-31 13:36 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('catalogue', '0032_collection_listed'), + ] + + operations = [ + migrations.CreateModel( + name='Visits', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('year', models.PositiveSmallIntegerField()), + ('month', models.PositiveSmallIntegerField()), + ('views', models.IntegerField()), + ('unique_views', models.IntegerField()), + ('book', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='catalogue.Book')), + ], + ), + ] diff --git a/src/stats/migrations/__init__.py b/src/stats/migrations/__init__.py new file mode 100644 index 000000000..e69de29bb -- 2.20.1 From 8a9843b112f8a3f72603afc9fb5d15ddcbd77559 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 31 May 2021 15:40:52 +0200 Subject: [PATCH 05/16] Fix imports. --- src/stats/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/stats/models.py b/src/stats/models.py index ea1a79042..0bd391a55 100644 --- a/src/stats/models.py +++ b/src/stats/models.py @@ -1,4 +1,6 @@ import re +from urllib.request import urlopen +from django.apps import apps from django.conf import settings from django.db import models @@ -12,6 +14,7 @@ class Visits(models.Model): @classmethod def build_month(cls, year, month): + Book = apps.get_model('catalogue', 'Book') ### TODO: Delete existing? date = f'{year}-{month:02d}' -- 2.20.1 From bb5061a441f8b5c69da7cb0df4ad89b847610961 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 31 May 2021 15:42:18 +0200 Subject: [PATCH 06/16] fix --- src/stats/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stats/models.py b/src/stats/models.py index 0bd391a55..6ddb4bc71 100644 --- a/src/stats/models.py +++ b/src/stats/models.py @@ -25,7 +25,7 @@ class Visits(models.Model): m = re.match('^/katalog/lektura/([^,]+)\.html,', line) if m is not None: slug = m.group(1) - _url, uviews, views = line.split(',', 3) + _url, uviews, views, _rest = line.split(',', 3) uviews = int(uviews) views = int(views) try: -- 2.20.1 From c4c73f2204ba7136b9573c33b2a0f9a01829b78a Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 1 Jun 2021 11:03:24 +0200 Subject: [PATCH 07/16] fix --- src/stats/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stats/models.py b/src/stats/models.py index 6ddb4bc71..c1b4d16d8 100644 --- a/src/stats/models.py +++ b/src/stats/models.py @@ -30,10 +30,10 @@ class Visits(models.Model): views = int(views) try: book = Book.objects.get(slug=slug) - except Book.DoesNotExists: + except Book.DoesNotExist: continue else: cls.objects.create( book=book, year=year, month=month, - views=views, uviews=uviews + views=views, unique_views=uviews ) -- 2.20.1 From 16ca16378b89015b7762bfa27a042097844ce668 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 1 Jun 2021 12:24:53 +0200 Subject: [PATCH 08/16] Updating stats. --- src/stats/models.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/stats/models.py b/src/stats/models.py index c1b4d16d8..7d850af11 100644 --- a/src/stats/models.py +++ b/src/stats/models.py @@ -15,7 +15,6 @@ class Visits(models.Model): @classmethod def build_month(cls, year, month): Book = apps.get_model('catalogue', 'Book') - ### TODO: Delete existing? date = f'{year}-{month:02d}' url = f'{settings.PIWIK_URL}?date={date}&filter_limit=-1&format=CSV&idSite={settings.PIWIK_SITE_ID}&language=pl&method=Actions.getPageUrls&module=API&period=month&segment=&token_auth={settings.PIWIK_TOKEN}&flat=1' @@ -33,7 +32,7 @@ class Visits(models.Model): except Book.DoesNotExist: continue else: - cls.objects.create( + cls.objects.update_or_create( book=book, year=year, month=month, - views=views, unique_views=uviews + defaults={'views': views, 'unique_views': uviews} ) -- 2.20.1 From b407504fbd3d55b7dfd64e82c1ab12d3a8d688bf Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 1 Jun 2021 13:04:25 +0200 Subject: [PATCH 09/16] Stats migrations. --- src/stats/admin.py | 9 +++++- src/stats/migrations/0002_visits_date.py | 19 ++++++++++++ src/stats/migrations/0003_migrate_months.py | 29 +++++++++++++++++++ .../migrations/0004_auto_20210601_1303.py | 21 ++++++++++++++ src/stats/models.py | 5 ++-- 5 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 src/stats/migrations/0002_visits_date.py create mode 100644 src/stats/migrations/0003_migrate_months.py create mode 100644 src/stats/migrations/0004_auto_20210601_1303.py diff --git a/src/stats/admin.py b/src/stats/admin.py index 979f18022..11dfe7e89 100644 --- a/src/stats/admin.py +++ b/src/stats/admin.py @@ -2,4 +2,11 @@ from django.contrib import admin from . import models -admin.site.register(models.Visits) +class VisitsAdmin(admin.ModelAdmin): + list_display = ['book', 'date', 'views', 'unique_views'] + raw_id_fields = ['book'] + date_hierarchy = 'date' + + + +admin.site.register(models.Visits, VisitsAdmin) diff --git a/src/stats/migrations/0002_visits_date.py b/src/stats/migrations/0002_visits_date.py new file mode 100644 index 000000000..4abcafe39 --- /dev/null +++ b/src/stats/migrations/0002_visits_date.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.19 on 2021-06-01 10:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('stats', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='visits', + name='date', + field=models.DateField(default='1970-01-01'), + preserve_default=False, + ), + ] diff --git a/src/stats/migrations/0003_migrate_months.py b/src/stats/migrations/0003_migrate_months.py new file mode 100644 index 000000000..077819ad9 --- /dev/null +++ b/src/stats/migrations/0003_migrate_months.py @@ -0,0 +1,29 @@ +# Generated by Django 2.2.19 on 2021-06-01 10:58 + +import datetime +from django.db import migrations + + +def ints_to_dates(apps, schema_editor): + Visits = apps.get_model('stats', 'Visits') + for visit in Visits.objects.all(): + visit.date = datetime.date(visit.year, visit.month, 1) + visit.save() + +def dates_to_ints(apps, schema_editor): + Visits = apps.get_model('stats', 'Visits') + for visit in Visits.objects.all(): + visit.year = visit.date.year + visit.month = visit.date.month + visit.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('stats', '0002_visits_date'), + ] + + operations = [ + migrations.RunPython(ints_to_dates, dates_to_ints) + ] diff --git a/src/stats/migrations/0004_auto_20210601_1303.py b/src/stats/migrations/0004_auto_20210601_1303.py new file mode 100644 index 000000000..523af9b51 --- /dev/null +++ b/src/stats/migrations/0004_auto_20210601_1303.py @@ -0,0 +1,21 @@ +# Generated by Django 2.2.19 on 2021-06-01 11:03 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('stats', '0003_migrate_months'), + ] + + operations = [ + migrations.RemoveField( + model_name='visits', + name='month', + ), + migrations.RemoveField( + model_name='visits', + name='year', + ), + ] diff --git a/src/stats/models.py b/src/stats/models.py index 7d850af11..9edc17be7 100644 --- a/src/stats/models.py +++ b/src/stats/models.py @@ -7,8 +7,7 @@ from django.db import models class Visits(models.Model): book = models.ForeignKey('catalogue.Book', models.CASCADE) - year = models.PositiveSmallIntegerField() - month = models.PositiveSmallIntegerField() + date = models.DateField() views = models.IntegerField() unique_views = models.IntegerField() @@ -16,7 +15,7 @@ class Visits(models.Model): def build_month(cls, year, month): Book = apps.get_model('catalogue', 'Book') - date = f'{year}-{month:02d}' + date = f'{year}-{month:02d}-01' url = f'{settings.PIWIK_URL}?date={date}&filter_limit=-1&format=CSV&idSite={settings.PIWIK_SITE_ID}&language=pl&method=Actions.getPageUrls&module=API&period=month&segment=&token_auth={settings.PIWIK_TOKEN}&flat=1' data = urlopen(url).read().decode('utf-16') lines = data.split('\n')[1:] -- 2.20.1 From c061ce9de60c897addd6a9217465c434ba429e7e Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 1 Jun 2021 13:05:38 +0200 Subject: [PATCH 10/16] fix --- src/stats/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stats/models.py b/src/stats/models.py index 9edc17be7..e95e75951 100644 --- a/src/stats/models.py +++ b/src/stats/models.py @@ -32,6 +32,6 @@ class Visits(models.Model): continue else: cls.objects.update_or_create( - book=book, year=year, month=month, + book=book, date=date, defaults={'views': views, 'unique_views': uviews} ) -- 2.20.1 From 6abcfa9732ddf2221e4edb0f276067c4283e8796 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 1 Jun 2021 13:37:25 +0200 Subject: [PATCH 11/16] View top stats. --- src/stats/forms.py | 6 ++++++ src/stats/templates/stats/top.html | 32 ++++++++++++++++++++++++++++++ src/stats/urls.py | 7 +++++++ src/stats/views.py | 29 +++++++++++++++++++++++++++ src/wolnelektury/urls.py | 1 + 5 files changed, 75 insertions(+) create mode 100644 src/stats/forms.py create mode 100644 src/stats/templates/stats/top.html create mode 100644 src/stats/urls.py create mode 100644 src/stats/views.py diff --git a/src/stats/forms.py b/src/stats/forms.py new file mode 100644 index 000000000..52ff11108 --- /dev/null +++ b/src/stats/forms.py @@ -0,0 +1,6 @@ +from django import forms + + +class VisitsForm(forms.Form): + date_since = forms.DateField(required=False) + date_until = forms.DateField(required=False) diff --git a/src/stats/templates/stats/top.html b/src/stats/templates/stats/top.html new file mode 100644 index 000000000..2ff1eb21d --- /dev/null +++ b/src/stats/templates/stats/top.html @@ -0,0 +1,32 @@ +{% extends 'base/base.html' %} + + +{% block body %} +
+ {{ form.as_p }} +
+ + + + + + + + {% for v in visits %} + + + + + + {% endfor %} +
KsiążkaUnikalne odsłonyOdsłony
+ + {{ v.book__slug }} + + + {{ v.unique_views }} + + {{ v.views }} +
+
+{% endblock %} diff --git a/src/stats/urls.py b/src/stats/urls.py new file mode 100644 index 000000000..80d261178 --- /dev/null +++ b/src/stats/urls.py @@ -0,0 +1,7 @@ +from django.urls import path +from . import views + + +urlpatterns = [ + path('top/', views.TopView.as_view(), name='stats_top'), +] diff --git a/src/stats/views.py b/src/stats/views.py new file mode 100644 index 000000000..4ff85f494 --- /dev/null +++ b/src/stats/views.py @@ -0,0 +1,29 @@ +from django.contrib.auth.mixins import PermissionRequiredMixin +from django.views.generic import TemplateView +from django.db.models import Sum +from . import forms +from . import models + + +class TopView(PermissionRequiredMixin, TemplateView): + permission_required = 'stats.view_visits' + template_name = 'stats/top.html' + + def get_context_data(self, **kwargs): + ctx = super().get_context_data(**kwargs) + form = forms.VisitsForm(self.request.GET) + assert form.is_valid() + visits = models.Visits.objects.all() + if form.cleaned_data['date_since']: + visits = visits.filter(date__gte=form.cleaned_data['date_since'].replace(day=1)) + if form.cleaned_data['date_until']: + visits = visits.filter(date__lte=form.cleaned_data['date_until']) + visits = visits.values('book__slug').annotate( + views=Sum('views'), + unique_views=Sum('unique_views') + ) + visits = visits.order_by('-unique_views') + ctx['form'] = form + ctx['visits'] = visits + return ctx + diff --git a/src/wolnelektury/urls.py b/src/wolnelektury/urls.py index 1fc60fcb0..f4bd6b251 100644 --- a/src/wolnelektury/urls.py +++ b/src/wolnelektury/urls.py @@ -47,6 +47,7 @@ urlpatterns += [ path('isbn/', include('isbn.urls')), path('messaging/', include('messaging.urls')), path('re/', include('redirects.urls')), + path('stats/', include('stats.urls')), path('paypal/app-form/', RedirectView.as_view( url='/towarzystwo/?pk_campaign=aplikacja', permanent=False)), -- 2.20.1 From 1efd8702d1a638414efea3c0f0c6146e97d386f1 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 1 Jun 2021 13:41:39 +0200 Subject: [PATCH 12/16] stats view fix --- src/stats/templates/stats/top.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/stats/templates/stats/top.html b/src/stats/templates/stats/top.html index 2ff1eb21d..f5ee6c293 100644 --- a/src/stats/templates/stats/top.html +++ b/src/stats/templates/stats/top.html @@ -3,7 +3,10 @@ {% block body %}
- {{ form.as_p }} +
+ {{ form.as_p }} + +

-- 2.20.1 From b86123575745cb5b1ee72018c08e34a187ec25a1 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 1 Jun 2021 15:07:45 +0200 Subject: [PATCH 13/16] Nicer collection boxes. --- .../templates/catalogue/collection_box.html | 17 +++---- src/catalogue/views.py | 8 ++- .../static/scss/main/catalogue.scss | 18 +++++++ .../templates/base/superbase.html | 4 +- src/wolnelektury/templates/main_page.html | 50 ++++++++++++------- src/wolnelektury/views.py | 7 +-- 6 files changed, 68 insertions(+), 36 deletions(-) diff --git a/src/catalogue/templates/catalogue/collection_box.html b/src/catalogue/templates/catalogue/collection_box.html index c32122f32..214db8be9 100644 --- a/src/catalogue/templates/catalogue/collection_box.html +++ b/src/catalogue/templates/catalogue/collection_box.html @@ -2,18 +2,17 @@ {% load i18n %}

{% trans "Collection" %}: {{ collection }}

+

{% if collection.description %} {{ collection.description|safe|truncatewords_html:40 }} {% endif %} - {% for book in collection.get_books|slice:":5" %} - {{ book.mini_box }} - {% endfor %} - {% with collection.get_books.count|add:-5 as more %} - {% if more > 0 %} - - {% blocktrans count c=more %}and one more{% plural %}and {{ c }} more{% endblocktrans %} +

+
+ {% for book in collection.get_books|slice:":5" %} + + {{ book.pretty_title }} - {% endif %} - {% endwith %} + {% endfor %} +
{% endspaceless %} diff --git a/src/catalogue/views.py b/src/catalogue/views.py index 904cdc531..38c616520 100644 --- a/src/catalogue/views.py +++ b/src/catalogue/views.py @@ -66,7 +66,10 @@ def daisy_list(request): def collection(request, slug): coll = get_object_or_404(Collection, slug=slug) - return render(request, 'catalogue/collection.html', {'collection': coll}) + return render(request, 'catalogue/collection.html', { + 'collection': coll, + 'active_menu_item': 'collections', + }) def differentiate_tags(request, tags, ambiguous_slugs): @@ -455,13 +458,14 @@ def collections(request): objects = Collection.objects.filter(listed=True) if len(objects) > 3: - best = random.sample(list(objects), 3) + best = random.sample(list(objects), 4) else: best = objects return render(request, 'catalogue/collections.html', { 'objects': objects, 'best': best, + 'active_menu_item': 'collections' }) diff --git a/src/wolnelektury/static/scss/main/catalogue.scss b/src/wolnelektury/static/scss/main/catalogue.scss index ba30e8271..8148930b2 100644 --- a/src/wolnelektury/static/scss/main/catalogue.scss +++ b/src/wolnelektury/static/scss/main/catalogue.scss @@ -27,3 +27,21 @@ @include size(padding, 26px); } } + + +.collection-box { + display: inline-block; + vertical-align: top; + + @media screen and (min-width:500px) { + width: 465px; + } + + p { + height: 75px; + overflow: hidden; + } + .covers { + line-height: 0; + } +} diff --git a/src/wolnelektury/templates/base/superbase.html b/src/wolnelektury/templates/base/superbase.html index e1ec73419..e1483b683 100644 --- a/src/wolnelektury/templates/base/superbase.html +++ b/src/wolnelektury/templates/base/superbase.html @@ -120,8 +120,8 @@ {% trans "Audiobooks" %} - - {% trans "All works" %} + + {% trans "Collections" %}
  • {% trans "Newsletter" %} diff --git a/src/wolnelektury/templates/main_page.html b/src/wolnelektury/templates/main_page.html index 1bec4c2e7..f47e1d227 100644 --- a/src/wolnelektury/templates/main_page.html +++ b/src/wolnelektury/templates/main_page.html @@ -31,8 +31,39 @@ +
    +

    + + {% trans "Recent publications" %} + → + +

    + {% for book in last_published %} + {{ book.mini_box }} + {% endfor %} +
    + + {% if collections %} +
    +

    + + {% trans "Collections" %} + → + +

    + {% for collection in collections %} + {{ collection.box }} + {% endfor %} +
    + {% endif %} +
    -

    {% trans "Motifs and themes" %}

    +

    + + {% trans "Motifs and themes" %} + → + +

    {% trans "Theme" %}: {{ theme }}

    {% trans "Explore works with the same theme" %}

    @@ -45,23 +76,6 @@ {% endcache %} {% endif %}
    - {% trans "See motifs catalog" %} -
    - - {% if collection %} -
    -

    {% trans "Collections" %}

    - {{ collection.box }} - {% trans "See collections catalog" %} -
    - {% endif %} - -
    -

    {% trans "Recent publications" %}

    - {% for book in last_published %} - {{ book.mini_box }} - {% endfor %} - {% trans "More recent publications" %}
    diff --git a/src/wolnelektury/views.py b/src/wolnelektury/views.py index 48063d29b..2cc0fd799 100644 --- a/src/wolnelektury/views.py +++ b/src/wolnelektury/views.py @@ -46,11 +46,8 @@ def main_page(request): break break - # Choose a collection for main. - try: - ctx['collection'] = Collection.objects.filter(listed=True).order_by('?')[:1][0] - except IndexError: - pass + # Choose collections for main. + ctx['collections'] = Collection.objects.filter(listed=True).order_by('?')[:4] best = [] best_places = 5 -- 2.20.1 From a83d83309b360a230b9458496e8bd9df6883af05 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 1 Jun 2021 15:10:17 +0200 Subject: [PATCH 14/16] fix --- src/catalogue/templates/catalogue/collection_box.html | 4 ++-- src/wolnelektury/static/scss/main/catalogue.scss | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/catalogue/templates/catalogue/collection_box.html b/src/catalogue/templates/catalogue/collection_box.html index 214db8be9..651473591 100644 --- a/src/catalogue/templates/catalogue/collection_box.html +++ b/src/catalogue/templates/catalogue/collection_box.html @@ -2,11 +2,11 @@ {% load i18n %}

    {% trans "Collection" %}: {{ collection }}

    -

    +

    {% if collection.description %} {{ collection.description|safe|truncatewords_html:40 }} {% endif %} -

    +
    - {% for book in collection.get_books|slice:":5" %} + {% for book in collection.get_books|slice:":6" %} {{ book.pretty_title }} -- 2.20.1 From 025b93b1df94c65df26c896284580f2b00756f0a Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 1 Jun 2021 15:13:41 +0200 Subject: [PATCH 16/16] Remove a word. --- src/catalogue/templates/catalogue/collection_box.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/catalogue/templates/catalogue/collection_box.html b/src/catalogue/templates/catalogue/collection_box.html index 38855d94a..c19ea8d54 100644 --- a/src/catalogue/templates/catalogue/collection_box.html +++ b/src/catalogue/templates/catalogue/collection_box.html @@ -1,7 +1,7 @@ {% spaceless %} {% load i18n %}
    -

    {% trans "Collection" %}: {{ collection }}

    +

    {{ collection }}

    {% if collection.description %} {{ collection.description|safe|truncatewords_html:40 }} -- 2.20.1