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_files/forms.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'archaeological_files/forms.py') diff --git a/archaeological_files/forms.py b/archaeological_files/forms.py index 8f18de29e..640e2cab1 100644 --- a/archaeological_files/forms.py +++ b/archaeological_files/forms.py @@ -140,7 +140,14 @@ class FileFormSelection(forms.Form): cleaned_data = self.cleaned_data if 'pk' not in cleaned_data or not cleaned_data['pk']: raise forms.ValidationError(_(u"You should select a file.")) - return cleaned_data + pk = self.cleaned_data["pk"] + try: + file = models.File.objects.get(pk=pk) + except models.File.DoesNotExist: + raise forms.ValidationError(_("Invalid selection.")) + if file.locked: + raise forms.ValidationError(_("This file is locked for edition.")) + return self.cleaned_data DATE_SOURCE = (('creation', _(u"Creation date")), -- cgit v1.2.3