From d5a4e2346ceaa436eb64372ad099ebbffd78db2e Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 7 Dec 2020 13:41:57 +0100 Subject: [PATCH] Fixes #4135: Payment form directly on book page. --- .../templates/catalogue/book_short.html | 9 +- .../templates/catalogue/book_wide.html | 23 ++ src/catalogue/views.py | 2 + src/club/static/club/club.scss | 126 +++++++++++ src/club/templates/club/membership_form.html | 206 +----------------- src/club/templates/club/payment_form.html | 64 ++++++ src/club/templates/club/payment_info.html | 13 ++ src/wolnelektury/settings/static.py | 1 + .../static/scss/main/book_box.scss | 1 + 9 files changed, 239 insertions(+), 206 deletions(-) create mode 100644 src/club/static/club/club.scss create mode 100644 src/club/templates/club/payment_form.html create mode 100644 src/club/templates/club/payment_info.html diff --git a/src/catalogue/templates/catalogue/book_short.html b/src/catalogue/templates/catalogue/book_short.html index 0c631791a..4c69492f8 100644 --- a/src/catalogue/templates/catalogue/book_short.html +++ b/src/catalogue/templates/catalogue/book_short.html @@ -147,9 +147,12 @@ {% else %} -

{% trans "For now this work is only available for our subscribers." %} - Dołącz do Towarzystwa Przyjaciół Wolnych Lektur -

+ {% block preview-info %} +

+ {% trans "For now this work is only available for our subscribers." %} + Dołącz do Towarzystwa Przyjaciół Wolnych Lektur +

+ {% endblock %} {% endif %} {% endcache %} {% block book-box-extra-info %}{% endblock %} diff --git a/src/catalogue/templates/catalogue/book_wide.html b/src/catalogue/templates/catalogue/book_wide.html index ffa4bcea1..84eb9ddcb 100644 --- a/src/catalogue/templates/catalogue/book_wide.html +++ b/src/catalogue/templates/catalogue/book_wide.html @@ -2,6 +2,8 @@ {% load i18n %} {% load choose_fragment license_icon from catalogue_tags %} {% load choose_cite from social_tags %} +{% load status from catalogue_tags %} +{% load chunks %} {% block box-class %}book-wide-box{% endblock %} @@ -19,6 +21,16 @@ {% endblock %} +{% block preview-info %} +

+ {% chunk "book-preview-warn" %} +

