Skip to content

Commit

Permalink
add modal json only when it exists (#1737)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pomax committed Aug 9, 2018
1 parent 2bbcc66 commit 511985a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions network-api/networkapi/wagtailpages/templatetags/mini_site_tags.py
Expand Up @@ -19,9 +19,15 @@ def mini_site_horizontal_nav(context, page):
# Render a page's CTA (petition, signup, etc.)
@register.inclusion_tag('wagtailpages/tags/cta.html', takes_context=True)
def cta(context, page):
cta = page.cta
return {
'cta': cta,
'modals_json': page.get_donation_modal_json(),
'cta_type': cta.__class__.__name__,
cta = {
'cta': page.cta,
'cta_type': page.cta.__class__.__name__,
}

# Only campaign pages currently have donation modal CTA data
# associated with them, so only add this if the accessor
# for it exists for the page type we're rendering.
if hasattr(page, 'get_donation_modal_json'):
cta['modals_json'] = page.get_donation_modal_json()

return cta

0 comments on commit 511985a

Please sign in to comment.