Disable view mode for settings table

Create/edit/delete are all that's needed there.
This commit is contained in:
Lance Edgar 2016-08-11 23:59:40 -05:00
parent 41ca3859f6
commit 457407fbcf
2 changed files with 18 additions and 1 deletions

View file

@ -647,12 +647,15 @@ class MasterView(View):
if self.creating:
kwargs.setdefault('cancel_url', self.get_index_url())
else:
kwargs.setdefault('cancel_url', self.get_action_url('view', instance))
kwargs.setdefault('cancel_url', self.get_cancel_url(instance))
factory = kwargs.pop('factory', forms.AlchemyForm)
form = factory(self.request, fieldset, **kwargs)
form.readonly = self.viewing
return form
def get_cancel_url(self, instance):
return self.get_action_url('view', instance)
def save_form(self, form):
form.save()

View file

@ -36,6 +36,7 @@ class SettingsView(MasterView):
Master view for the settings model.
"""
model_class = model.Setting
viewable = False
def configure_grid(self, g):
g.filters['name'].default_active = True
@ -48,6 +49,19 @@ class SettingsView(MasterView):
],
readonly=True)
def get_grid_actions(self):
# TODO: bit of a hack, but gets the job done
return self.get_more_actions(), []
def get_cancel_url(self, setting):
return self.get_index_url()
def redirect_after_create(self, setting):
return self.redirect(self.get_index_url())
def redirect_after_edit(self, setting):
return self.redirect(self.get_index_url())
def configure_fieldset(self, fs):
fs.configure(
include=[