diff --git a/tailbone/templates/customers/configure.mako b/tailbone/templates/customers/configure.mako index 93a72327..e68f4543 100644 --- a/tailbone/templates/customers/configure.mako +++ b/tailbone/templates/customers/configure.mako @@ -62,6 +62,14 @@ + + + + +

POS

diff --git a/tailbone/templates/people/configure.mako b/tailbone/templates/people/configure.mako index c936b2f9..c39e49d1 100644 --- a/tailbone/templates/people/configure.mako +++ b/tailbone/templates/people/configure.mako @@ -15,6 +15,14 @@ + + + + + diff --git a/tailbone/templates/people/view_profile_buefy.mako b/tailbone/templates/people/view_profile_buefy.mako index 79e51435..84aecd30 100644 --- a/tailbone/templates/people/view_profile_buefy.mako +++ b/tailbone/templates/people/view_profile_buefy.mako @@ -697,25 +697,55 @@ {{ customer._key }} - + {{ customer.name }} - - + + + {{ customer.account_holder.display_name }} + + + {{ customer.account_holder.display_name }} + + + % if expose_customer_shoppers: + + + + % endif + + % if expose_customer_people: + + + + % endif + diff --git a/tailbone/views/customers.py b/tailbone/views/customers.py index 217d0770..af90f0f5 100644 --- a/tailbone/views/customers.py +++ b/tailbone/views/customers.py @@ -57,6 +57,7 @@ class CustomerView(MasterView): labels = { 'id': "ID", + 'name': "Account Name", 'default_phone': "Phone Number", 'default_email': "Email Address", 'default_address': "Physical Address", @@ -74,6 +75,7 @@ class CustomerView(MasterView): form_fields = [ '_customer_key_', 'name', + 'account_holder', 'default_phone', 'default_address', 'address_street', @@ -111,11 +113,13 @@ class CustomerView(MasterView): default=False) return self._expose_active_in_pos + # TODO: this is duplicated in people view module def should_expose_shoppers(self): return self.rattail_config.getbool('rattail', 'customers.expose_shoppers', default=True) + # TODO: this is duplicated in people view module def should_expose_people(self): return self.rattail_config.getbool('rattail', 'customers.expose_people', @@ -249,6 +253,13 @@ class CustomerView(MasterView): customer = f.model_instance permission_prefix = self.get_permission_prefix() + # account_holder + if self.creating: + f.remove_field('account_holder') + else: + f.set_readonly('account_holder') + f.set_renderer('account_holder', self.render_person) + # default_email f.set_renderer('default_email', self.render_default_email) if not self.creating and customer.emails: @@ -623,6 +634,8 @@ class CustomerView(MasterView): 'option': 'customers.expose_people', 'type': bool, 'default': True}, + {'section': 'rattail', + 'option': 'clientele.handler'}, # POS {'section': 'rattail', diff --git a/tailbone/views/people.py b/tailbone/views/people.py index 0f50e7fc..71403efd 100644 --- a/tailbone/views/people.py +++ b/tailbone/views/people.py @@ -446,6 +446,8 @@ class PersonView(MasterView): 'customers_data': self.get_context_customers(person), # TODO: deprecate / remove this 'customer_xref_buttons': self.get_customer_xref_buttons(person), + 'expose_customer_people': self.customers_should_expose_people(), + 'expose_customer_shoppers': self.customers_should_expose_shoppers(), 'members_data': self.get_context_members(person), 'member_xref_buttons': self.get_member_xref_buttons(person), 'employee': employee, @@ -554,6 +556,20 @@ class PersonView(MasterView): return context + def get_context_shopper(self, shopper): + person = shopper.person + return { + 'uuid': shopper.uuid, + 'person_uuid': person.uuid, + 'first_name': person.first_name, + 'middle_name': person.middle_name, + 'last_name': person.last_name, + 'display_name': person.display_name, + 'view_profile_url': self.get_action_url('view_profile', person), + 'phones': self.get_context_phones(person), + 'emails': self.get_context_emails(person), + } + def get_context_content_title(self, person): return str(person) @@ -578,6 +594,7 @@ class PersonView(MasterView): def get_context_customers(self, person): app = self.get_rattail_app() clientele = app.get_clientele_handler() + expose_shoppers = self.customers_should_expose_shoppers() customers = clientele.get_customers_for_account_holder(person) key = self.get_customer_key_field() @@ -599,6 +616,14 @@ class PersonView(MasterView): 'external_links': [], } + if customer.account_holder: + context['account_holder'] = self.get_context_person( + customer.account_holder) + + if expose_shoppers: + context['shoppers'] = [self.get_context_shopper(s) + for s in customer.shoppers] + for supp in self.iter_view_supplements(): if hasattr(supp, 'get_context_for_customer'): context = supp.get_context_for_customer(customer, context) @@ -607,6 +632,18 @@ class PersonView(MasterView): return data + # TODO: this is duplicated in customers view module + def customers_should_expose_shoppers(self): + return self.rattail_config.getbool('rattail', + 'customers.expose_shoppers', + default=True) + + # TODO: this is duplicated in customers view module + def customers_should_expose_people(self): + return self.rattail_config.getbool('rattail', + 'customers.expose_people', + default=True) + def get_context_members(self, person): app = self.get_rattail_app() membership = app.get_membership_handler() @@ -1394,6 +1431,8 @@ class PersonView(MasterView): {'section': 'rattail', 'option': 'people.straight_to_profile', 'type': bool}, + {'section': 'rattail', + 'option': 'people.handler'}, ]