Add "just in time" editable instance check for master view

This commit is contained in:
Lance Edgar 2016-09-18 17:14:57 -05:00
parent 94a7a15e6d
commit 679dce4ed8

View file

@ -329,6 +329,12 @@ class MasterView(View):
""" """
self.editing = True self.editing = True
instance = self.get_instance() instance = self.get_instance()
if not self.editable_instance(instance):
self.request.session.flash("Edit is not permitted for {}: {}".format(
self.get_model_title(), instance_title), 'error')
return self.redirect(self.get_action_url('view', instance))
form = self.make_form(instance) form = self.make_form(instance)
if self.request.method == 'POST': if self.request.method == 'POST':
@ -364,7 +370,7 @@ class MasterView(View):
if not self.deletable_instance(instance): if not self.deletable_instance(instance):
self.request.session.flash("Deletion is not permitted for {}: {}".format( self.request.session.flash("Deletion is not permitted for {}: {}".format(
self.get_model_title(), instance_title)) self.get_model_title(), instance_title), 'error')
return self.redirect(self.get_action_url('view', instance)) return self.redirect(self.get_action_url('view', instance))
form = self.make_form(instance) form = self.make_form(instance)