Theme page.
authorRadek Czajka <rczajka@rczajka.pl>
Mon, 5 Jun 2023 13:02:35 +0000 (15:02 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Mon, 5 Jun 2023 13:02:35 +0000 (15:02 +0200)
src/catalogue/templates/catalogue/2022/author_detail.html
src/catalogue/templates/catalogue/2022/theme_detail.html
src/catalogue/views.py

index 120fec4..9596852 100644 (file)
@@ -7,21 +7,21 @@
 {% block breadcrumbs %}
   <a href="/katalog/"><span>Katalog</span></a>
   {% if tags %}
 {% block breadcrumbs %}
   <a href="/katalog/"><span>Katalog</span></a>
   {% if tags %}
-    <a href="{{ tags.0.get_absolute_catalogue_url }}"><span>{{ tags.0.get_category_display|title }}</span></a>
+    <a href="{{ main_tag.get_absolute_catalogue_url }}"><span>{{ main_tag.get_category_display|title }}</span></a>
   {% endif %}
 {% endblock %}
 
 {% block main %}
   <div class="l-section">
     <div class="l-author__header">
   {% endif %}
 {% endblock %}
 
 {% block main %}
   <div class="l-section">
     <div class="l-author__header">
-      {% if tags.0.photo %}
+      {% if main_tag.photo %}
         <figure>
         <figure>
-          <img src="{{ tags.0.photo.url }}" alt="{{ tags.0.name }}">
+          <img src="{{ main_tag.photo.url }}" alt="{{ main_tag.name }}">
         </figure>
       {% endif %}
       <h1>
         </figure>
       {% endif %}
       <h1>
-        {% if tags %}
-          {{ tags.0.name }}
+        {% if main_tag %}
+          {{ main_tag.name }}
         {% else %}
           {{ title }}
         {% endif %}
         {% else %}
           {{ title }}
         {% endif %}
@@ -36,7 +36,7 @@
         <input type="text" placeholder="filtry, tytuł" class="quick-filter" data-for="book-list" data-filters="with-filter">
         <div class="filter-container">
           {% for tag in tags %}
         <input type="text" placeholder="filtry, tytuł" class="quick-filter" data-for="book-list" data-filters="with-filter">
         <div class="filter-container">
           {% for tag in tags %}
-            {% if forloop.counter > 1 %}
+            {% if tag is not main_tag %}
               <span class="filter filter-category-{{ tag.category }}">
                 <a href="{% catalogue_url list_type tag %}">{{ tag }}</a>
                 <a href="{% catalogue_url list_type tags -tag %}">✖</a>
               <span class="filter filter-category-{{ tag.category }}">
                 <a href="{% catalogue_url list_type tag %}">{{ tag }}</a>
                 <a href="{% catalogue_url list_type tags -tag %}">✖</a>
@@ -45,7 +45,6 @@
           {% endfor %}
         </div>
 
           {% endfor %}
         </div>
 
-  </span>
       </div>
       <div class="l-books__sorting">
         <span>Sortuj:</span>
       </div>
       <div class="l-books__sorting">
         <span>Sortuj:</span>
   {% if tags %}
     <section class="l-section">
       <div class="l-author">
   {% if tags %}
     <section class="l-section">
       <div class="l-author">
-        {% with tag=tags.0 %}
+        {% with tag=main_tag %}
           {% include 'catalogue/2022/author_box.html' %}
         {% endwith %}
           {% include 'catalogue/2022/author_box.html' %}
         {% endwith %}
-        {% choose_cites 3 author=tags.0 as cites %}
+        {% choose_cites 3 author=main_tag as cites %}
         {% if cites %}
           <div class="row">
             <div class="l-author__quotes">
         {% if cites %}
           <div class="row">
             <div class="l-author__quotes">
index 29b0eeb..b4db65d 100644 (file)
@@ -1,4 +1,5 @@
 {% extends '2022/base.html' %}
 {% extends '2022/base.html' %}
+{% load catalogue_tags %}
 {% load pagination_tags %}
 
 {% block global-content %}
 {% load pagination_tags %}
 
 {% block global-content %}
@@ -7,7 +8,7 @@
       <a href="/"><span>Strona główna</span></a>
       <a href="/katalog/"><span>Katalog</span></a>
       <a href="/katalog/motyw/"><span>Motyw</span></a>
       <a href="/"><span>Strona główna</span></a>
       <a href="/katalog/"><span>Katalog</span></a>
       <a href="/katalog/motyw/"><span>Motyw</span></a>
-      <span>{{ tags.0.name }}</span>
+      <span>{{ main_tag.name }}</span>
     </div>
   </div>
 
     </div>
   </div>
 
 
     <div class="l-section">
       <div class="l-author__header">
 
     <div class="l-section">
       <div class="l-author__header">
-        <h1><span>Motyw:</span> {{ tags.0.name }}</h1>
+        <h1><span>Motyw:</span> {{ main_tag.name }}</h1>
       </div>
     </div>
 
       </div>
     </div>
 
-    <!-- div class="l-section">
-         <div class="l-books__header">
-         <div class="l-books__input">
-         <i class="icon icon-filter"></i>
-         <input type="text" placeholder="filtry, tytuł">
-         </div>
-         <div class="l-books__sorting">
-         <span>Sortuj:</span>
-         <div>
-         <button>autorzy</button>
-         <button>epoki</button>
-         <button>gatunki</button>
-         <button>rodzaje</button>
-         <button class="is-active">motywy</button>
-         </div>
-         </div>
-         </div>
-         </div -->
+
+    <div class="l-section">
+      <div class="l-books__header">
+        <div class="l-books__input">
+          <i class="icon icon-filter"></i>
+          <input type="text" placeholder="filtry, tytuł" class="quick-filter" data-for="book-list" data-filters="with-filter">
+          <div class="filter-container">
+            {% for tag in tags %}
+              {% if tag is not main_tag %}
+                <span class="filter filter-category-{{ tag.category }}">
+                  <a href="{% catalogue_url list_type tag %}">{{ tag }}</a>
+                  <a href="{% catalogue_url list_type tags -tag %}">✖</a>
+                </span>
+              {% endif %}
+            {% endfor %}
+          </div>
+
+        </div>
+      </div>
+    </div>
+    <div class="l-author with-filter">
+      <div class="row">
+        <h2>{% nice_title_from_tags tags categories %}</h2>
+        {% if suggest %}
+          <div class="filter-container">
+            {% for tag in suggest %}
+              <span class="filter filter-category-{{ tag.category }}">
+                <a href="{% catalogue_url list_type tags tag %}">{{ tag }}</a>
+              </span>
+            {% endfor %}
+          </div>
+        {% endif %}
+      </div>
+    </div>
 
     {% autopaginate object_list 10 %}
 
 
     {% autopaginate object_list 10 %}
 
@@ -53,8 +70,8 @@
         </div>
         <div class="l-theme__col">
           <div class="l-theme__info">
         </div>
         <div class="l-theme__col">
           <div class="l-theme__info">
-            <h3>Motyw: {{ tags.0.name }}</h3>
-            {{ tags.0.description|safe }}
+            <h3>Motyw: {{ main_tag.name }}</h3>
+            {{ main_tag.description|safe }}
             <!--
                  <h3>Motyw w sztuce <i class="icon icon-arrow-left"></i> <i class="icon icon-arrow-right"></i></h3>
                  <div class="l-theme__info__slider">
             <!--
                  <h3>Motyw w sztuce <i class="icon icon-arrow-left"></i> <i class="icon icon-arrow-right"></i></h3>
                  <div class="l-theme__info__slider">
index b4e5920..b52d7b9 100644 (file)
@@ -154,6 +154,7 @@ def object_list(request, objects, fragments=None, related_tags=None, tags=None,
         'suggest': suggest,
         'list_type': list_type,
         'tags': tags,
         'suggest': suggest,
         'list_type': list_type,
         'tags': tags,
+        'main_tag': tags[0],
 
         'formats_form': forms.DownloadFormatsForm(),
         'best': best,
 
         'formats_form': forms.DownloadFormatsForm(),
         'best': best,
@@ -162,14 +163,13 @@ def object_list(request, objects, fragments=None, related_tags=None, tags=None,
     if extra:
         result.update(extra)
 
     if extra:
         result.update(extra)
 
-    is_theme = len(tags) == 1 and tags[0].category == 'theme'
-    has_theme = any((x.category == 'theme' for x in tags))
-    new_layout = request.EXPERIMENTS['layout']
-
-    if is_theme and new_layout.value:
-        template = 'catalogue/2022/theme_detail.html'
-    elif new_layout.value and not has_theme:
-        template = 'catalogue/2022/author_detail.html'
+    if request.EXPERIMENTS['layout'].value:
+        has_theme = any(((theme := x).category == 'theme' for x in tags))
+        if has_theme:
+            result['main_tag'] = theme
+            template = 'catalogue/2022/theme_detail.html'
+        else:
+            template = 'catalogue/2022/author_detail.html'
     else:
         template = 'catalogue/tagged_object_list.html'
         
     else:
         template = 'catalogue/tagged_object_list.html'