+ + {% include "club/payment_info.html" %} +{% endblock %} + + + {% block right-column %}
@@ -33,6 +45,17 @@ {% endif %}
{% include 'catalogue/snippets/jplayer.html' %} + + {% if book|status:request.user == 'closed' %} + {% with form=club_form %} +
+ {% csrf_token %} + {% include "club/payment_form.html" %} + {% chunk 'club_form_bottom' %} +
+ {% endwith %} + {% endif %} +
{% endblock %} diff --git a/src/catalogue/views.py b/src/catalogue/views.py index bca75e78f..9a36b7305 100644 --- a/src/catalogue/views.py +++ b/src/catalogue/views.py @@ -17,6 +17,7 @@ from django.utils.translation import ugettext as _, ugettext_lazy from django.views.decorators.cache import never_cache from ajaxable.utils import AjaxableFormView +from club.forms import ScheduleForm from club.models import Membership from annoy.models import DynamicTextInsert from pdcounter import views as pdcounter_views @@ -289,6 +290,7 @@ def book_detail(request, slug): 'book': book, 'book_children': book.children.all().order_by('parent_number', 'sort_key'), 'active_menu_item': 'books', + 'club_form': ScheduleForm() if book.preview else None, }) diff --git a/src/club/static/club/club.scss b/src/club/static/club/club.scss new file mode 100644 index 000000000..4b3d7d50e --- /dev/null +++ b/src/club/static/club/club.scss @@ -0,0 +1,126 @@ +.plan-select { + margin-bottom: 15px; +} + +.methods { + color: #888; + line-height: 30px; +} +.methods .method { + border: 1px solid #888; + border-radius: 5px; + display: inline-block; + padding: 0 5px; +} + +.methods img { + height: 30px; + margin-right: 5px; + vertical-align: middle; +} + +.payment-method.disabled { + opacity: .5; + filter: grayscale(100%); +} + +.button { + box-sizing: border-box; + display: inline-block; + text-align: center; +} +.kwota, .inna .button, .plan-toggle, .inna input { + border: 1px solid black; + border-radius: 8px; + background: none; + cursor: pointer; + padding: 0; + margin-right: 3%; + margin-bottom: 10px; + line-height: 3em; + font-size: 20px; +} +.plan-toggle { + width: 46.5%; +} +.kwota { + width: 30%; +} +.kwota:after { + content: " zł"; +} +.kwota.yearly { + background: orange; + +} +.inna .button { + width: 63%; +} +.inna input { + width: 60%; + padding-left: 1.5%; + padding-right: 1.5%; + height: 3em !important; + text-align: center; +} +.chunk-alt { + position: relative; + overflow: hidden; +} +.chunk-alt .chunk { + top: 0; +} + +.kwota.active, .plan-toggle.active { + background: #9ACD32; +} +.inna input {display: none;} +.inna.active input {display: inline;} +.inna.active .button {display: none;} + +.ambassador { + padding: 2em; + margin-bottom: 1em; + border: 1px solid #ddd; + position: relative; +} +.ambassador.with-photo { + padding-right: 145px; +} +.ambassador img { + border-radius: 100%; + height: 100px; + width: 100px; + position: absolute; + top: 35px; + right: 30px; +} +.ambassador div { + text-align: right; + line-height: 1.5em; +} + +.club-form-info { + line-height: 1.5em; +} + +@media screen and (max-width: 1023px) { + .club-form-info { + margin-top: 2em; + } +} + + +@media screen and (min-width: 1024px) { + .club-form-info { + border-left: 1px solid #ddd; + padding-left: 2em; + margin-left: 2em; + } + .twocol { + display: flex; + } + .twocol > form, .twocol > div { + flex: 1; + } +} diff --git a/src/club/templates/club/membership_form.html b/src/club/templates/club/membership_form.html index 1ae2f82e5..f9fe931e3 100644 --- a/src/club/templates/club/membership_form.html +++ b/src/club/templates/club/membership_form.html @@ -9,136 +9,6 @@ {% block body %} - - - -

{% trans "Support Wolne Lektury" %}

@@ -164,68 +34,7 @@ vertical-align: middle; {% chunk 'club_form_top' %} - - -

1. {% trans "Choose your type of support" %}

- - {{ form.amount }} - {{ form.monthly }} -
- {% trans "one-time" %} - {% trans "monthly" %} -
- -

2. {% trans "Choose the amount" %}

- - - - -
- {% for amount in club.proposed_monthly_amounts %} - {{ amount }} - {% endfor %} - - - {% trans "different amount" %} - - -
{% include 'club/payment/payu-re.html' %}
-
- -

3. {% trans "Provide an e-mail address" %}

- -

{{ form.email }}

- -

- {{ form.agree_newsletter }} - -

- -

{% trans 'You can unsubscribe at any point. More in the privacy policy.' %}

- -
+ {% include "club/payment_form.html" %} {% chunk 'club_form_bottom' %} @@ -245,17 +54,8 @@ vertical-align: middle; {% endif %}
{% endif %} -
-
- {% chunk 'club-form-info-monthly' %} -
- - -
+ + {% include "club/payment_info.html" %} diff --git a/src/club/templates/club/payment_form.html b/src/club/templates/club/payment_form.html new file mode 100644 index 000000000..454bc7774 --- /dev/null +++ b/src/club/templates/club/payment_form.html @@ -0,0 +1,64 @@ +{% load i18n %} + + + +

1. {% trans "Choose your type of support" %}

+ +{{ form.amount }} +{{ form.monthly }} +
+ {% trans "one-time" %} + {% trans "monthly" %} +
+ +

2. {% trans "Choose the amount" %}

+ + + + +
+ {% for amount in club.proposed_monthly_amounts %} + {{ amount }} + {% endfor %} + + + {% trans "different amount" %} + + +
{% include 'club/payment/payu-re.html' %}
+
+ +

3. {% trans "Provide an e-mail address" %}

+ +

{{ form.email }}

+ +

+ {{ form.agree_newsletter }} + +

+ +

{% trans 'You can unsubscribe at any point. More in the privacy policy.' %}

+ +
diff --git a/src/club/templates/club/payment_info.html b/src/club/templates/club/payment_info.html new file mode 100644 index 000000000..7527f85a7 --- /dev/null +++ b/src/club/templates/club/payment_info.html @@ -0,0 +1,13 @@ +{% load chunks %} + +
+
+ {% chunk 'club-form-info-monthly' %} +
+ + +
diff --git a/src/wolnelektury/settings/static.py b/src/wolnelektury/settings/static.py index 1f42d55a0..efb61b25f 100644 --- a/src/wolnelektury/settings/static.py +++ b/src/wolnelektury/settings/static.py @@ -39,6 +39,7 @@ PIPELINE = { 'css/tlite.css', 'scss/main.scss', + 'club/club.scss', ], 'output_filename': 'css/compressed/main.css', }, diff --git a/src/wolnelektury/static/scss/main/book_box.scss b/src/wolnelektury/static/scss/main/book_box.scss index 17b72f10b..f9e2d6b82 100644 --- a/src/wolnelektury/static/scss/main/book_box.scss +++ b/src/wolnelektury/static/scss/main/book_box.scss @@ -396,6 +396,7 @@ max-width: 32em; border: 1px solid #888; padding: 1em; + box-sizing: border-box; } -- 2.20.1