-
- {{ customer.number }}
-
-
-
- {{ customer.id }}
+
+ {{ customer._key }}
@@ -1011,8 +1003,8 @@
<%def name="render_profile_tabs()">
${self.render_personal_tab()}
- ${self.render_customer_tab()}
${self.render_member_tab()}
+ ${self.render_customer_tab()}
${self.render_employee_tab()}
${self.render_user_tab()}
%def>
diff --git a/tailbone/views/customers.py b/tailbone/views/customers.py
index 50b93d59..02071ab4 100644
--- a/tailbone/views/customers.py
+++ b/tailbone/views/customers.py
@@ -63,16 +63,14 @@ class CustomerView(MasterView):
}
grid_columns = [
- 'id',
- 'number',
+ '_customer_key_',
'name',
'phone',
'email',
]
form_fields = [
- 'id',
- 'number',
+ '_customer_key_',
'name',
'default_phone',
'default_address',
@@ -114,13 +112,16 @@ class CustomerView(MasterView):
super(CustomerView, self).configure_grid(g)
model = self.model
- # number
- g.set_link('number')
+ # customer key
+ field = self.get_customer_key_field()
+ g.filters[field].default_active = True
+ g.filters[field].default_verb = 'equal'
+ g.set_sort_defaults(field)
+ g.set_link(field)
# name
g.filters['name'].default_active = True
g.filters['name'].default_verb = 'contains'
- g.set_sort_defaults('name')
# phone
g.set_joiner('phone', lambda q: q.outerjoin(model.CustomerPhoneNumber, sa.and_(
@@ -158,7 +159,6 @@ class CustomerView(MasterView):
g.filters['active_in_pos'].default_active = True
g.filters['active_in_pos'].default_verb = 'is_true'
- g.set_link('id')
g.set_link('name')
g.set_link('person')
g.set_link('email')
@@ -485,6 +485,10 @@ class CustomerView(MasterView):
return [
# General
+ {'section': 'rattail',
+ 'option': 'customers.key_field'},
+ {'section': 'rattail',
+ 'option': 'customers.key_label'},
{'section': 'rattail',
'option': 'customers.choice_uses_dropdown',
'type': bool},
diff --git a/tailbone/views/master.py b/tailbone/views/master.py
index 394424a2..0993ac7d 100644
--- a/tailbone/views/master.py
+++ b/tailbone/views/master.py
@@ -163,6 +163,8 @@ class MasterView(View):
labels = {'uuid': "UUID"}
+ customer_key_fields = {}
+ member_key_fields = {}
product_key_fields = {}
# ROW-RELATED ATTRS FOLLOW:
@@ -463,6 +465,8 @@ class MasterView(View):
grid.remove('local_only')
grid.remove_filter('local_only')
+ self.configure_column_customer_key(grid)
+ self.configure_column_member_key(grid)
self.configure_column_product_key(grid)
for supp in self.iter_view_supplements():
@@ -561,6 +565,8 @@ class MasterView(View):
# super(MasterView, self).configure_row_grid(grid)
self.set_row_labels(grid)
+ self.configure_column_customer_key(grid)
+ self.configure_column_member_key(grid)
self.configure_column_product_key(grid)
def row_grid_extra_class(self, obj, i):
@@ -2407,8 +2413,14 @@ class MasterView(View):
'quickie': None,
}
- key = self.rattail_config.product_key()
- context['product_key_field'] = self.product_key_fields.get(key, key)
+ context['customer_key_field'] = self.get_customer_key_field()
+ context['customer_key_label'] = self.get_customer_key_label()
+
+ context['member_key_field'] = self.get_member_key_field()
+ context['member_key_label'] = self.get_member_key_label()
+
+ context['product_key_field'] = self.get_product_key_field()
+ context['product_key_label'] = self.get_product_key_label()
if self.expose_quickie_search:
context['quickie'] = self.get_quickie_context()
@@ -4131,6 +4143,8 @@ class MasterView(View):
"""
self.configure_common_form(form)
+ self.configure_field_customer_key(form)
+ self.configure_field_member_key(form)
self.configure_field_product_key(form)
for supp in self.iter_view_supplements():
@@ -4596,6 +4610,8 @@ class MasterView(View):
self.set_row_labels(form)
+ self.configure_field_customer_key(form)
+ self.configure_field_member_key(form)
self.configure_field_product_key(form)
def validate_row_form(self, form):
@@ -4604,23 +4620,77 @@ class MasterView(View):
return True
return False
+ def get_customer_key_field(self):
+ app = self.get_rattail_app()
+ key = app.get_customer_key_field()
+ return self.customer_key_fields.get(key, key)
+
+ def get_customer_key_label(self):
+ app = self.get_rattail_app()
+ field = self.get_customer_key_field()
+ return app.get_customer_key_label(field=field)
+
+ def configure_column_customer_key(self, g):
+ if '_customer_key_' in g.columns:
+ field = self.get_customer_key_field()
+ g.replace('_customer_key_', field)
+ g.set_label(field, self.get_customer_key_label())
+ g.set_link(field)
+
+ def configure_field_customer_key(self, f):
+ if '_customer_key_' in f:
+ field = self.get_customer_key_field()
+ f.replace('_customer_key_', field)
+ f.set_label(field, self.get_customer_key_label())
+
+ def get_member_key_field(self):
+ app = self.get_rattail_app()
+ key = app.get_member_key_field()
+ return self.member_key_fields.get(key, key)
+
+ def get_member_key_label(self):
+ app = self.get_rattail_app()
+ field = self.get_member_key_field()
+ return app.get_member_key_label(field=field)
+
+ def configure_column_member_key(self, g):
+ if '_member_key_' in g.columns:
+ field = self.get_member_key_field()
+ g.replace('_member_key_', field)
+ g.set_label(field, self.get_member_key_label())
+ g.set_link(field)
+
+ def configure_field_member_key(self, f):
+ if '_member_key_' in f:
+ field = self.get_member_key_field()
+ f.replace('_member_key_', field)
+ f.set_label(field, self.get_member_key_label())
+
+ def get_product_key_field(self):
+ app = self.get_rattail_app()
+ key = app.get_product_key_field()
+ return self.product_key_fields.get(key, key)
+
+ def get_product_key_label(self):
+ app = self.get_rattail_app()
+ field = self.get_product_key_field()
+ return app.get_product_key_label(field=field)
+
def configure_column_product_key(self, g):
if '_product_key_' in g.columns:
- key = self.rattail_config.product_key()
- field = self.product_key_fields.get(key, key)
+ field = self.get_product_key_field()
g.replace('_product_key_', field)
- g.set_label(field, self.rattail_config.product_key_title(key))
+ g.set_label(field, self.get_product_key_label())
g.set_link(field)
- if key == 'upc':
+ if field == 'upc':
g.set_renderer(field, self.render_upc)
def configure_field_product_key(self, f):
if '_product_key_' in f:
- key = self.rattail_config.product_key()
- field = self.product_key_fields.get(key, key)
+ field = self.get_product_key_field()
f.replace('_product_key_', field)
- f.set_label(field, self.rattail_config.product_key_title(key))
- if key == 'upc':
+ f.set_label(field, self.get_product_key_label())
+ if field == 'upc':
f.set_renderer(field, self.render_upc)
def get_row_action_url(self, action, row, **kwargs):
diff --git a/tailbone/views/members.py b/tailbone/views/members.py
index 28265061..955a217f 100644
--- a/tailbone/views/members.py
+++ b/tailbone/views/members.py
@@ -42,14 +42,14 @@ class MemberView(MasterView):
is_contact = True
touchable = True
has_versions = True
+ configurable = True
labels = {
'id': "ID",
}
grid_columns = [
- 'number',
- 'id',
+ '_member_key_',
'person',
'customer',
'email',
@@ -61,8 +61,7 @@ class MemberView(MasterView):
]
form_fields = [
- 'number',
- 'id',
+ '_member_key_',
'person',
'customer',
'default_email',
@@ -77,6 +76,13 @@ class MemberView(MasterView):
def configure_grid(self, g):
super(MemberView, self).configure_grid(g)
+ # member key
+ field = self.get_member_key_field()
+ g.filters[field].default_active = True
+ g.filters[field].default_verb = 'equal'
+ g.set_sort_defaults(field)
+ g.set_link(field)
+
g.set_joiner('person', lambda q: q.outerjoin(model.Person))
g.set_sorter('person', model.Person.display_name)
g.set_filter('person', model.Person.display_name)
@@ -105,8 +111,6 @@ class MemberView(MasterView):
g.set_filter('email', model.MemberEmailAddress.address)
g.set_label('email', "Email Address")
- g.set_sort_defaults('number')
-
g.set_link('person')
g.set_link('customer')
@@ -186,6 +190,16 @@ class MemberView(MasterView):
if member.phones:
return member.phones[0].number
+ def configure_get_simple_settings(self):
+ return [
+
+ # General
+ {'section': 'rattail',
+ 'option': 'members.key_field'},
+ {'section': 'rattail',
+ 'option': 'members.key_label'},
+ ]
+
def defaults(config, **kwargs):
base = globals()
diff --git a/tailbone/views/people.py b/tailbone/views/people.py
index 0a471f46..dc75b8aa 100644
--- a/tailbone/views/people.py
+++ b/tailbone/views/people.py
@@ -545,12 +545,14 @@ class PersonView(MasterView):
return context
def get_context_customers(self, person):
+ key = self.get_customer_key_field()
data = []
for cp in person._customers:
customer = cp.customer
data.append({
'uuid': customer.uuid,
'ordinal': cp.ordinal,
+ '_key': getattr(customer, key),
'id': customer.id,
'number': customer.number,
'name': customer.name,
@@ -582,8 +584,10 @@ class PersonView(MasterView):
profile_url = self.request.route_url('people.view_profile',
uuid=member.person_uuid)
+ key = self.get_member_key_field()
return {
'uuid': member.uuid,
+ '_key': getattr(member, key),
'number': member.number,
'id': member.id,
'active': member.active,