Let master view control context menu items for page
that really does not belong in the template if we can help it. some templates still define context menu items but can hopefully phase those out over time
This commit is contained in:
parent
254df6d6f2
commit
fa25857680
|
@ -1,13 +1,6 @@
|
||||||
## -*- coding: utf-8; -*-
|
## -*- coding: utf-8; -*-
|
||||||
<%inherit file="/master/index.mako" />
|
<%inherit file="/master/index.mako" />
|
||||||
|
|
||||||
<%def name="context_menu_items()">
|
|
||||||
${parent.context_menu_items()}
|
|
||||||
% if request.has_perm('datasync.status'):
|
|
||||||
<li>${h.link_to("View DataSync Status", url('datasync.status'))}</li>
|
|
||||||
% endif
|
|
||||||
</%def>
|
|
||||||
|
|
||||||
<%def name="grid_tools()">
|
<%def name="grid_tools()">
|
||||||
${parent.grid_tools()}
|
${parent.grid_tools()}
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,6 @@
|
||||||
|
|
||||||
<%def name="content_title()"></%def>
|
<%def name="content_title()"></%def>
|
||||||
|
|
||||||
<%def name="context_menu_items()">
|
|
||||||
${parent.context_menu_items()}
|
|
||||||
% if request.has_perm('datasync_changes.list'):
|
|
||||||
<li>${h.link_to("View DataSync Changes", url('datasyncchanges'))}</li>
|
|
||||||
% endif
|
|
||||||
</%def>
|
|
||||||
|
|
||||||
<%def name="page_content()">
|
<%def name="page_content()">
|
||||||
% if expose_websockets and not supervisor_error:
|
% if expose_websockets and not supervisor_error:
|
||||||
<b-notification type="is-warning"
|
<b-notification type="is-warning"
|
||||||
|
|
|
@ -12,20 +12,6 @@
|
||||||
|
|
||||||
<%def name="content_title()"></%def>
|
<%def name="content_title()"></%def>
|
||||||
|
|
||||||
<%def name="context_menu_items()">
|
|
||||||
% if master.results_downloadable_csv and request.has_perm('{}.results_csv'.format(permission_prefix)):
|
|
||||||
<li>${h.link_to("Download results as CSV", url('{}.results_csv'.format(route_prefix)))}</li>
|
|
||||||
% endif
|
|
||||||
% if master.results_downloadable_xlsx and request.has_perm('{}.results_xlsx'.format(permission_prefix)):
|
|
||||||
<li>${h.link_to("Download results as XLSX", url('{}.results_xlsx'.format(route_prefix)))}</li>
|
|
||||||
% endif
|
|
||||||
% if master.has_input_file_templates and master.has_perm('create'):
|
|
||||||
% for template in input_file_templates.values():
|
|
||||||
<li>${h.link_to("Download {} Template".format(template['label']), template['effective_url'])}</li>
|
|
||||||
% endfor
|
|
||||||
% endif
|
|
||||||
</%def>
|
|
||||||
|
|
||||||
<%def name="grid_tools()">
|
<%def name="grid_tools()">
|
||||||
|
|
||||||
## grid totals
|
## grid totals
|
||||||
|
|
|
@ -51,12 +51,6 @@
|
||||||
% endif
|
% endif
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="context_menu_items()">
|
|
||||||
## TODO: either make this configurable, or just lose it.
|
|
||||||
## nobody seems to ever find it useful in practice.
|
|
||||||
## <li>${h.link_to("Permalink for this {}".format(model_title), action_url('view', instance))}</li>
|
|
||||||
</%def>
|
|
||||||
|
|
||||||
<%def name="render_row_grid_tools()">
|
<%def name="render_row_grid_tools()">
|
||||||
${rows_grid_tools}
|
${rows_grid_tools}
|
||||||
% if master.rows_downloadable_xlsx and master.has_perm('row_results_xlsx'):
|
% if master.rows_downloadable_xlsx and master.has_perm('row_results_xlsx'):
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
## -*- coding: utf-8; -*-
|
## -*- coding: utf-8; -*-
|
||||||
<%inherit file="/base.mako" />
|
<%inherit file="/base.mako" />
|
||||||
|
|
||||||
<%def name="context_menu_items()"></%def>
|
<%def name="context_menu_items()">
|
||||||
|
% if context_menu_list_items is not Undefined:
|
||||||
|
% for item in context_menu_list_items:
|
||||||
|
<li>${item}</li>
|
||||||
|
% endfor
|
||||||
|
% endif
|
||||||
|
</%def>
|
||||||
|
|
||||||
<%def name="page_content()"></%def>
|
<%def name="page_content()"></%def>
|
||||||
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
## -*- coding: utf-8; -*-
|
|
||||||
<%inherit file="/master/index.mako" />
|
|
||||||
|
|
||||||
<%def name="context_menu_items()">
|
|
||||||
${parent.context_menu_items()}
|
|
||||||
% if master.has_perm('rollover'):
|
|
||||||
<li>${h.link_to("Yearly Rollover", url('{}.rollover'.format(route_prefix)))}</li>
|
|
||||||
% endif
|
|
||||||
</%def>
|
|
||||||
|
|
||||||
|
|
||||||
${parent.body()}
|
|
|
@ -14,13 +14,6 @@
|
||||||
% endif
|
% endif
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="context_menu_items()">
|
|
||||||
${parent.context_menu_items()}
|
|
||||||
% if master.has_perm('preferences'):
|
|
||||||
<li>${h.link_to("Edit User Preferences", action_url('preferences', instance))}</li>
|
|
||||||
% endif
|
|
||||||
</%def>
|
|
||||||
|
|
||||||
<%def name="render_this_page()">
|
<%def name="render_this_page()">
|
||||||
${parent.render_this_page()}
|
${parent.render_this_page()}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ from rattail.db.model import DataSyncChange
|
||||||
from rattail.datasync.util import purge_datasync_settings
|
from rattail.datasync.util import purge_datasync_settings
|
||||||
from rattail.util import simple_error
|
from rattail.util import simple_error
|
||||||
|
|
||||||
|
from webhelpers2.html import tags
|
||||||
|
|
||||||
from tailbone.views import MasterView
|
from tailbone.views import MasterView
|
||||||
from tailbone.util import raw_datetime
|
from tailbone.util import raw_datetime
|
||||||
from tailbone.config import should_expose_websockets
|
from tailbone.config import should_expose_websockets
|
||||||
|
@ -75,6 +77,16 @@ class DataSyncThreadView(MasterView):
|
||||||
app = self.get_rattail_app()
|
app = self.get_rattail_app()
|
||||||
self.datasync_handler = app.get_datasync_handler()
|
self.datasync_handler = app.get_datasync_handler()
|
||||||
|
|
||||||
|
def get_context_menu_items(self, thread=None):
|
||||||
|
items = super().get_context_menu_items(thread)
|
||||||
|
|
||||||
|
# nb. just one view here, no need to check if listing etc.
|
||||||
|
if self.request.has_perm('datasync_changes.list'):
|
||||||
|
url = self.request.route_url('datasyncchanges')
|
||||||
|
items.append(tags.link_to("View DataSync Changes", url))
|
||||||
|
|
||||||
|
return items
|
||||||
|
|
||||||
def status(self):
|
def status(self):
|
||||||
"""
|
"""
|
||||||
View to list/filter/sort the model data.
|
View to list/filter/sort the model data.
|
||||||
|
@ -389,6 +401,17 @@ class DataSyncChangeView(MasterView):
|
||||||
'consumer',
|
'consumer',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def get_context_menu_items(self, change=None):
|
||||||
|
items = super().get_context_menu_items(change)
|
||||||
|
|
||||||
|
if self.listing:
|
||||||
|
|
||||||
|
if self.request.has_perm('datasync.status'):
|
||||||
|
url = self.request.route_url('datasync.status')
|
||||||
|
items.append(tags.link_to("View DataSync Status", url))
|
||||||
|
|
||||||
|
return items
|
||||||
|
|
||||||
def configure_grid(self, g):
|
def configure_grid(self, g):
|
||||||
super().configure_grid(g)
|
super().configure_grid(g)
|
||||||
|
|
||||||
|
|
|
@ -2807,6 +2807,13 @@ class MasterView(View):
|
||||||
kwargs['db_picker_options'] = [tags.Option(k, value=k) for k in engines]
|
kwargs['db_picker_options'] = [tags.Option(k, value=k) for k in engines]
|
||||||
kwargs['db_picker_selected'] = selected
|
kwargs['db_picker_selected'] = selected
|
||||||
|
|
||||||
|
# context menu
|
||||||
|
obj = kwargs.get('instance')
|
||||||
|
items = self.get_context_menu_items(obj)
|
||||||
|
for supp in self.iter_view_supplements():
|
||||||
|
items.extend(supp.get_context_menu_items(obj) or [])
|
||||||
|
kwargs['context_menu_list_items'] = items
|
||||||
|
|
||||||
# add info for downloadable input file templates, if any
|
# add info for downloadable input file templates, if any
|
||||||
if self.has_input_file_templates:
|
if self.has_input_file_templates:
|
||||||
templates = self.normalize_input_file_templates()
|
templates = self.normalize_input_file_templates()
|
||||||
|
@ -2914,6 +2921,35 @@ class MasterView(View):
|
||||||
kwargs['xref_links'] = self.get_xref_links(obj)
|
kwargs['xref_links'] = self.get_xref_links(obj)
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
def get_context_menu_items(self, obj=None):
|
||||||
|
items = []
|
||||||
|
route_prefix = self.get_route_prefix()
|
||||||
|
|
||||||
|
if self.listing:
|
||||||
|
|
||||||
|
if self.results_downloadable_csv and self.has_perm('results_csv'):
|
||||||
|
url = self.request.route_url(f'{route_prefix}.results_csv')
|
||||||
|
items.append(tags.link_to("Download results as CSV", url))
|
||||||
|
|
||||||
|
if self.results_downloadable_xlsx and self.has_perm('results_xlsx'):
|
||||||
|
url = self.request.route_url(f'{route_prefix}.results_xlsx')
|
||||||
|
items.append(tags.link_to("Download results as XLSX", url))
|
||||||
|
|
||||||
|
if self.has_input_file_templates and self.has_perm('create'):
|
||||||
|
templates = self.normalize_input_file_templates()
|
||||||
|
for template in templates:
|
||||||
|
items.append(tags.link_to(f"Download {template['label']} Template",
|
||||||
|
template['effective_url']))
|
||||||
|
|
||||||
|
# if self.viewing:
|
||||||
|
|
||||||
|
# # # TODO: either make this configurable, or just lose it.
|
||||||
|
# # # nobody seems to ever find it useful in practice.
|
||||||
|
# # url = self.get_action_url('view', instance)
|
||||||
|
# # items.append(tags.link_to(f"Permalink for this {model_title}", url))
|
||||||
|
|
||||||
|
return items
|
||||||
|
|
||||||
def get_xref_buttons(self, obj):
|
def get_xref_buttons(self, obj):
|
||||||
buttons = []
|
buttons = []
|
||||||
for supp in self.iter_view_supplements():
|
for supp in self.iter_view_supplements():
|
||||||
|
@ -5914,6 +5950,9 @@ class ViewSupplement(object):
|
||||||
def get_xref_links(self, obj):
|
def get_xref_links(self, obj):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
def get_context_menu_items(self, obj):
|
||||||
|
return []
|
||||||
|
|
||||||
def get_version_child_classes(self):
|
def get_version_child_classes(self):
|
||||||
"""
|
"""
|
||||||
Return a list of additional "version child classes" which are
|
Return a list of additional "version child classes" which are
|
||||||
|
|
|
@ -164,6 +164,18 @@ class TransactionView(MasterView):
|
||||||
|
|
||||||
return TrainwreckSession()
|
return TrainwreckSession()
|
||||||
|
|
||||||
|
def get_context_menu_items(self, txn=None):
|
||||||
|
items = super().get_context_menu_items(txn)
|
||||||
|
route_prefix = self.get_route_prefix()
|
||||||
|
|
||||||
|
if self.listing:
|
||||||
|
|
||||||
|
if self.has_perm('rollover'):
|
||||||
|
url = self.request.route_url(f'{route_prefix}.rollover')
|
||||||
|
items.append(tags.link_to("Yearly Rollover", url))
|
||||||
|
|
||||||
|
return items
|
||||||
|
|
||||||
def configure_grid(self, g):
|
def configure_grid(self, g):
|
||||||
super().configure_grid(g)
|
super().configure_grid(g)
|
||||||
app = self.get_rattail_app()
|
app = self.get_rattail_app()
|
||||||
|
|
|
@ -92,6 +92,17 @@ class UserView(PrincipalMasterView):
|
||||||
self.auth_handler = app.get_auth_handler()
|
self.auth_handler = app.get_auth_handler()
|
||||||
self.merge_handler = self.auth_handler
|
self.merge_handler = self.auth_handler
|
||||||
|
|
||||||
|
def get_context_menu_items(self, user=None):
|
||||||
|
items = super().get_context_menu_items(user)
|
||||||
|
|
||||||
|
if self.viewing:
|
||||||
|
|
||||||
|
if self.has_perm('preferences'):
|
||||||
|
url = self.get_action_url('preferences', user)
|
||||||
|
items.append(tags.link_to("Edit User Preferences", url))
|
||||||
|
|
||||||
|
return items
|
||||||
|
|
||||||
def query(self, session):
|
def query(self, session):
|
||||||
query = super().query(session)
|
query = super().query(session)
|
||||||
model = self.model
|
model = self.model
|
||||||
|
|
Loading…
Reference in a new issue