From f8f6b766578b213c6bfcb3cc1f8bde375ca18474 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 10 Dec 2022 09:11:27 -0600 Subject: [PATCH] Add xref buttons for Customer, Member tabs in profile view --- .../templates/people/view_profile_buefy.mako | 6 ++++++ tailbone/views/master.py | 1 + tailbone/views/people.py | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/tailbone/templates/people/view_profile_buefy.mako b/tailbone/templates/people/view_profile_buefy.mako index 51ecaed0..89cafb6a 100644 --- a/tailbone/templates/people/view_profile_buefy.mako +++ b/tailbone/templates/people/view_profile_buefy.mako @@ -579,6 +579,9 @@ <%def name="render_member_panel_buttons(member)"> + % for button in member_xref_buttons: + ${button} + % endfor % if request.has_perm('members.view'): View Member @@ -665,6 +668,9 @@ <%def name="render_customer_panel_buttons(customer)"> + % for button in customer_xref_buttons: + ${button} + % endfor % if request.has_perm('customers.view'): View Customer diff --git a/tailbone/views/master.py b/tailbone/views/master.py index c96270b7..304494c3 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -5107,6 +5107,7 @@ class ViewSupplement(object): self.request = master.request self.model = master.model self.rattail_config = master.rattail_config + self.Session = master.Session def get_grid_query(self, query): """ diff --git a/tailbone/views/people.py b/tailbone/views/people.py index 6d517e3a..d5330076 100644 --- a/tailbone/views/people.py +++ b/tailbone/views/people.py @@ -417,7 +417,9 @@ class PersonView(MasterView): 'email_type_options': self.get_email_type_options(), 'max_lengths': self.get_max_lengths(), 'customers_data': self.get_context_customers(person), + 'customer_xref_buttons': self.get_customer_xref_buttons(person), 'members_data': self.get_context_members(person), + 'member_xref_buttons': self.get_member_xref_buttons(person), 'employee': employee, 'employee_data': self.get_context_employee(employee) if employee else {}, 'employee_view_url': self.request.route_url('employees.view', uuid=employee.uuid) if employee else None, @@ -430,6 +432,22 @@ class PersonView(MasterView): template = 'view_profile_buefy' if use_buefy else 'view_profile' return self.render_to_response(template, context) + def get_customer_xref_buttons(self, person): + buttons = [] + for supp in self.iter_view_supplements(): + if hasattr(supp, 'get_customer_xref_buttons'): + buttons.extend(supp.get_customer_xref_buttons(person) or []) + buttons = self.normalize_xref_buttons(buttons) + return buttons + + def get_member_xref_buttons(self, person): + buttons = [] + for supp in self.iter_view_supplements(): + if hasattr(supp, 'get_member_xref_buttons'): + buttons.extend(supp.get_member_xref_buttons(person) or []) + buttons = self.normalize_xref_buttons(buttons) + return buttons + def template_kwargs_view_profile(self, **kwargs): """ Stub method so subclass can call `super()` for it.