Add common logic for xref buttons, links when viewing object
about dang time for this..probaby needs improvement but a good start
This commit is contained in:
parent
2278082a4d
commit
273fa7eb55
4 changed files with 60 additions and 22 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue