From af339a5c1a69ec22a6f1d5940cde313953948368 Mon Sep 17 00:00:00 2001 From: Radek Czajka <rczajka@rczajka.pl> Date: Fri, 25 Nov 2022 16:15:08 +0100 Subject: [PATCH] Book with donation. --- .../templates/catalogue/2022/book_detail.html | 12 +- src/catalogue/views.py | 7 +- .../templates/club/2022/donation_step1.html | 136 +----------------- .../club/2022/donation_step1_form.html | 135 +++++++++++++++++ 4 files changed, 149 insertions(+), 141 deletions(-) create mode 100644 src/club/templates/club/2022/donation_step1_form.html diff --git a/src/catalogue/templates/catalogue/2022/book_detail.html b/src/catalogue/templates/catalogue/2022/book_detail.html index d70572889..e1f0d6318 100644 --- a/src/catalogue/templates/catalogue/2022/book_detail.html +++ b/src/catalogue/templates/catalogue/2022/book_detail.html @@ -23,11 +23,11 @@ {% 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> @@ -118,6 +118,7 @@ </div> </header> <article class="l-article"> + {% if accessible %} <div class="c-media"> <div class="c-media__actions"> <div class="c-media__btn"> @@ -282,6 +283,11 @@ </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 }} @@ -295,6 +301,7 @@ </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> @@ -304,6 +311,7 @@ <img src="{% static '2022/images/dziecko.jpeg' %}" alt="DorzuÄ siÄ!"> </figure> </div> + {% endif %} </div> {% endwith %} </section> diff --git a/src/catalogue/views.py b/src/catalogue/views.py index 2955a5ce0..d1fc0c9cd 100644 --- a/src/catalogue/views.py +++ b/src/catalogue/views.py @@ -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, }) diff --git a/src/club/templates/club/2022/donation_step1.html b/src/club/templates/club/2022/donation_step1.html index 2f28d069d..a59abd6a3 100644 --- a/src/club/templates/club/2022/donation_step1.html +++ b/src/club/templates/club/2022/donation_step1.html @@ -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 index 000000000..bd4582645 --- /dev/null +++ b/src/club/templates/club/2022/donation_step1_form.html @@ -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> -- 2.20.1