Skip to content

Commit

Permalink
Simplified payment button customisation. spookylukey#196
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiocaccamo committed Jul 6, 2022
1 parent 84c0183 commit 6710279
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions paypal/standard/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,20 +191,26 @@ def get_login_url(self):
else:
return LOGIN_URL

def get_html(self):
return format_html(
"""<form action="{0}" method="post">{1}{2}</form>""",
self.get_login_url(),
self.as_p(),
self.get_html_submit_element(),
)

def get_html_submit_element(self):
return format_html(
"""<input type="image" src="{0}" name="submit" alt="Buy it Now" />""",
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(
"""<form action="{0}" method="post">
{1}
<input type="image" src="{2}" name="submit" alt="Buy it Now" />
</form>""",
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`,
Expand All @@ -214,15 +220,7 @@ def render(self, *args, **kwargs):
else:

def render(self):
return format_html(
"""<form action="{0}" method="post">
{1}
<input type="image" src="{2}" name="submit" alt="Buy it Now" />
</form>""",
self.get_login_url(),
self.as_p(),
self.get_image(),
)
return self.get_html()

def get_image(self):
return {
Expand Down

0 comments on commit 6710279

Please sign in to comment.