summaryrefslogtreecommitdiff
path: root/archaeological_files/forms.py
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_files/forms.py
parent389f86b06d5f6129614cb312c7034cdc4bb1b684 (diff)
downloadIshtar-0c185f1abbe9abe0d977e1b7d1d3f0440b8d6371.tar.bz2
Ishtar-0c185f1abbe9abe0d977e1b7d1d3f0440b8d6371.zip
Locks: prevent edit actions
Diffstat (limited to 'archaeological_files/forms.py')
-rw-r--r--archaeological_files/forms.py9
1 files changed, 8 insertions, 1 deletions
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")),