From 05ed481007604079612aa4b0f1f3bb8d4d35a6e5 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 10 Sep 2019 18:02:50 +0200 Subject: Locks: prevent edit actions --- archaeological_context_records/forms.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'archaeological_context_records/forms.py') 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): -- cgit v1.2.3