From 60157abd46ba1d7d3c0c06672736f06f0c439948 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 17 Mar 2020 12:28:13 -0500 Subject: [PATCH] Allow customization for Customers tab of Profile view more tabs to come, this was all i needed for now --- .../templates/people/view_profile_buefy.mako | 192 ++++++++---------- tailbone/views/people.py | 29 +++ 2 files changed, 112 insertions(+), 109 deletions(-) diff --git a/tailbone/templates/people/view_profile_buefy.mako b/tailbone/templates/people/view_profile_buefy.mako index ecb8d60a..b34de9ac 100644 --- a/tailbone/templates/people/view_profile_buefy.mako +++ b/tailbone/templates/people/view_profile_buefy.mako @@ -9,6 +9,86 @@ ${self.page_content()} +<%def name="render_customer_tab()"> + + +
+ +
+

{{ person.fullName }} is associated with {{ customers.length }} customer account(s)

+
+ +
+ + +
+ + + #{{ customer.number }} {{ customer.name }} +
+ +
+
+
+ + + {{ customer.number }} + + + + {{ customer.id }} + + + + {{ customer.name }} + + + + + + +
+
+ ${self.render_customer_panel_buttons(customer)} +
+
+
+
+
+ +
+

{{ person.fullName }} has never had a customer account.

+
+ +
+ + +<%def name="render_customer_panel_buttons(customer)"> + % if request.has_perm('customers.view'): + + View Customer + + % endif + + <%def name="render_this_page_template()"> ${parent.render_this_page_template()} @@ -148,115 +228,7 @@ - - % if person.customers: -

${person} is associated with ${len(person.customers)} customer account(s)

-
-
- % for customer in person.customers: - - - -
- ${customer.id} - ${customer.name} -
- -
- -
- -
- -
-
- -
- ${customer.id or ''} -
-
-
- -
-
- -
- ${customer.name} -
-
-
- - % if customer.phones: - % for phone in customer.phones: -
-
- -
- ${phone.number} (type: ${phone.type}) -
-
-
- % endfor - % else: -
-
- -
- (none on file) -
-
-
- % endif - - % if customer.emails: - % for email in customer.emails: -
-
- -
- ${email.address} (type: ${email.type}) -
-
-
- % endfor - % else: -
-
- -
- (none on file) -
-
-
- % endif - -
- -
- % if request.has_perm('customers.view'): - ${h.link_to("View Customer", url('customers.view', uuid=customer.uuid), class_='button')} - % endif -
- -
- -
-
- % endfor -
- - % else: -

${person} has never been a customer.

- % endif -
+ ${self.render_customer_tab()} @@ -422,6 +394,8 @@ data() { return { activeTab: 0, + person: ${json.dumps(person_data)|n}, + customers: ${json.dumps(customers_data)|n}, } }, } diff --git a/tailbone/views/people.py b/tailbone/views/people.py index 2173be83..ef78c91f 100644 --- a/tailbone/views/people.py +++ b/tailbone/views/people.py @@ -297,6 +297,8 @@ class PeopleView(MasterView): 'instance': person, 'instance_title': self.get_instance_title(person), 'today': localtime(self.rattail_config).date(), + 'person_data': self.get_context_person(person), + 'customers_data': self.get_context_customers(person), 'employee': employee, '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, @@ -307,6 +309,33 @@ class PeopleView(MasterView): template = 'view_profile_buefy' if use_buefy else 'view_profile' return self.render_to_response(template, context) + def get_context_person(self, person): + return { + 'uuid': person.uuid, + 'first_name': person.first_name, + 'last_name': person.last_name, + 'display_name': person.display_name, + 'view_url': self.get_action_url('view', person), + 'view_profile_url': self.get_action_url('view_profile', person), + } + + def get_context_customers(self, person): + data = [] + for cp in person._customers: + customer = cp.customer + data.append({ + 'uuid': customer.uuid, + 'ordinal': cp.ordinal, + 'id': customer.id, + 'number': customer.number, + 'name': customer.name, + 'view_url': self.request.route_url('customers.view', + uuid=customer.uuid), + 'people': [self.get_context_person(p) + for p in customer.people], + }) + return data + def get_context_employee_history(self, employee): data = [] if employee: