OMG a ridiculous commit to overhaul import handler config etc.
- add `MasterView.configurable` concept, `/configure.mako` template - add new master view for DataSync Threads (needs content) - tweak view config for DataSync Changes accordingly - update the Configure DataSync page per `configurable` concept - add new Configure Import/Export page, per `configurable` - add basic views for Raw Permissions
This commit is contained in:
parent
282185c5af
commit
cc4b2278e7
10 changed files with 735 additions and 238 deletions
|
@ -114,6 +114,7 @@ class MasterView(View):
|
|||
execute_progress_initial_msg = None
|
||||
supports_prev_next = False
|
||||
supports_import_batch_from_file = False
|
||||
configurable = False
|
||||
|
||||
# set to True to add "View *global* Objects" permission, and
|
||||
# expose / leverage the ``local_only`` object flag
|
||||
|
@ -2032,6 +2033,16 @@ class MasterView(View):
|
|||
"""
|
||||
return getattr(cls, 'index_title', cls.get_model_title_plural())
|
||||
|
||||
@classmethod
|
||||
def get_config_title(cls):
|
||||
"""
|
||||
Returns the view's "config title".
|
||||
"""
|
||||
if hasattr(cls, 'config_title'):
|
||||
return cls.config_title
|
||||
|
||||
return cls.get_model_title_plural()
|
||||
|
||||
def get_action_url(self, action, instance, **kwargs):
|
||||
"""
|
||||
Generate a URL for the given action on the given instance
|
||||
|
@ -2075,6 +2086,7 @@ class MasterView(View):
|
|||
'permission_prefix': self.get_permission_prefix(),
|
||||
'index_title': self.get_index_title(),
|
||||
'index_url': self.get_index_url(),
|
||||
'config_title': self.get_config_title(),
|
||||
'action_url': self.get_action_url,
|
||||
'grid_index': self.grid_index,
|
||||
'help_url': self.get_help_url(),
|
||||
|
@ -3982,7 +3994,46 @@ class MasterView(View):
|
|||
return diffs.Diff(old_data, new_data, **kwargs)
|
||||
|
||||
##############################
|
||||
# Config Stuff
|
||||
# Configuration Views
|
||||
##############################
|
||||
|
||||
def configure(self):
|
||||
"""
|
||||
Generic view for configuring some aspect of the software.
|
||||
"""
|
||||
if self.request.method == 'POST':
|
||||
if self.request.POST.get('remove_settings'):
|
||||
self.configure_remove_settings()
|
||||
self.request.session.flash("Settings have been removed.")
|
||||
return self.redirect(self.request.current_route_url())
|
||||
else:
|
||||
data = self.request.json_body
|
||||
settings = self.configure_gather_settings(data)
|
||||
self.configure_remove_settings()
|
||||
self.configure_save_settings(settings)
|
||||
self.request.session.flash("Settings have been saved.")
|
||||
return self.json_response({'success': True})
|
||||
|
||||
context = self.configure_get_context()
|
||||
return self.render_to_response('configure', context)
|
||||
|
||||
def configure_get_context(self):
|
||||
return {}
|
||||
|
||||
def configure_gather_settings(self, data):
|
||||
return []
|
||||
|
||||
def configure_remove_settings(self):
|
||||
pass
|
||||
|
||||
def configure_save_settings(self, settings):
|
||||
model = self.model
|
||||
for setting in settings:
|
||||
self.Session.add(model.Setting(name=setting['name'],
|
||||
value=setting['value']))
|
||||
|
||||
##############################
|
||||
# Pyramid View Config
|
||||
##############################
|
||||
|
||||
@classmethod
|
||||
|
@ -4025,6 +4076,7 @@ class MasterView(View):
|
|||
model_key = cls.get_model_key()
|
||||
model_title = cls.get_model_title()
|
||||
model_title_plural = cls.get_model_title_plural()
|
||||
config_title = cls.get_config_title()
|
||||
if cls.has_rows:
|
||||
row_model_title = cls.get_row_model_title()
|
||||
|
||||
|
@ -4087,6 +4139,17 @@ class MasterView(View):
|
|||
config.add_view(cls, attr='download_results_rows', route_name='{}.download_results_rows'.format(route_prefix),
|
||||
permission='{}.download_results_rows'.format(permission_prefix))
|
||||
|
||||
# configure
|
||||
if cls.configurable:
|
||||
config.add_tailbone_permission(permission_prefix,
|
||||
'{}.configure'.format(permission_prefix),
|
||||
label="Configure {}".format(config_title))
|
||||
config.add_route('{}.configure'.format(route_prefix),
|
||||
'{}/configure'.format(url_prefix))
|
||||
config.add_view(cls, attr='configure',
|
||||
route_name='{}.configure'.format(route_prefix),
|
||||
permission='{}.configure'.format(permission_prefix))
|
||||
|
||||
# quickie (search)
|
||||
if cls.supports_quickie_search:
|
||||
config.add_tailbone_permission(permission_prefix, '{}.quickie'.format(permission_prefix),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue