Book with donation.
authorRadek Czajka <rczajka@rczajka.pl>
Fri, 25 Nov 2022 15:15:08 +0000 (16:15 +0100)
committerRadek Czajka <rczajka@rczajka.pl>
Fri, 25 Nov 2022 15:15:08 +0000 (16:15 +0100)
src/catalogue/templates/catalogue/2022/book_detail.html
src/catalogue/views.py
src/club/templates/club/2022/donation_step1.html
src/club/templates/club/2022/donation_step1_form.html [new file with mode: 0644]

index d705728..e1f0d63 100644 (file)
         {% with first_text=book.get_first_text %}
           <aside class="l-aside">
             <figure>
-              {% if first_text %}
+              {% if accessible and first_text %}
                 <a href="{% url 'book_text' first_text.slug %}">
               {% endif %}
               <img src="{% if book.cover_clean %}{{ book.cover_clean.url }}{% endif %}" alt="{{ book.pretty_title }}" width="240">
-              {% if first_text %}
+              {% if accessible and first_text %}
                 </a>
               {% endif %}
             </figure>
               </div>
             </header>
             <article class="l-article">
+              {% if accessible %}
               <div class="c-media">
                 <div class="c-media__actions">
                   <div class="c-media__btn">
                   </div>
                 {% endif %}
               </div>
+              {% else %}
+              <div class="l-checkout__box">
+                {% include 'club/2022/donation_step1_form.html' %}
+              </div>
+              {% endif %}
 
               <div class="l-article__overlay" data-max-height="327">
                 {{ book.abstract|safe }}
               </div>
               <button class="l-article__read-more" aria-label="Kliknij aby rozwinąć" data-label="Czytaj więcej" data-action="Zwiń tekst">Czytaj więcej</button>
             </article>
+            {% if accessible %}
             <div class="c-support">
               <div>
                 <h2>Ta książka jest dostępna dla tysięcy dzieciaków dzięki <span>darowiznom</span> od osób takich jak <span>Ty</span>!</h2>
                 <img src="{% static '2022/images/dziecko.jpeg' %}" alt="Dorzuć się!">
               </figure>
             </div>
+            {% endif %}
           </div>
         {% endwith %}
       </section>
index 2955a5c..d1fc0c9 100644 (file)
@@ -18,7 +18,7 @@ from django.utils.translation import gettext as _, gettext_lazy
 from django.views.decorators.cache import never_cache
 
 from ajaxable.utils import AjaxableFormView
-from club.forms import ScheduleForm
+from club.forms import ScheduleForm, DonationStep1Form
 from club.models import Club
 from annoy.models import DynamicTextInsert
 from pdcounter import views as pdcounter_views
@@ -305,19 +305,18 @@ def book_detail(request, slug):
         return pdcounter_views.book_stub_detail(request, slug)
 
     new_layout = request.EXPERIMENTS['layout']
-    # Not for preview books.
-    if new_layout.value and not book.is_accessible_to(request.user):
-        new_layout.override(None)
     
     return render(
         request,
         'catalogue/2022/book_detail.html' if new_layout.value else 'catalogue/book_detail.html',
         {
             'book': book,
+            'accessible': book.is_accessible_to(request.user),
             'book_children': book.children.all().order_by('parent_number', 'sort_key'),
             'active_menu_item': 'books',
             'club_form': ScheduleForm() if book.preview else None,
             'club': Club.objects.first() if book.preview else None,
+            'donation_form': DonationStep1Form(),
 
             'EXPERIMENTS_SWITCHABLE_layout': True,
         })
index 2f28d06..a59abd6 100644 (file)
@@ -4,139 +4,5 @@
 
 
 {% block donation-step-content %}
-  <form method="post">
-    {% csrf_token %}
-    {{ form.errors }}
-    <input type="radio" name="switch" id="switch-once" value="single" class="toggle-input" {% if schedule and not schedule.monthly %}checked{% endif %}>
-    <input type="radio" name="switch" id="switch-monthly" value="monthly" class="toggle-input" {% if not schedule or schedule.monthly %}checked{% endif %}>
-    <div class="l-switch__wrapper">
-      {% if user.is_staff %}
-        <span data-edit="club/club/{{ club.pk }}"></span>
-      {% endif %}
-
-      <div class="l-switch white">
-        <label class='toggle-for' for="switch-once">Jednorazowo</label>
-        <label class='toggle-for' for="switch-monthly">Miesięcznie</label>
-        <span class="toggle"></span>
-          </div>
-        </div>
-
-        <div class="l-checkout__payments payments-once">
-          {% for amount in club.singleamount_set.all %}
-            <div class="l-checkout__payments__box once{% if not schedule.monthly and schedule.amount == amount.amount or not schedule and club.default_single_amount == amount.amount %} is-active{% endif %}{% if forloop.last %} l-checkout__payments__box--xl{% endif %}">
-              <div>
-                <h3>{{ amount.amount }} zł</h3>
-                <div class="l-checkout__payments__box__btn-wrp">
-                  <button name="single_amount" value="{{ amount.amount }}">Wybierz</button>
-                </div>
-              </div>
-              {% if amount.description %}
-                <div>
-                  <p>{{ amount.description|safe }}</p>
-                </div>
-              {% endif %}
-            </div>
-          {% endfor %}
-          <input type="hidden"
-                 name="single_amount_selected"
-                 value="{% if schedule and not schedule.monthly %}{{ schedule.amount|floatformat }}{% else %}{{ club.default_single_amount }}{% endif %}">
-
-        </div>
-
-
-        <div class="l-checkout__payments payments-recurring">
-          {% for amount in club.monthlyamount_set.all %}
-            <div class="l-checkout__payments__box{% if schedule.monthly and schedule.amount == amount.amount or not schedule and amount.amount == club.default_monthly_amount %} is-active{% endif %}">
-              <h3>{{ amount.amount }} zł <span>/mies.</span></h3>
-              <div class="l-checkout__payments__box__btn-wrp">
-                <p>{{ amount.description|safe }}</p>
-                <button name="monthly_amount" value="{{ amount.amount }}">Wybierz</button>
-              </div>
-            </div>
-          {% endfor %}
-          <input type="hidden"
-                 name="monthly_amount_selected"
-                 value="{% if schedule and schedule.monthly %}{{ schedule.amount|floatformat }}{% else %}{{ club.default_monthly_amount }}{% endif %}">
-        </div>
-
-        <div class="l-checkout__amount">
-          <div class="l-checkout__input">
-            <label for="kwota">Inna kwota</label>
-            <!-- input type="text" id="kwota" name="custom_amount" value="" -->
-            {{ form.custom_amount }}
-          </div>
-          <button>Dalej</button>
-        </div>
-      </form>
-
-      <img src="{% static '2022/images/checkout-footer.png' %}" alt="Bezpieczne płatności zapewniają" class="l-checkout__footer__img">
-      <div class="l-checkout__cols bt-w">
-        <div class="l-checkout__col full">
-          <div class="l-checkout__form">
-            <div class="l-checkout__form__row full">
-              <h3>Dane do przelewu tradycyjnego:</h3>
-              <div class="l-checkout__info">
-                <div class="l-checkout__info__item">
-                  <div>nazwa odbiorcy</div>
-                  <h3>Fundacja Nowoczesna Polska</h3>
-                  <button title="Kopiuj tekst" class="js-copy">
-                    <img src="{% static '2022/images/copy.svg' %}" alt="Kopiuj">
-                  </button>
-                  <input type="text" value="Fundacja Nowoczesna Polska">
-                </div>
-                <div class="l-checkout__info__item">
-                  <div>adres odbiorcy</div>
-                  <h3>ul. Marszałkowska 84/92 lok. 125, 00-514 Warszawa</h3>
-                  <button title="Kopiuj tekst" class="js-copy">
-                    <img src="{% static '2022/images/copy.svg' %}" alt="Kopiuj">
-                  </button>
-                  <input type="text" value="ul. Marszałkowska 84/92 lok. 125, 00-514 Warszawa">
-                </div>
-                <div class="l-checkout__info__item">
-                  <div>numer konta</div>
-                  <h3>75 1090 2851 0000 0001 4324 3317</h3>
-                  <button title="Kopiuj tekst" class="js-copy">
-                    <img src="{% static '2022/images/copy.svg' %}" alt="Kopiuj">
-                  </button>
-                  <input type="text" value="75 1090 2851 0000 0001 4324 3317">
-                </div>
-                <div class="l-checkout__info__item">
-                  <div>tytuł przelewu</div>
-                  <h3>Darowizna na Wolne Lektury + twoja nazwa użytkownika lub e-mail</h3>
-                  <button title="Kopiuj tekst" class="js-copy">
-                    <img src="{% static '2022/images/copy.svg' %}" alt="Kopiuj">
-                  </button>
-                  <input type="text" value="Darowizna na Wolne Lektury + twoja nazwa użytkownika lub e-mail">
-                </div>
-                <div class="l-checkout__info__item">
-                  <div>wpłaty w EUR</div>
-                  <h3>PL88 1090 2851 0000 0001 4324 3374</h3>
-                  <button title="Kopiuj tekst" class="js-copy">
-                    <img src="{% static '2022/images/copy.svg' %}" alt="Kopiuj">
-                  </button>
-                  <input type="text" value="PL88 1090 2851 0000 0001 4324 3374">
-                </div>
-                <div class="l-checkout__info__item">
-                  <div>Wpłaty w USD</div>
-                  <h3>PL82 1090 2851 0000 0001 4324 3385</h3>
-                  <button title="Kopiuj tekst" class="js-copy">
-                    <img src="{% static '2022/images/copy.svg' %}" alt="Kopiuj">
-                  </button>
-                  <input type="text" value="PL88 1090 2851 0000 0001 4324 3374">
-                </div>
-                <div class="l-checkout__info__item">
-                  <div>SWIFT</div>
-                  <h3>WBKPPLPP</h3>
-                  <button title="Kopiuj tekst" class="js-copy">
-                    <img src="{% static '2022/images/copy.svg' %}" alt="Kopiuj">
-                  </button>
-                  <input type="text" value="WBKPPLPP">
-                </div>
-              </div>
-            </div>
-          </div>
-        </div>
-      </div>
-    </div>
-
+  {% include "club/2022/donation_step1_form.html" %}
 {% endblock %}
diff --git a/src/club/templates/club/2022/donation_step1_form.html b/src/club/templates/club/2022/donation_step1_form.html
new file mode 100644 (file)
index 0000000..bd45826
--- /dev/null
@@ -0,0 +1,135 @@
+{% load static %}
+
+<form method="post" action="{% url 'club_join' %}">
+  {% csrf_token %}
+  {{ form.errors }}
+  <input type="radio" name="switch" id="switch-once" value="single" class="toggle-input" {% if schedule and not schedule.monthly %}checked{% endif %}>
+  <input type="radio" name="switch" id="switch-monthly" value="monthly" class="toggle-input" {% if not schedule or schedule.monthly %}checked{% endif %}>
+  <div class="l-switch__wrapper">
+    {% if user.is_staff %}
+      <span data-edit="club/club/{{ club.pk }}"></span>
+    {% endif %}
+
+    <div class="l-switch white">
+      <label class='toggle-for' for="switch-once">Jednorazowo</label>
+      <label class='toggle-for' for="switch-monthly">Miesięcznie</label>
+      <span class="toggle"></span>
+    </div>
+  </div>
+
+  <div class="l-checkout__payments payments-once">
+    {% for amount in club.singleamount_set.all %}
+      <div class="l-checkout__payments__box once{% if not schedule.monthly and schedule.amount == amount.amount or not schedule and club.default_single_amount == amount.amount %} is-active{% endif %}{% if forloop.last %} l-checkout__payments__box--xl{% endif %}">
+        <div>
+          <h3>{{ amount.amount }} zł</h3>
+          <div class="l-checkout__payments__box__btn-wrp">
+            <button name="single_amount" value="{{ amount.amount }}">Wybierz</button>
+          </div>
+        </div>
+        {% if amount.description %}
+          <div>
+            <p>{{ amount.description|safe }}</p>
+          </div>
+        {% endif %}
+      </div>
+    {% endfor %}
+    <input type="hidden"
+           name="single_amount_selected"
+           value="{% if schedule and not schedule.monthly %}{{ schedule.amount|floatformat }}{% else %}{{ club.default_single_amount }}{% endif %}">
+
+  </div>
+
+
+  <div class="l-checkout__payments payments-recurring">
+    {% for amount in club.monthlyamount_set.all %}
+      <div class="l-checkout__payments__box{% if schedule.monthly and schedule.amount == amount.amount or not schedule and amount.amount == club.default_monthly_amount %} is-active{% endif %}">
+        <h3>{{ amount.amount }} zł <span>/mies.</span></h3>
+        <div class="l-checkout__payments__box__btn-wrp">
+          <p>{{ amount.description|safe }}</p>
+          <button name="monthly_amount" value="{{ amount.amount }}">Wybierz</button>
+        </div>
+      </div>
+    {% endfor %}
+    <input type="hidden"
+           name="monthly_amount_selected"
+           value="{% if schedule and schedule.monthly %}{{ schedule.amount|floatformat }}{% else %}{{ club.default_monthly_amount }}{% endif %}">
+  </div>
+
+  <div class="l-checkout__amount">
+    <div class="l-checkout__input">
+      <label for="kwota">Inna kwota</label>
+      <!-- input type="text" id="kwota" name="custom_amount" value="" -->
+      {{ form.custom_amount }}
+    </div>
+    <button>Dalej</button>
+  </div>
+</form>
+
+<img src="{% static '2022/images/checkout-footer.png' %}" alt="Bezpieczne płatności zapewniają" class="l-checkout__footer__img">
+<div class="l-checkout__cols bt-w">
+  <div class="l-checkout__col full">
+    <div class="l-checkout__form">
+      <div class="l-checkout__form__row full">
+        <h3>Dane do przelewu tradycyjnego:</h3>
+        <div class="l-checkout__info">
+          <div class="l-checkout__info__item">
+            <div>nazwa odbiorcy</div>
+            <h3>Fundacja Nowoczesna Polska</h3>
+            <button title="Kopiuj tekst" class="js-copy">
+              <img src="{% static '2022/images/copy.svg' %}" alt="Kopiuj">
+            </button>
+            <input type="text" value="Fundacja Nowoczesna Polska">
+          </div>
+          <div class="l-checkout__info__item">
+            <div>adres odbiorcy</div>
+            <h3>ul. Marszałkowska 84/92 lok. 125, 00-514 Warszawa</h3>
+            <button title="Kopiuj tekst" class="js-copy">
+              <img src="{% static '2022/images/copy.svg' %}" alt="Kopiuj">
+            </button>
+            <input type="text" value="ul. Marszałkowska 84/92 lok. 125, 00-514 Warszawa">
+          </div>
+          <div class="l-checkout__info__item">
+            <div>numer konta</div>
+            <h3>75 1090 2851 0000 0001 4324 3317</h3>
+            <button title="Kopiuj tekst" class="js-copy">
+              <img src="{% static '2022/images/copy.svg' %}" alt="Kopiuj">
+            </button>
+            <input type="text" value="75 1090 2851 0000 0001 4324 3317">
+          </div>
+          <div class="l-checkout__info__item">
+            <div>tytuł przelewu</div>
+            <h3>Darowizna na Wolne Lektury + twoja nazwa użytkownika lub e-mail</h3>
+            <button title="Kopiuj tekst" class="js-copy">
+              <img src="{% static '2022/images/copy.svg' %}" alt="Kopiuj">
+            </button>
+            <input type="text" value="Darowizna na Wolne Lektury + twoja nazwa użytkownika lub e-mail">
+          </div>
+          <div class="l-checkout__info__item">
+            <div>wpłaty w EUR</div>
+            <h3>PL88 1090 2851 0000 0001 4324 3374</h3>
+            <button title="Kopiuj tekst" class="js-copy">
+              <img src="{% static '2022/images/copy.svg' %}" alt="Kopiuj">
+            </button>
+            <input type="text" value="PL88 1090 2851 0000 0001 4324 3374">
+          </div>
+          <div class="l-checkout__info__item">
+            <div>Wpłaty w USD</div>
+            <h3>PL82 1090 2851 0000 0001 4324 3385</h3>
+            <button title="Kopiuj tekst" class="js-copy">
+              <img src="{% static '2022/images/copy.svg' %}" alt="Kopiuj">
+            </button>
+            <input type="text" value="PL88 1090 2851 0000 0001 4324 3374">
+          </div>
+          <div class="l-checkout__info__item">
+            <div>SWIFT</div>
+            <h3>WBKPPLPP</h3>
+            <button title="Kopiuj tekst" class="js-copy">
+              <img src="{% static '2022/images/copy.svg' %}" alt="Kopiuj">
+            </button>
+            <input type="text" value="WBKPPLPP">
+          </div>
+        </div>
+      </div>
+    </div>
+  </div>
+</div>