summaryrefslogtreecommitdiff
path: root/archaeological_finds/forms_treatments.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-11-14 18:02:04 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-11-28 11:40:16 +0100
commit87b2c52f3d32d32187cf318a39078acf58041ab8 (patch)
tree57dd96f25a1e518dc04ac1d73fd4ebd4d52526cd /archaeological_finds/forms_treatments.py
parent10abb4228c72b9c01e5344f38047be149a734251 (diff)
downloadIshtar-87b2c52f3d32d32187cf318a39078acf58041ab8.tar.bz2
Ishtar-87b2c52f3d32d32187cf318a39078acf58041ab8.zip
Reorganize treatment actions - add a direct to treatements
Diffstat (limited to 'archaeological_finds/forms_treatments.py')
-rw-r--r--archaeological_finds/forms_treatments.py58
1 files changed, 30 insertions, 28 deletions
diff --git a/archaeological_finds/forms_treatments.py b/archaeological_finds/forms_treatments.py
index 7ada0f4bc..248b1ef7d 100644
--- a/archaeological_finds/forms_treatments.py
+++ b/archaeological_finds/forms_treatments.py
@@ -94,20 +94,21 @@ class BaseTreatmentForm(CustomForm, ManageOldType):
file_upload = True
need_user_for_initialization = True
- label = forms.CharField(label=_(u"Label"),
- max_length=200, required=False)
- other_reference = forms.CharField(
- label=_(u"Other ref."), max_length=200, required=False)
- year = forms.IntegerField(label=_("Year"),
- initial=lambda: datetime.datetime.now().year,
- validators=[validators.MinValueValidator(1000),
- validators.MaxValueValidator(2100)])
- treatment_type = forms.MultipleChoiceField(
+ treatment_type = widgets.Select2MultipleField(
label=_(u"Treatment type"), choices=[],
widget=widgets.CheckboxSelectMultiple)
treatment_state = forms.ChoiceField(label=_(u"State"),
choices=[], required=False)
- target_is_basket = forms.NullBooleanField(label=_(u"Target"))
+ year = forms.IntegerField(label=_("Year"),
+ initial=lambda: datetime.datetime.now().year,
+ validators=[validators.MinValueValidator(1000),
+ validators.MaxValueValidator(2100)])
+ location = forms.IntegerField(
+ label=_(u"Location"),
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy('autocomplete-warehouse'), associated_model=Warehouse,
+ new=True),
+ validators=[valid_id(Warehouse)])
person = forms.IntegerField(
label=_(u"Responsible"),
widget=widgets.JQueryAutoComplete(
@@ -120,30 +121,29 @@ class BaseTreatmentForm(CustomForm, ManageOldType):
reverse_lazy('autocomplete-organization'),
associated_model=Organization, new=True),
validators=[valid_id(Organization)], required=False)
- location = forms.IntegerField(
- label=_(u"Location"),
- widget=widgets.JQueryAutoComplete(
- reverse_lazy('autocomplete-warehouse'), associated_model=Warehouse,
- new=True),
- validators=[valid_id(Warehouse)])
+ label = forms.CharField(label=_(u"Label"),
+ max_length=200, required=False)
+ other_reference = forms.CharField(
+ label=_(u"Other ref."), max_length=200, required=False)
+ # target_is_basket = forms.NullBooleanField(label=_(u"Target"))
+ # external_id = forms.CharField(
+ # label=_(u"External ref."), max_length=200, required=False)
+ start_date = forms.DateField(label=_(u"Start date"), required=False,
+ widget=DatePicker, initial=datetime.date.today)
+ end_date = forms.DateField(label=_(u"Closing date"), required=False,
+ widget=DatePicker)
container = forms.IntegerField(
label=_(u"Container (relevant for packaging)"),
widget=widgets.JQueryAutoComplete(
reverse_lazy('autocomplete-container'),
associated_model=Container, new=True),
validators=[valid_id(Container)], required=False)
- external_id = forms.CharField(
- label=_(u"External ref."), max_length=200, required=False)
goal = forms.CharField(label=_(u"Goal"),
widget=forms.Textarea, required=False)
description = forms.CharField(label=_(u"Description"),
widget=forms.Textarea, required=False)
comment = forms.CharField(label=_(u"Comment"),
widget=forms.Textarea, required=False)
- start_date = forms.DateField(label=_(u"Start date"), required=False,
- widget=DatePicker)
- end_date = forms.DateField(label=_(u"Closing date"), required=False,
- widget=DatePicker)
estimated_cost = forms.FloatField(label=_(u"Estimated cost ({currency})"),
required=False)
quoted_cost = forms.FloatField(label=_(u"Quoted cost ({currency})"),
@@ -155,9 +155,10 @@ class BaseTreatmentForm(CustomForm, ManageOldType):
TYPES = [
FieldType('treatment_state', models.TreatmentState),
- FieldType('treatment_type', models.TreatmentType, is_multiple=True,
- extra_args={'dct': {'upstream_is_many': False,
- 'downstream_is_many': False}})
+ FieldType(
+ 'treatment_type', models.TreatmentType, is_multiple=True,
+ extra_args={'dct': {'upstream_is_many': False,
+ 'downstream_is_many': False}})
]
def __init__(self, *args, **kwargs):
@@ -176,8 +177,8 @@ class BaseTreatmentForm(CustomForm, ManageOldType):
self.fields['person'].initial = person.pk
if person.attached_to:
self.fields['organization'].initial = person.attached_to.pk
- self.fields['target_is_basket'].widget.choices = \
- ((False, _(u"Single find")), (True, _(u"Basket")))
+ # self.fields['target_is_basket'].widget.choices = \
+ # ((False, _(u"Single find")), (True, _(u"Basket")))
# TODO
"""
self.fields['basket'].required = False
@@ -198,6 +199,7 @@ class BaseTreatmentForm(CustomForm, ManageOldType):
if not packaging:
logger.warning("No 'packaging' treatment type defined")
return
+
if data.get('container', None) \
and str(packaging.pk) not in data.get('treatment_type', []):
raise forms.ValidationError(
@@ -240,7 +242,7 @@ class TreatmentModifyForm(BaseTreatmentForm):
fields[key] = value
if key == 'year':
fields['index'] = idx
- fields.pop('target_is_basket')
+ # fields.pop('target_is_basket')
self.fields = fields
def clean(self, *args, **kwargs):