Collections pages.
authorRadek Czajka <rczajka@rczajka.pl>
Fri, 28 Oct 2022 13:29:48 +0000 (15:29 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Fri, 28 Oct 2022 13:29:48 +0000 (15:29 +0200)
src/catalogue/migrations/0040_alter_collection_description.py [new file with mode: 0644]
src/catalogue/migrations/0041_alter_collection_authors.py [new file with mode: 0644]
src/catalogue/models/collection.py
src/catalogue/templates/catalogue/2022/author_detail.html
src/catalogue/templates/catalogue/2022/collection.html [new file with mode: 0644]
src/catalogue/templates/catalogue/2022/collections.html [new file with mode: 0644]
src/catalogue/views.py
src/social/migrations/0015_alter_carousel_placement.py [new file with mode: 0644]
src/wolnelektury/static/2021/scripts/main.js

diff --git a/src/catalogue/migrations/0040_alter_collection_description.py b/src/catalogue/migrations/0040_alter_collection_description.py
new file mode 100644 (file)
index 0000000..eb47756
--- /dev/null
@@ -0,0 +1,19 @@
+# Generated by Django 4.0.8 on 2022-10-28 13:03
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('catalogue', '0039_collection_authors'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='collection',
+            name='description',
+            field=models.TextField(blank=True, default='', verbose_name='description'),
+            preserve_default=False,
+        ),
+    ]
diff --git a/src/catalogue/migrations/0041_alter_collection_authors.py b/src/catalogue/migrations/0041_alter_collection_authors.py
new file mode 100644 (file)
index 0000000..2feb345
--- /dev/null
@@ -0,0 +1,18 @@
+# Generated by Django 4.0.8 on 2022-10-28 13:06
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('catalogue', '0040_alter_collection_description'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='collection',
+            name='authors',
+            field=models.ManyToManyField(blank=True, limit_choices_to={'category': 'author'}, to='catalogue.tag'),
+        ),
+    ]
index 75c56ea..412a976 100644 (file)
@@ -13,11 +13,12 @@ class Collection(models.Model):
     """A collection of books, which might be defined before publishing them."""
     title = models.CharField(_('title'), max_length=120, db_index=True)
     slug = models.SlugField(_('slug'), max_length=120, primary_key=True)
-    description = models.TextField(_('description'), null=True, blank=True)
+    description = models.TextField(_('description'), blank=True)
     book_slugs = models.TextField(_('book slugs'))
     authors = models.ManyToManyField(
         'Tag',
-        limit_choices_to={'category': 'author'}
+        limit_choices_to={'category': 'author'},
+        blank=True
     )
     kind = models.CharField(_('kind'), max_length=10, blank=False, default='book', db_index=True,
                             choices=(('book', _('book')), ('picture', _('picture'))))
index d32c012..17514ed 100644 (file)
@@ -2,17 +2,13 @@
 
 {% load choose_cites from social_tags %}
 
-{% block global-content %}
-  <div class="l-container">
-    <div class="l-breadcrumb">
-      <a href="/"><span>Strona główna</span></a>
-      <a href="/katalog/"><span>Katalog</span></a>
-      <a href="/katalog/autor/"><span>Autor</span></a>
-    </div>
-  </div>
 
-  <main class="l-main">
+{% block breadcrumbs %}
+  <a href="/katalog/"><span>Katalog</span></a>
+  <a href="/katalog/autor/"><span>Autor</span></a>
+{% endblock %}
 
+{% block main %}
     <div class="l-section">
       <div class="l-author__header">
         {% if tags.0.photo %}
@@ -72,5 +68,4 @@
         {% endif %}
       </div>
     </section>
-  </main>
 {% endblock %}
