Unlisted collections.
authorRadek Czajka <rczajka@rczajka.pl>
Wed, 5 May 2021 08:03:13 +0000 (10:03 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Wed, 5 May 2021 08:03:13 +0000 (10:03 +0200)
src/catalogue/admin.py
src/catalogue/api/views.py
src/catalogue/locale/pl/LC_MESSAGES/django.mo
src/catalogue/locale/pl/LC_MESSAGES/django.po
src/catalogue/migrations/0032_collection_listed.py [new file with mode: 0644]
src/catalogue/models/collection.py
src/catalogue/views.py
src/wolnelektury/views.py

index adc2eaf..997dd5e 100644 (file)
@@ -43,6 +43,7 @@ class FragmentAdmin(admin.ModelAdmin):
 
 
 class CollectionAdmin(admin.ModelAdmin):
+    list_display = ('title', 'listed')
     prepopulated_fields = {'slug': ('title',)}
 
 
index bcfe0ad..885df24 100644 (file)
@@ -27,7 +27,7 @@ book_tag_categories = ['author', 'epoch', 'kind', 'genre']
 
 
 class CollectionList(ListAPIView):
-    queryset = Collection.objects.all()
+    queryset = Collection.objects.filter(listed=True)
     serializer_class = serializers.CollectionListSerializer
 
 
index edd1fa1..4ce940f 100644 (file)
Binary files a/src/catalogue/locale/pl/LC_MESSAGES/django.mo and b/src/catalogue/locale/pl/LC_MESSAGES/django.mo differ
index 3dc9832..eb92303 100644 (file)
@@ -5,7 +5,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: WolneLektury\n"
 "Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: 2021-01-27 10:47+0100\n"
+"PO-Revision-Date: 2021-05-05 10:02+0200\n"
 "Last-Translator: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
 "Language-Team: Fundacja Nowoczesna Polska <fundacja@nowoczesnapolska.org."
 "pl>\n"
@@ -195,7 +195,7 @@ msgstr "dodatkowe informacje"
 msgid "print on demand"
 msgstr "druk na żądanie"
 
-#: catalogue/models/book.py:73 catalogue/models/collection.py:22
+#: catalogue/models/book.py:73 catalogue/models/collection.py:23
 msgid "recommended"
 msgstr "polecane"
 
@@ -253,11 +253,11 @@ msgstr "Utwór \"%s\" nie istnieje."
 msgid "Book %s already exists"
 msgstr "Książka %s już istnieje"
 
-#: catalogue/models/book.py:853
+#: catalogue/models/book.py:857
 msgid "This work needs modernisation"
 msgstr "Ten utwór wymaga uwspółcześnienia"
 
-#: catalogue/models/book.py:932 catalogue/models/bookmedia.py:33
+#: catalogue/models/book.py:936 catalogue/models/bookmedia.py:33
 #, python-format
 msgid "%s file"
 msgstr "plik %s"
@@ -299,11 +299,15 @@ msgstr "rodzaj"
 msgid "picture"
 msgstr "obraz"
 
-#: catalogue/models/collection.py:27
+#: catalogue/models/collection.py:20
+msgid "listed"
+msgstr "na liście"
+
+#: catalogue/models/collection.py:28
 msgid "collection"
 msgstr "kolekcja"
 
-#: catalogue/models/collection.py:28
+#: catalogue/models/collection.py:29
 msgid "collections"
 msgstr "kolekcje"
 
@@ -990,9 +994,6 @@ msgstr "Błąd podczas importowania pliku: %r"
 #~ msgid "for advanced usage"
 #~ msgstr "do zadań specjalnych"
 
-#~ msgid "Listen"
-#~ msgstr "Słuchaj"
-
 #~ msgid "See"
 #~ msgstr "Zobacz"
 
diff --git a/src/catalogue/migrations/0032_collection_listed.py b/src/catalogue/migrations/0032_collection_listed.py
new file mode 100644 (file)
index 0000000..52c9ccd
--- /dev/null
@@ -0,0 +1,18 @@
+# Generated by Django 2.2.19 on 2021-05-05 07:57
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('catalogue', '0031_auto_20210316_1446'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='collection',
+            name='listed',
+            field=models.BooleanField(db_index=True, default=True, verbose_name='listed'),
+        ),
+    ]
index d964762..6f956c7 100644 (file)
@@ -17,6 +17,7 @@ class Collection(models.Model):
     book_slugs = models.TextField(_('book slugs'))
     kind = models.CharField(_('kind'), max_length=10, blank=False, default='book', db_index=True,
                             choices=(('book', _('book')), ('picture', _('picture'))))
+    listed = models.BooleanField(_('listed'), default=True, db_index=True)
     role = models.CharField(max_length=128, blank=True, db_index=True, choices=[
         ('', '–'),
         ('recommend', _('recommended')),
index 398c61c..904cdc5 100644 (file)
@@ -36,7 +36,7 @@ def catalogue(request):
     return render(request, 'catalogue/catalogue.html', {
         'books': Book.objects.filter(findable=True, parent=None),
         'pictures': Picture.objects.all(),
-        'collections': Collection.objects.all(),
+        'collections': Collection.objects.filter(listed=True),
         'active_menu_item': 'all_works',
     })
 
@@ -452,7 +452,7 @@ def tag_catalogue(request, category):
 
 
 def collections(request):
-    objects = Collection.objects.all()
+    objects = Collection.objects.filter(listed=True)
 
     if len(objects) > 3:
         best = random.sample(list(objects), 3)
index 1c0f40c..48063d2 100644 (file)
@@ -48,13 +48,13 @@ def main_page(request):
 
     # Choose a collection for main.
     try:
-        ctx['collection'] = Collection.objects.order_by('?')[:1][0]
+        ctx['collection'] = Collection.objects.filter(listed=True).order_by('?')[:1][0]
     except IndexError:
         pass
 
     best = []
     best_places = 5
-    for recommended in Collection.objects.filter(role='recommend').order_by('?'):
+    for recommended in Collection.objects.filter(listed=True, role='recommend').order_by('?'):
         books = list(recommended.get_books().exclude(id__in=[b.id for b in best]).order_by('?')[:best_places])
         best.extend(books)
         best_places -= len(books)