Add auto-links for most grids

probably still missing some yet?
This commit is contained in:
Lance Edgar 2017-08-03 19:16:53 -05:00
parent bd3d948bf4
commit ea7eb47551
18 changed files with 49 additions and 1 deletions

View file

@ -977,7 +977,7 @@ class CustomWebhelpersGrid(webhelpers2_grid.Grid):
if hasattr(record, 'uuid'):
attrs['data_uuid'] = record.uuid
return HTML.tag('li', tags.link_to(value, url), **attrs)
if self.linked_columns and column_name in self.linked_columns:
if self.linked_columns and column_name in self.linked_columns and value:
url = self.url_generator(record, i)
value = tags.link_to(value, url)
class_name = 'c{} {}'.format(column_number, column_name)

View file

@ -87,6 +87,9 @@ class EmailBouncesView(MasterView):
g.set_label('bounce_recipient_address', "Bounced To")
g.set_label('intended_recipient_address', "Intended For")
g.set_link('bounced')
g.set_link('intended_recipient_address')
def configure_fieldset(self, fs):
bounce = fs.model
handler = self.get_handler(bounce)

View file

@ -43,9 +43,11 @@ class BrandsView(MasterView):
]
def configure_grid(self, g):
super(BrandsView, self).configure_grid(g)
g.filters['name'].default_active = True
g.filters['name'].default_verb = 'contains'
g.default_sortkey = 'name'
g.set_link('name')
def configure_fieldset(self, fs):
fs.configure(

View file

@ -52,6 +52,9 @@ class CategoriesView(MasterView):
g.filters['name'].default_active = True
g.filters['name'].default_verb = 'contains'
g.default_sortkey = 'code'
g.set_link('code')
g.set_link('number')
g.set_link('name')
def configure_fieldset(self, fs):
fs.configure(

View file

@ -85,6 +85,8 @@ class CustomersView(MasterView):
g.set_label('phone', "Phone Number")
g.set_label('email', "Email Address")
g.set_link('id')
g.set_link('number')
g.set_link('name')
def get_mobile_data(self, session=None):

View file

@ -51,6 +51,8 @@ class DepartmentsView(MasterView):
g.filters['name'].default_active = True
g.filters['name'].default_verb = 'contains'
g.default_sortkey = 'number'
g.set_link('number')
g.set_link('name')
def configure_fieldset(self, fs):
fs.configure(

View file

@ -52,6 +52,8 @@ class DepositLinksView(MasterView):
g.filters['description'].default_verb = 'contains'
g.default_sortkey = 'code'
g.set_type('amount', 'currency')
g.set_link('code')
g.set_link('description')
def configure_fieldset(self, fs):
fs.configure(

View file

@ -77,6 +77,8 @@ class ExportMasterView(MasterView):
g.set_label('id', "ID")
g.set_label('created_by', "Created by")
g.set_link('id')
def render_id(self, export, column):
return export.id_str

View file

@ -55,6 +55,8 @@ class ProfilesView(MasterView):
super(ProfilesView, self).configure_grid(g)
g.default_sortkey = 'ordinal'
g.set_type('visible', 'boolean')
g.set_link('code')
g.set_link('description')
def configure_fieldset(self, fs):
fs.printer_spec.set(renderer=forms.renderers.StrippedTextFieldRenderer)

View file

@ -104,6 +104,8 @@ class PeopleView(MasterView):
g.set_label('customer_id', "Customer ID")
g.set_link('display_name')
g.set_link('first_name')
g.set_link('last_name')
def get_instance(self):
# TODO: I don't recall why this fallback check for a vendor contact

View file

@ -49,6 +49,8 @@ class ReportCodesView(MasterView):
g.filters['name'].default_active = True
g.filters['name'].default_verb = 'contains'
g.default_sortkey = 'code'
g.set_link('code')
g.set_link('name')
def configure_fieldset(self, fs):
fs.configure(

View file

@ -212,6 +212,10 @@ class ReportOutputView(ExportMasterView):
'created_by',
]
def configure_grid(self, g):
super(ReportOutputView, self).configure_grid(g)
g.set_link('filename')
def _preconfigure_fieldset(self, fs):
super(ReportOutputView, self)._preconfigure_fieldset(fs)
if self.viewing:

View file

@ -51,6 +51,8 @@ class TaxesView(MasterView):
g.filters['description'].default_active = True
g.filters['description'].default_verb = 'contains'
g.default_sortkey = 'code'
g.set_link('code')
g.set_link('description')
def configure_fieldset(self, fs):
fs.configure(

View file

@ -91,6 +91,10 @@ class TempmonClientView(MasterView):
g.set_label('config_key', "Key")
g.set_link('config_key')
g.set_link('hostname')
g.set_link('location')
def _preconfigure_fieldset(self, fs):
fs.config_key.set(validate=unique_config_key)
fs.probes.set(renderer=ProbesFieldRenderer)

View file

@ -79,6 +79,10 @@ class TempmonProbeView(MasterView):
g.set_label('config_key', "Key")
g.set_link('client')
g.set_link('config_key')
g.set_link('description')
def _preconfigure_fieldset(self, fs):
fs.config_key.set(validate=unique_config_key)
fs.client.set(label="TempMon Client", renderer=ClientFieldRenderer)

View file

@ -81,6 +81,9 @@ class TempmonReadingView(MasterView):
g.set_renderer('client_key', self.render_client_key)
g.set_renderer('client_host', self.render_client_host)
g.set_link('probe')
g.set_link('taken')
def render_client_key(self, reading, column):
return reading.client.config_key

View file

@ -92,6 +92,12 @@ class TransactionView(MasterView):
g.set_label('receipt_number', "Receipt No.")
g.set_label('customer_id', "Customer ID")
g.set_link('start_time')
g.set_link('receipt_number')
g.set_link('customer_id')
g.set_link('customer_name')
g.set_link('total')
def _preconfigure_fieldset(self, fs):
fs.system.set(renderer=forms.renderers.EnumFieldRenderer(self.enum.TRAINWRECK_SYSTEM))
fs.terminal_id.set(label="Terminal")

View file

@ -59,6 +59,9 @@ class VendorsView(MasterView):
g.set_label('phone', "Phone Number")
g.set_label('email', "Email Address")
g.set_link('id')
g.set_link('name')
def configure_fieldset(self, fs):
fs.append(forms.AssociationProxyField('contact'))
fs.configure(