diff --git a/src/catalogue/templates/catalogue/2022/collection.html b/src/catalogue/templates/catalogue/2022/collection.html
new file mode 100644 (file)
index 0000000..38c52d8
--- /dev/null
@@ -0,0 +1,50 @@
+{% extends '2022/base.html' %}
+
+
+{% block breadcrumbs %}
+  <a href="/katalog/"><span>Katalog</span></a>
+  <a href="/katalog/kolekcje/"><span>Kolekcje</span></a>
+{% endblock %}
+
+
+{% block main %}
+
+  <div class="l-section">
+    <div class="l-author__header">
+      <h1>{{ collection.title }}</h1>
+    </div>
+  </div>
+
+  <div class="l-author__info">
+    <p>
+      {{ collection.description|safe }}
+    </p>
+  </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">
+      </div>
+      <div class="l-books__sorting">
+        <span>Sortuj:</span>
+        <div>
+          <button data-order="data-pop">najpopularniejsze</button>
+          <button class="is-active">alfabetycznie</button>
+          <!--button>chronologicznie</button-->
+        </div>
+      </div>
+    </div>
+  </div>
+
+  <div class="l-section l-section--col">
+    <div class="l-books__grid" id="book-list">
+      {% for book in collection.get_books %}
+        {% include "catalogue/2022/book_box.html" %}
+      {% endfor %}
+    </div>
+  </div>
+
+
+{% endblock %}
diff --git a/src/catalogue/templates/catalogue/2022/collections.html b/src/catalogue/templates/catalogue/2022/collections.html
new file mode 100644 (file)
index 0000000..ba25bcb
--- /dev/null
@@ -0,0 +1,38 @@
+{% extends '2022/base.html' %}
+
+
+{% block breadcrumbs %}
+  <a href="/katalog/"><span>Katalog</span></a>
+{% endblock %}
+
+
+{% block main %}
+
+  <div class="l-section">
+    <div class="l-author__header">
+      <h1>Kolekcje</h1>
+    </div>
+  </div>
+
+  {% for collection in objects %}
+    <section class="l-section">
+      <div class="l-collections js-collections">
+        <div class="l-collections__header">
+          <h3><a href="{{ collection.get_absolute_url }}">{{ collection.title }}</a></h3>
+        </div>
+          <div class="l-author__info">
+            <p>
+              {{ collection.description|safe }}
+            </p>
+          </div>
+        <div class="l-books">
+          {% for book in collection.get_books %}
+            {% include 'catalogue/2022/book_box.html' %}
+          {% endfor %}
+        </div>
+      </div>
+    </section>
+  {% endfor %}
+
+
+{% endblock %}
index 12f47a2..b57ba11 100644 (file)
@@ -67,7 +67,11 @@ def daisy_list(request):
 
 def collection(request, slug):
     coll = get_object_or_404(Collection, slug=slug)
-    return render(request, 'catalogue/collection.html', {
+    if request.EXPERIMENTS['layout'].value:
+        template_name = 'catalogue/2022/collection.html'
+    else:
+        template_name = 'catalogue/collection.html'
+    return render(request, template_name, {
         'collection': coll,
         'active_menu_item': 'collections',
     })
@@ -480,7 +484,12 @@ def collections(request):
     else:
         best = objects
 
-    return render(request, 'catalogue/collections.html', {
+    if request.EXPERIMENTS['layout'].value:
+        template_name = 'catalogue/2022/collections.html'
+    else:
+        template_name = 'catalogue/collections.html'
+
+    return render(request, template_name, {
         'objects': objects,
         'best': best,
         'active_menu_item': 'collections'
diff --git a/src/social/migrations/0015_alter_carousel_placement.py b/src/social/migrations/0015_alter_carousel_placement.py
new file mode 100644 (file)
index 0000000..bce2dac
--- /dev/null
@@ -0,0 +1,18 @@
+# Generated by Django 4.0.8 on 2022-10-28 13:03
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('social', '0014_auto_20221014_1004'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='carousel',
+            name='placement',
+            field=models.SlugField(choices=[('main', 'main'), ('main_2022', 'main 2022')], verbose_name='placement'),
+        ),
+    ]
index 97ac9a3..21c76a0 100644 (file)
     shelfSlider.slick('slickPrev');
   });
 
-  let collectionsSlider = $('.js-collections .l-books');
-  let collectionsNextSlide = $('.js-collections .js-next-slide');
-  let collectionsPrevSlide = $('.js-collections .js-prev-slide');
+
+    $('.js-collections').each(function() {
+        let collectionsSlider = $('.l-books', this);
+        if ($collectionsSlider.children().length < 2) return;
+        let collectionsNextSlide = $('.js-next-slide', this);
+        let collectionsPrevSlide = $('.js-prev-slide', this);
 
   collectionsSlider.slick({
     slidesToScroll: 1,
     event.preventDefault();
     collectionsSlider.slick('slickPrev');
   });
-
+    });
   let newBooksSlider = $('.js-new-books-slider .l-books');
   let newBooksNextSlide = $('.js-new-books-slider .js-next-slide');
   let newBooksPrevSlide = $('.js-new-books-slider .js-prev-slide');