summaryrefslogtreecommitdiff
path: root/archaeological_finds/forms_treatments.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-12-10 17:51:52 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-12-10 18:06:42 +0100
commitd249f79bdfa5eb1599cd55b81b7047ad79dfb19a (patch)
tree7173c7f429d0d6f06b74c07f0dfccf14f98c8e8b /archaeological_finds/forms_treatments.py
parent8a5106021abc5a897a2dc52dc0ff1c6cf4af951f (diff)
downloadIshtar-d249f79bdfa5eb1599cd55b81b7047ad79dfb19a.tar.bz2
Ishtar-d249f79bdfa5eb1599cd55b81b7047ad79dfb19a.zip
Treatment - packaging: change by default current and ref container
Diffstat (limited to 'archaeological_finds/forms_treatments.py')
-rw-r--r--archaeological_finds/forms_treatments.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/archaeological_finds/forms_treatments.py b/archaeological_finds/forms_treatments.py
index 8ae0dbd36..59df12df2 100644
--- a/archaeological_finds/forms_treatments.py
+++ b/archaeological_finds/forms_treatments.py
@@ -195,10 +195,20 @@ class BaseTreatmentForm(CustomForm, ManageOldType):
def clean(self, *args, **kwargs):
data = self.cleaned_data
- treatment_types = data.get('treatment_type', [])
+ try:
+ treatment_types = [
+ models.TreatmentType.objects.get(
+ pk=pk, available=True, upstream_is_many=False,
+ downstream_is_many=False)
+ for pk in data.get('treatment_type', [])]
+ except models.TreatmentType.DoesNotExist:
+ raise forms.ValidationError(_(u"Unknow treatment type"))
+
change_current_location = [
- unicode(tp) for tp in treatment_types if tp.change_current_location]
+ unicode(tp) for tp in treatment_types
+ if tp.change_current_location
+ ]
restore_reference_location = [
unicode(tp) for tp in treatment_types
if tp.restore_reference_location
@@ -214,7 +224,7 @@ class BaseTreatmentForm(CustomForm, ManageOldType):
raise forms.ValidationError(
unicode(
_(u"{} is not compatible with {} "
- u"treatments.")).format(
+ u"treatment(s).")).format(
u' ; '.join(restore_reference_location),
u' ; '.join(change_ref_location),
)
@@ -223,22 +233,12 @@ class BaseTreatmentForm(CustomForm, ManageOldType):
raise forms.ValidationError(
unicode(
_(u"{} is not compatible with {} "
- u"treatments.")).format(
+ u"treatment(s).")).format(
u' ; '.join(restore_reference_location),
u' ; '.join(change_current_location)
)
)
- if change_ref_location and change_current_location:
- raise forms.ValidationError(
- unicode(
- _(u"{} is not compatible with {} "
- u"treatments.")).format(
- u' ; '.join(change_ref_location),
- u' ; '.join(change_current_location)
- )
- )
-
if data.get('container', None) \
and not change_ref_location\
and not change_current_location: