From 6710279c7509e00109eeee351a7c0ba12c3ba835 Mon Sep 17 00:00:00 2001 From: Fabio Caccamo Date: Wed, 6 Jul 2022 12:36:09 +0200 Subject: [PATCH] Simplified payment button customisation. #196 --- paypal/standard/forms.py | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/paypal/standard/forms.py b/paypal/standard/forms.py index 38cec99..66d3028 100644 --- a/paypal/standard/forms.py +++ b/paypal/standard/forms.py @@ -191,20 +191,26 @@ def get_login_url(self): else: return LOGIN_URL + def get_html(self): + return format_html( + """
{1}{2}
""", + self.get_login_url(), + self.as_p(), + self.get_html_submit_element(), + ) + + def get_html_submit_element(self): + return format_html( + """""", + self.get_image(), + ) + if DJANGO_FORM_HAS_RENDER_METHOD: def render(self, *args, **kwargs): if not args and not kwargs: # `form.render` usage from template - return format_html( - """
- {1} - -
""", - self.get_login_url(), - self.as_p(), - self.get_image(), - ) + return self.get_html() else: # Need to delegate to super. This provides # support for `as_p` method and for `BoundField.label_tag`, @@ -214,15 +220,7 @@ def render(self, *args, **kwargs): else: def render(self): - return format_html( - """
- {1} - -
""", - self.get_login_url(), - self.as_p(), - self.get_image(), - ) + return self.get_html() def get_image(self): return {