summaryrefslogtreecommitdiff
path: root/archaeological_context_records
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-09-10 18:02:50 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-09-10 18:02:50 +0200
commit0c185f1abbe9abe0d977e1b7d1d3f0440b8d6371 (patch)
treef84171501c3d98df394c94fcc6d32cc3dd5c6539 /archaeological_context_records
parent389f86b06d5f6129614cb312c7034cdc4bb1b684 (diff)
downloadIshtar-0c185f1abbe9abe0d977e1b7d1d3f0440b8d6371.tar.bz2
Ishtar-0c185f1abbe9abe0d977e1b7d1d3f0440b8d6371.zip
Locks: prevent edit actions
Diffstat (limited to 'archaeological_context_records')
-rw-r--r--archaeological_context_records/forms.py10
-rw-r--r--archaeological_context_records/views.py7
2 files changed, 16 insertions, 1 deletions
diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py
index 6bbc3099c..375943c9c 100644
--- a/archaeological_context_records/forms.py
+++ b/archaeological_context_records/forms.py
@@ -133,7 +133,15 @@ class RecordFormSelection(CustomFormSearch):
if 'pk' not in cleaned_data or not cleaned_data['pk']:
raise forms.ValidationError(_(u"You should at least select one "
u"context record."))
- return cleaned_data
+ pk = self.cleaned_data["pk"]
+ try:
+ cr = models.ContextRecord.objects.get(pk=pk)
+ except models.ContextRecord.DoesNotExist:
+ raise forms.ValidationError(_("Invalid selection."))
+ if cr.locked:
+ raise forms.ValidationError(_("This context record is locked for "
+ "edition."))
+ return self.cleaned_data
class RecordFormGeneral(CustomForm, ManageOldType):
diff --git a/archaeological_context_records/views.py b/archaeological_context_records/views.py
index fe77150f6..794cb5592 100644
--- a/archaeological_context_records/views.py
+++ b/archaeological_context_records/views.py
@@ -144,6 +144,13 @@ def record_modify(request, pk):
)
return HttpResponseRedirect("/")
+ q = models.ContextRecord.objects.filter(pk=pk)
+ if not q.count():
+ raise Http404()
+ cr = q.all()[0]
+ if cr.locked:
+ raise Http404()
+
wizards.RecordModifWizard.session_set_value(
request, 'selec-record_modification', 'pk', pk, reset=True)
return redirect(reverse('record_modification',