summaryrefslogtreecommitdiff
path: root/archaeological_finds/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-05-18 20:03:04 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-05-18 20:03:04 +0200
commit3a81d40b69a7f86731d45ac73188eed63fc14c77 (patch)
tree9beb8f0accd7700838e31d25fe79b1d02fe4d763 /archaeological_finds/forms.py
parentb114fa6d0b42a0ba2bc1a1988c1714f48d6a5474 (diff)
downloadIshtar-3a81d40b69a7f86731d45ac73188eed63fc14c77.tar.bz2
Ishtar-3a81d40b69a7f86731d45ac73188eed63fc14c77.zip
Basket: create a new basket
Diffstat (limited to 'archaeological_finds/forms.py')
-rw-r--r--archaeological_finds/forms.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py
index e3207a2f5..2b3586979 100644
--- a/archaeological_finds/forms.py
+++ b/archaeological_finds/forms.py
@@ -390,6 +390,27 @@ FindSourceFormSelection = get_form_selection(
_(u"You should select a document."))
+class NewFindBasketForm(forms.ModelForm):
+ class Meta:
+ model = models.FindBasket
+ fields = ('label', 'comment')
+
+ def __init__(self, *args, **kwargs):
+ self.user = kwargs.pop('user')
+ super(NewFindBasketForm, self).__init__(*args, **kwargs)
+
+ def clean(self):
+ q = models.FindBasket.objects.filter(user=self.user,
+ label=self.cleaned_data['label'])
+ if q.count():
+ raise forms.ValidationError(_(u"Another basket already exist with "
+ u"this name."))
+ return self.cleaned_data
+
+ def save(self, commit=True):
+ self.instance.user = self.user
+ return super(NewFindBasketForm, self).save(commit)
+
"""
####################################
# Source management for treatments #