class CollectionAdmin(admin.ModelAdmin):
+ list_display = ('title', 'listed')
prepopulated_fields = {'slug': ('title',)}
class CollectionList(ListAPIView):
- queryset = Collection.objects.all()
+ queryset = Collection.objects.filter(listed=True)
serializer_class = serializers.CollectionListSerializer
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"
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"
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"
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"
#~ msgid "for advanced usage"
#~ msgstr "do zadań specjalnych"
-#~ msgid "Listen"
-#~ msgstr "Słuchaj"
-
#~ msgid "See"
#~ msgstr "Zobacz"
--- /dev/null
+# 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'),
+ ),
+ ]
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')),
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',
})
def collections(request):
- objects = Collection.objects.all()
+ objects = Collection.objects.filter(listed=True)
if len(objects) > 3:
best = random.sample(list(objects), 3)
# 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)