Use handler to generate NationBuilder URLs

instead of config function
This commit is contained in:
Lance Edgar 2023-09-14 13:22:19 -05:00
parent a5e6dd0c96
commit 5d865ae8bf
2 changed files with 14 additions and 3 deletions

View file

@ -24,10 +24,9 @@
Common menus for NationBuilder
"""
from rattail_nationbuilder.nationbuilder.util import get_nationbuilder_url
def make_nationbuilder_menu(request):
app = request.rattail_config.get_app()
url = request.route_url
nationbuilder_menu = {
@ -47,7 +46,7 @@ def make_nationbuilder_menu(request):
],
}
url = get_nationbuilder_url(request.rattail_config)
url = app.get_nationbuilder_handler().get_url()
if url:
nationbuilder_menu['items'].insert(
0, {

View file

@ -100,6 +100,18 @@ class NationBuilderCacheDonationView(NationBuilderMasterView):
f.set_type('amount', 'currency')
def get_xref_buttons(self, donation):
buttons = super().get_xref_buttons(donation)
app = self.get_rattail_app()
nationbuilder = app.get_nationbuilder_handler()
url = nationbuilder.get_url()
if url:
url = f'{url}/admin/signups/{donation.donor_id}/donations/{donation.id}'
buttons.append(self.make_xref_button(url=url, text="View in NationBuilder"))
return buttons
def defaults(config, **kwargs):
base = globals()