diff options
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 |
commit | 05ed481007604079612aa4b0f1f3bb8d4d35a6e5 (patch) | |
tree | f84171501c3d98df394c94fcc6d32cc3dd5c6539 /archaeological_operations/forms.py | |
parent | 1d5254416b11ef1010d5ac31f2a53677254c6497 (diff) | |
download | Ishtar-05ed481007604079612aa4b0f1f3bb8d4d35a6e5.tar.bz2 Ishtar-05ed481007604079612aa4b0f1f3bb8d4d35a6e5.zip |
Locks: prevent edit actions
Diffstat (limited to 'archaeological_operations/forms.py')
-rw-r--r-- | archaeological_operations/forms.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index 5cc544171..1e12c3614 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -616,7 +616,15 @@ class OperationFormSelection(CustomFormSearch): cleaned_data = self.cleaned_data if 'pk' not in cleaned_data or not cleaned_data['pk']: raise forms.ValidationError(_(u"You should select an operation.")) - return cleaned_data + pk = self.cleaned_data["pk"] + try: + item = models.Operation.objects.get(pk=pk) + except models.Operation.DoesNotExist: + raise forms.ValidationError(_("Invalid selection.")) + if item.locked: + raise forms.ValidationError(_("This operation is locked for " + "edition.")) + return self.cleaned_data class OperationCodeInput(forms.TextInput): @@ -1388,7 +1396,15 @@ class SiteFormSelection(IshtarForm): cleaned_data = self.cleaned_data if 'pk' not in cleaned_data or not cleaned_data['pk']: raise forms.ValidationError(_(u"You should select an item.")) - return cleaned_data + pk = self.cleaned_data["pk"] + try: + item = models.ArchaeologicalSite.objects.get(pk=pk) + except models.ArchaeologicalSite.DoesNotExist: + raise forms.ValidationError(_("Invalid selection.")) + if item.locked: + raise forms.ValidationError(_("This site is locked for " + "edition.")) + return self.cleaned_data class SiteForm(CustomForm, ManageOldType): |