From: Radek Czajka Date: Thu, 1 Dec 2022 14:11:36 +0000 (+0100) Subject: Picture page. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/51c43b2690ff814ec4b744c630c0b3f48294dbb0?ds=inline;hp=7784eab91b17a8c74cd79eb15303d09842b2d91c Picture page. --- diff --git a/src/catalogue/templatetags/catalogue_tags.py b/src/catalogue/templatetags/catalogue_tags.py index 718ffd358..6ee177713 100644 --- a/src/catalogue/templatetags/catalogue_tags.py +++ b/src/catalogue/templatetags/catalogue_tags.py @@ -413,12 +413,14 @@ def related_books(context, instance, limit=6, random=1, taken=0): @register.simple_tag -def related_books_2022(instance, limit=4, taken=0): +def related_books_2022(book=None, picture=None, limit=4, taken=0): limit -= taken max_books = limit books_qs = Book.objects.filter(findable=True) - books_qs = books_qs.exclude(common_slug=instance.common_slug).exclude(ancestor=instance) + if book is not None: + books_qs = books_qs.exclude(common_slug=book.common_slug).exclude(ancestor=book) + instance = book or picture books = Book.tagged.related_to(instance, books_qs)[:max_books] return books diff --git a/src/picture/models.py b/src/picture/models.py index 5f5fe4c58..b9ddcae9b 100644 --- a/src/picture/models.py +++ b/src/picture/models.py @@ -136,6 +136,15 @@ class Picture(models.Model): def authors(self): return self.tags.filter(category='author') + def epochs(self): + return self.tags.filter(category='epoch') + + def genres(self): + return self.tags.filter(category='genre') + + def kinds(self): + return self.tags.filter(category='kind') + def tag_unicode(self, category): relations = prefetched_relations(self, category) if relations: diff --git a/src/picture/templates/picture/2022/picture_detail.html b/src/picture/templates/picture/2022/picture_detail.html new file mode 100644 index 000000000..69dbb2594 --- /dev/null +++ b/src/picture/templates/picture/2022/picture_detail.html @@ -0,0 +1,145 @@ +{% extends '2022/base.html' %} + +{% load chunks %} +{% load static %} +{% load thumbnail %} +{% load catalogue_tags %} + + +{% block global-content %} +
+ +
+ + +
+
+ +
+ + +
+
+ + {% for author in picture.authors %} +
+
+ {% include 'catalogue/2022/author_box.html' %} +
+
+ {% endfor %} + +
+
+ {% if themes %} +

Motywy obecne na tym obrazie Wszystkie motywy

+
+ +
+ + + {% endif %} + {% if things %} +

Obiekty na tym obrazie Wszystkie obiekty

+
+ +
+ + + {% endif %} + +
+
+
+ + + + + +
+
+
+

Czytaj także

+
+ {% related_books_2022 picture=picture as related_books %} + {% for rel in related_books %} + + {% endfor %} + + + +
+
+
+
+ + +{% endblock %} diff --git a/src/picture/views.py b/src/picture/views.py index 27f9050fe..e742c1542 100644 --- a/src/picture/views.py +++ b/src/picture/views.py @@ -25,7 +25,12 @@ def picture_detail(request, slug): theme_things = split_tags(picture.related_themes()) - return render(request, "picture/picture_detail.html", { + if request.EXPERIMENTS['layout'].value: + template_name = 'picture/2022/picture_detail.html' + else: + template_name = 'picture/picture_detail.html' + + return render(request, template_name, { 'picture': picture, 'themes': theme_things.get('theme', []), 'things': theme_things.get('thing', []),