diff --git a/tailbone/templates/customers/configure.mako b/tailbone/templates/customers/configure.mako new file mode 100644 index 00000000..13093a7b --- /dev/null +++ b/tailbone/templates/customers/configure.mako @@ -0,0 +1,23 @@ +## -*- coding: utf-8; -*- +<%inherit file="/configure.mako" /> + +<%def name="form_content()"> + +

POS

+
+ + + + Expose/track the "Active in POS" flag for customers. + + + +
+ + + + +${parent.body()} diff --git a/tailbone/views/customers.py b/tailbone/views/customers.py index 310bddb5..d061701f 100644 --- a/tailbone/views/customers.py +++ b/tailbone/views/customers.py @@ -50,6 +50,7 @@ class CustomerView(MasterView): people_detachable = True touchable = True supports_autocomplete = True + configurable = True # whether to show "view full profile" helper for customer view show_profiles_helper = True @@ -92,6 +93,13 @@ class CustomerView(MasterView): 'members', ] + def get_expose_active_in_pos(self): + if not hasattr(self, '_expose_active_in_pos'): + self._expose_active_in_pos = self.rattail_config.getbool( + 'rattail', 'customers.active_in_pos', + default=False) + return self._expose_active_in_pos + def configure_grid(self, g): super(CustomerView, self).configure_grid(g) @@ -132,8 +140,9 @@ class CustomerView(MasterView): g.set_renderer('person', self.grid_render_person) # active_in_pos - g.filters['active_in_pos'].default_active = True - g.filters['active_in_pos'].default_verb = 'is_true' + if self.get_expose_active_in_pos(): + g.filters['active_in_pos'].default_active = True + g.filters['active_in_pos'].default_verb = 'is_true' g.set_link('id') g.set_link('number') @@ -142,8 +151,9 @@ class CustomerView(MasterView): g.set_link('email') def grid_extra_class(self, customer, i): - if not customer.active_in_pos: - return 'warning' + if self.get_expose_active_in_pos(): + if not customer.active_in_pos: + return 'warning' def get_instance(self): try: @@ -246,6 +256,10 @@ class CustomerView(MasterView): customer = f.model_instance permission_prefix = self.get_permission_prefix() + if not self.get_expose_active_in_pos(): + f.remove('active_in_pos', + 'active_in_pos_sticky') + # members if self.creating: f.remove_field('members') @@ -430,6 +444,16 @@ class CustomerView(MasterView): return self.redirect(self.request.get_referrer()) + def configure_get_simple_settings(self): + return [ + + # POS + {'section': 'rattail', + 'option': 'customers.active_in_pos', + 'type': bool}, + + ] + @classmethod def defaults(cls, config): cls._defaults(config)