From: Radek Czajka Date: Mon, 5 Jun 2023 09:45:00 +0000 (+0200) Subject: Allow disable paypal. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/4cbcf8cac5e8cad592d9d84d76408249ccca8112 Allow disable paypal. --- diff --git a/src/club/models.py b/src/club/models.py index 676669497..8fe3e4798 100644 --- a/src/club/models.py +++ b/src/club/models.py @@ -73,6 +73,11 @@ class Club(models.Model): amounts = self.monthlyamount_set if monthly else self.singleamount_set amount = amounts.all().filter(amount__lte=amount).last() return amount.description if amount is not None else '' + + @property + def paypal_enabled(self): + print("ENABLED?", settings.PAYPAL_ENABLED) + return settings.PAYPAL_ENABLED class SingleAmount(models.Model): diff --git a/src/club/payment_methods.py b/src/club/payment_methods.py index 8d1ad7be9..4a596e45b 100644 --- a/src/club/payment_methods.py +++ b/src/club/payment_methods.py @@ -150,13 +150,16 @@ class PayPal(PaymentMethod): is_onetime = False def invite_widget(self, schedule, request): - return render_to_string( - 'club/payment/paypal_invite.html', - { - 'schedule': schedule, - }, - request=request - ) + if settings.PAYPAL_ENABLED: + return render_to_string( + 'club/payment/paypal_invite.html', + { + 'schedule': schedule, + }, + request=request + ) + else: + return '' def initiate(self, request, schedule): app = request.GET.get('app') diff --git a/src/club/templates/club/2022/donation_step1_form.html b/src/club/templates/club/2022/donation_step1_form.html index 6b985eded..7066db593 100644 --- a/src/club/templates/club/2022/donation_step1_form.html +++ b/src/club/templates/club/2022/donation_step1_form.html @@ -67,9 +67,12 @@
- -Bezpieczne płatności zapewniają: - + + Bezpieczne płatności zapewniają: + PayU Visa MasterCard + {% if club.paypal_enabled %} + PayPal + {% endif %}
diff --git a/src/club/templates/club/2022/donation_step2.html b/src/club/templates/club/2022/donation_step2.html index f115ece6b..4f43b84fb 100644 --- a/src/club/templates/club/2022/donation_step2.html +++ b/src/club/templates/club/2022/donation_step2.html @@ -97,7 +97,7 @@
- Powrót + Powrót
@@ -109,6 +109,9 @@
Bezpieczne płatności zapewniają: - + PayU Visa MasterCard + {% if club.paypal_enabled %} + PayPal + {% endif %}
{% endblock %} diff --git a/src/club/templates/club/2022/donation_step3.html b/src/club/templates/club/2022/donation_step3.html index a368c659b..7acb6170b 100644 --- a/src/club/templates/club/2022/donation_step3.html +++ b/src/club/templates/club/2022/donation_step3.html @@ -15,8 +15,8 @@ {{ schedule.amount|floatformat }} zł {% if schedule.monthly %} /mies. - {% endif %} - + {% endif %} +
@@ -91,13 +91,17 @@
- Powrót - + Powrót
- Bezpieczne płatności zapewniają +
+ + Bezpieczne płatności zapewniają: + PayU Visa MasterCard + {% if club.paypal_enabled %} + PayPal + {% endif %} +
{% endblock %} diff --git a/src/club/views.py b/src/club/views.py index 74ff2fb90..e80fcf977 100644 --- a/src/club/views.py +++ b/src/club/views.py @@ -53,6 +53,11 @@ class DonationStep2(UpdateView): template_name = 'club/2022/donation_step2.html' step = 2 + def get_context_data(self, **kwargs): + c = super().get_context_data(**kwargs) + c['club'] = models.Club.objects.first() + return c + class JoinView(CreateView): @property diff --git a/src/wolnelektury/settings/contrib.py b/src/wolnelektury/settings/contrib.py index 858c4022c..664003ff1 100644 --- a/src/wolnelektury/settings/contrib.py +++ b/src/wolnelektury/settings/contrib.py @@ -17,6 +17,7 @@ PAYPAL_CONFIG = { 'client_id': '', 'client_secret': '', } +PAYPAL_ENABLED = True REST_FRAMEWORK = { "DEFAULT_RENDERER_CLASSES": ( diff --git a/src/wolnelektury/static/2022/images/payments-2.png b/src/wolnelektury/static/2022/images/payments-2.png deleted file mode 100644 index 346076122..000000000 Binary files a/src/wolnelektury/static/2022/images/payments-2.png and /dev/null differ diff --git a/src/wolnelektury/static/2022/images/payments-paypal.png b/src/wolnelektury/static/2022/images/payments-paypal.png new file mode 100644 index 000000000..f26e1cc0b Binary files /dev/null and b/src/wolnelektury/static/2022/images/payments-paypal.png differ diff --git a/src/wolnelektury/static/2022/images/payments-payu.png b/src/wolnelektury/static/2022/images/payments-payu.png new file mode 100644 index 000000000..47383c202 Binary files /dev/null and b/src/wolnelektury/static/2022/images/payments-payu.png differ