Allow disable paypal.
authorRadek Czajka <rczajka@rczajka.pl>
Mon, 5 Jun 2023 09:45:00 +0000 (11:45 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Mon, 5 Jun 2023 09:45:00 +0000 (11:45 +0200)
src/club/models.py
src/club/payment_methods.py
src/club/templates/club/2022/donation_step1_form.html
src/club/templates/club/2022/donation_step2.html
src/club/templates/club/2022/donation_step3.html
src/club/views.py
src/wolnelektury/settings/contrib.py
src/wolnelektury/static/2022/images/payments-2.png [deleted file]
src/wolnelektury/static/2022/images/payments-paypal.png [new file with mode: 0644]
src/wolnelektury/static/2022/images/payments-payu.png [new file with mode: 0644]

index 6766694..8fe3e47 100644 (file)
@@ -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 ''
         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):
     
 
 class SingleAmount(models.Model):
index 8d1ad7b..4a596e4 100644 (file)
@@ -150,13 +150,16 @@ class PayPal(PaymentMethod):
     is_onetime = False
 
     def invite_widget(self, schedule, request):
     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')
     
     def initiate(self, request, schedule):
         app = request.GET.get('app')
index 6b985ed..7066db5 100644 (file)
 </form>
 
 <div class="l-checkout__secure">
 </form>
 
 <div class="l-checkout__secure">
-<img src="{% static '2022/images/payments-padlock.png' %}" class="l-checkout__secure__padlock">
-Bezpieczne płatności zapewniają:
-<img src="{% static '2022/images/payments-2.png' %}" class="l-checkout__secure__img">
+  <img src="{% static '2022/images/payments-padlock.png' %}" class="l-checkout__secure__padlock">
+  Bezpieczne płatności zapewniają:
+  <img src="{% static '2022/images/payments-payu.png' %}" class="l-checkout__secure__img" alt="PayU Visa MasterCard">
+  {% if club.paypal_enabled %}
+    <img src="{% static '2022/images/payments-paypal.png' %}" class="l-checkout__secure__img" alt="PayPal">
+  {% endif %}
 </div>
 
 <div class="l-checkout__cols bt-w">
 </div>
 
 <div class="l-checkout__cols bt-w">
index f115ece..4f43b84 100644 (file)
@@ -97,7 +97,7 @@
             </div>
           </div>
           <div class="l-checkout__form__row confirm">
             </div>
           </div>
           <div class="l-checkout__form__row confirm">
-            <a href=".#{{ view.step1_hash }}">Powrót</a>
+            <a href="{% url 'donation_step1' schedule.key %}">Powrót</a>
             <div class="l-checkout__input">
               <button>Dalej</button>
             </div>
             <div class="l-checkout__input">
               <button>Dalej</button>
             </div>
   <div class="l-checkout__secure">
     <img src="{% static '2022/images/payments-padlock.png' %}" class="l-checkout__secure__padlock">
     Bezpieczne płatności zapewniają:
   <div class="l-checkout__secure">
     <img src="{% static '2022/images/payments-padlock.png' %}" class="l-checkout__secure__padlock">
     Bezpieczne płatności zapewniają:
-    <img src="{% static '2022/images/payments-2.png' %}" class="l-checkout__secure__img">
+    <img src="{% static '2022/images/payments-payu.png' %}" class="l-checkout__secure__img" alt="PayU Visa MasterCard">
+    {% if club.paypal_enabled %}
+      <img src="{% static '2022/images/payments-paypal.png' %}" class="l-checkout__secure__img" alt="PayPal">
+    {% endif %}
   </div>
 {% endblock %}
   </div>
 {% endblock %}
index a368c65..7acb617 100644 (file)
@@ -15,8 +15,8 @@
           {{ schedule.amount|floatformat }} zł
           {% if schedule.monthly %}
             <span>/mies.</span>
           {{ schedule.amount|floatformat }} zł
           {% if schedule.monthly %}
             <span>/mies.</span>
-        {% endif %}</h3>
-        <img src="{% static '2022/images/checkout-img-3.jpg' %}" alt="">
+          {% endif %}</h3>
+          <img src="{% static '2022/images/checkout-img-3.jpg' %}" alt="">
       </div>
     </div>
     <div class="l-checkout__col">
       </div>
     </div>
     <div class="l-checkout__col">
           </div>
         </div>
         <div class="l-checkout__form__row confirm">
           </div>
         </div>
         <div class="l-checkout__form__row confirm">
-          <a href="#">Powrót</a>
-          <!-- div class="l-checkout__input">
-            <a href="#">Dalej</a>
-          </div-->
+          <a href="{% url 'donation_step2' schedule.key %}">Powrót</a>
         </div>
       </div>
     </div>
   </div>
         </div>
       </div>
     </div>
   </div>
-  <img src="{% static '2022/images/checkout-footer.png' %}" alt="Bezpieczne płatności zapewniają" class="l-checkout__footer__img">
+  <div class="l-checkout__secure">
+    <img src="{% static '2022/images/payments-padlock.png' %}" class="l-checkout__secure__padlock">
+    Bezpieczne płatności zapewniają:
+    <img src="{% static '2022/images/payments-payu.png' %}" class="l-checkout__secure__img" alt="PayU Visa MasterCard">
+    {% if club.paypal_enabled %}
+      <img src="{% static '2022/images/payments-paypal.png' %}" class="l-checkout__secure__img" alt="PayPal">
+    {% endif %}
+  </div>
 {% endblock %}
 {% endblock %}
index 74ff2fb..e80fcf9 100644 (file)
@@ -53,6 +53,11 @@ class DonationStep2(UpdateView):
     template_name = 'club/2022/donation_step2.html'
     step = 2
 
     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
 
 class JoinView(CreateView):
     @property
index 858c402..664003f 100644 (file)
@@ -17,6 +17,7 @@ PAYPAL_CONFIG = {
     'client_id': '',
     'client_secret': '',
 }
     'client_id': '',
     'client_secret': '',
 }
+PAYPAL_ENABLED = True
 
 REST_FRAMEWORK = {
     "DEFAULT_RENDERER_CLASSES": (
 
 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 (file)
index 3460761..0000000
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 (file)
index 0000000..f26e1cc
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 (file)
index 0000000..47383c2
Binary files /dev/null and b/src/wolnelektury/static/2022/images/payments-payu.png differ