From 90cc8e5370ef4194ee2b0985a5f849a72794a3d9 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 8 Nov 2021 20:17:07 -0600 Subject: [PATCH] Fix dynamic content title for "view profile" page --- .../templates/people/view_profile_buefy.mako | 6 +++++- tailbone/views/people.py | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tailbone/templates/people/view_profile_buefy.mako b/tailbone/templates/people/view_profile_buefy.mako index 9ef956a9..766ca5f1 100644 --- a/tailbone/templates/people/view_profile_buefy.mako +++ b/tailbone/templates/people/view_profile_buefy.mako @@ -14,6 +14,10 @@ +<%def name="content_title()"> + ${dynamic_content_title} + + <%def name="page_content()"> @@ -1394,7 +1398,7 @@ mixins: [SubmitMixin], props: { employee: Object, - employeeHistory: Object, + employeeHistory: Array, }, computed: { diff --git a/tailbone/views/people.py b/tailbone/views/people.py index 8e8374c4..3f055493 100644 --- a/tailbone/views/people.py +++ b/tailbone/views/people.py @@ -445,18 +445,27 @@ class PersonView(MasterView): 'employee_view_url': self.request.route_url('employees.view', uuid=employee.uuid) if employee else None, 'employee_history': employee.get_current_history() if employee else None, 'employee_history_data': self.get_context_employee_history(employee), + 'dynamic_content_title': self.get_context_content_title(person), } use_buefy = self.get_use_buefy() template = 'view_profile_buefy' if use_buefy else 'view_profile' return self.render_to_response(template, context) - def template_kwargs_view_profile_buefy(self, **kwargs): + def template_kwargs_view_profile(self, **kwargs): """ - Method stub, so subclass can always invoke super() for it. + Stub method so subclass can call `super()` for it. """ return kwargs + def template_kwargs_view_profile_buefy(self, **kwargs): + """ + Note that any subclass should not need to define this method. + It by default invokes :meth:`template_kwargs_view_profile()` + and returns that result. + """ + return self.template_kwargs_view_profile(**kwargs) + def get_max_lengths(self): model = self.model return { @@ -507,6 +516,7 @@ class PersonView(MasterView): 'view_profile_url': self.get_action_url('view_profile', person), 'phones': self.get_context_phones(person), 'emails': self.get_context_emails(person), + 'dynamic_content_title': self.get_context_content_title(person), } if person.address: @@ -514,6 +524,9 @@ class PersonView(MasterView): return context + def get_context_content_title(self, person): + return six.text_type(person) + def get_context_address(self, address): context = { 'uuid': address.uuid, @@ -633,6 +646,7 @@ class PersonView(MasterView): return { 'success': True, 'person': self.get_context_person(person), + 'dynamic_content_title': self.get_context_content_title(person), } def get_context_phones(self, person):