From 679dce4ed88dc3d85f4b92209b1c88520097b40d Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 18 Sep 2016 17:14:57 -0500 Subject: [PATCH] Add "just in time" editable instance check for master view --- tailbone/views/master.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tailbone/views/master.py b/tailbone/views/master.py index 06f8f34d..7521b9d0 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -329,6 +329,12 @@ class MasterView(View): """ self.editing = True 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) if self.request.method == 'POST': @@ -364,7 +370,7 @@ class MasterView(View): if not self.deletable_instance(instance): 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)) form = self.make_form(instance)