diff --git a/tailbone/static/themes/falafel/css/layout.css b/tailbone/static/themes/falafel/css/layout.css index db3ebaf8..b0fd0cc9 100644 --- a/tailbone/static/themes/falafel/css/layout.css +++ b/tailbone/static/themes/falafel/css/layout.css @@ -93,6 +93,10 @@ header .level .theme-picker { * "object helper" panel ******************************/ +.object-helpers .panel-heading { + white-space: nowrap; +} + .object-helpers a { white-space: nowrap; } diff --git a/tailbone/templates/master/view.mako b/tailbone/templates/master/view.mako index 7b0b2de5..f8be8f5b 100644 --- a/tailbone/templates/master/view.mako +++ b/tailbone/templates/master/view.mako @@ -47,6 +47,35 @@ ${instance_title} +<%def name="object_helpers()"> + ${parent.object_helpers()} + ${self.render_xref_helper()} + + +<%def name="render_xref_helper()"> + % if xref_buttons or xref_links: + % if use_buefy: + + % else: +
+

Cross-Reference

+
+ % for link in xref_links: + ${link} + % endfor +
+
+ % endif + % endif + + <%def name="context_menu_items()"> ## TODO: either make this configurable, or just lose it. ## nobody seems to ever find it useful in practice. diff --git a/tailbone/views/master.py b/tailbone/views/master.py index b03ebcf8..c782b52e 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -2502,8 +2502,23 @@ class MasterView(View): """ Method stub, so subclass can always invoke super() for it. """ + obj = kwargs['instance'] + kwargs['xref_buttons'] = self.get_xref_buttons(obj) + kwargs['xref_links'] = self.get_xref_links(obj) return kwargs + def get_xref_buttons(self, obj): + buttons = [] + for supp in self.iter_view_supplements(): + buttons.extend(supp.get_xref_buttons(obj)) + return buttons + + def get_xref_links(self, obj): + links = [] + for supp in self.iter_view_supplements(): + links.extend(supp.get_xref_links(obj)) + return links + def template_kwargs_edit(self, **kwargs): """ Method stub, so subclass can always invoke super() for it. @@ -5062,10 +5077,8 @@ class ViewSupplement(object): def __init__(self, master): self.master = master - - @property - def model(self): - return self.master.model + self.request = master.request + self.model = master.model def get_grid_query(self, query): """ @@ -5111,6 +5124,12 @@ class ViewSupplement(object): renderers, default values etc. for them. """ + def get_xref_buttons(self, obj): + return [] + + def get_xref_links(self, obj): + return [] + def get_version_child_classes(self): """ Return a list of additional "version child classes" which are diff --git a/tailbone/views/products.py b/tailbone/views/products.py index ab9f55c6..8357c895 100644 --- a/tailbone/views/products.py +++ b/tailbone/views/products.py @@ -187,27 +187,12 @@ class ProductView(MasterView): self.handler = self.products_handler def query(self, session): - user = self.request.user - if user and user not in session: - user = session.merge(user) + query = super(ProductView, self).query(session) - query = session.query(model.Product) - # TODO: was this old `has_permission()` call here for a reason..? hope not.. - # if not auth.has_permission(session, user, 'products.view_deleted'): - if not self.request.has_perm('products.view_deleted'): + if not self.has_perm('view_deleted'): query = query.filter(model.Product.deleted == False) - # TODO: This used to be a good idea I thought...but in dev it didn't - # seem to make much difference, except with a larger (50K) data set it - # totally bogged things down instead of helping... - # query = query\ - # .options(orm.joinedload(model.Product.brand))\ - # .options(orm.joinedload(model.Product.department))\ - # .options(orm.joinedload(model.Product.subdepartment))\ - # .options(orm.joinedload(model.Product.regular_price))\ - # .options(orm.joinedload(model.Product.current_price))\ - # .options(orm.joinedload(model.Product.vendor)) - + # TODO: surely this is not always needed query = query.outerjoin(model.ProductInventory) return query @@ -1190,6 +1175,7 @@ class ProductView(MasterView): return jsdata def template_kwargs_view(self, **kwargs): + kwargs = super(ProductView, self).template_kwargs_view(**kwargs) product = kwargs['instance'] use_buefy = self.get_use_buefy()