summaryrefslogtreecommitdiff
path: root/ishtar/furnitures/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar/furnitures/forms.py')
-rw-r--r--ishtar/furnitures/forms.py52
1 files changed, 38 insertions, 14 deletions
diff --git a/ishtar/furnitures/forms.py b/ishtar/furnitures/forms.py
index 821ef1bb9..ba3ba826b 100644
--- a/ishtar/furnitures/forms.py
+++ b/ishtar/furnitures/forms.py
@@ -733,7 +733,7 @@ class FileSelect(forms.Form):
year = forms.IntegerField(label=_("Year"))
class FileFormSelection(forms.Form):
- form_label = _("Archaelogical file")
+ form_label = _("Archaeological file")
associated_models = {'pk':models.File}
currents = {'pk':models.File}
pk = forms.IntegerField(label="", required=False,
@@ -747,17 +747,6 @@ class FileFormSelection(forms.Form):
raise forms.ValidationError(_(u"You should select a file."))
return cleaned_data
-"""
-class FileFormSelection(forms.Form):
- form_label = _("Archaelogical file")
- associated_models = {'pk':models.File}
- currents = {'pk':models.File}
- pk = forms.IntegerField(label=_("References/location"),
- widget=widgets.JQueryAutoComplete(reverse_lazy('autocomplete-file'),
- associated_model=models.File),
- validators=[models.valid_id(models.File)])
-"""
-
class FileFormGeneral(forms.Form):
form_label = _("General")
associated_models = {'in_charge':models.Person,
@@ -1671,11 +1660,36 @@ class RecordWizard(Wizard):
obj.datings.add(dating)
return res
+class RecordSelect(forms.Form):
+ parcel__town = forms.IntegerField(label=_(u"Town"),
+ widget=widgets.JQueryAutoComplete("/" + settings.URL_PATH + \
+ 'autocomplete-town', associated_model=models.Town),
+ validators=[models.valid_id(models.Town)])
+ parcel__operation__operation_type = forms.ChoiceField(
+ label=_("Operation type"), choices=models.OperationType.get_types())
+ parcel__year = forms.IntegerField(label=_("Year"))
+
+class RecordFormSelection(forms.Form):
+ form_label = _("Context record")
+ associated_models = {'pk':models.ContextRecord}
+ currents = {'pk':models.ContextRecord}
+ pk = forms.IntegerField(label="", required=False,
+ widget=widgets.JQueryJqGrid(reverse_lazy('get-contextrecord'),
+ RecordSelect(), models.ContextRecord),
+ validators=[models.valid_id(models.ContextRecord)])
+
+ def clean(self):
+ cleaned_data = self.cleaned_data
+ if 'pk' not in cleaned_data or not cleaned_data['pk']:
+ raise forms.ValidationError(_(u"You should select a context "
+ u"record."))
+ return cleaned_data
+
class RecordFormGeneral(forms.Form):
form_label = _("General")
associated_models = {'parcel':models.Parcel,}
- parcel = forms.ChoiceField(label=_("Parcel"), choices=[('', '--')])
+ parcel = forms.ChoiceField(label=_("Parcel"), choices=[])
label = forms.CharField(label=_(u"Label"),
validators=[validators.MaxLengthValidator(200)])
description = forms.CharField(label=_(u"Description"),
@@ -1700,7 +1714,8 @@ class RecordFormGeneral(forms.Form):
if 'files' in kwargs:
kwargs.pop('files')
super(RecordFormGeneral, self).__init__(*args, **kwargs)
- if operation and len(self.fields['parcel'].choices) == 1:
+ self.fields['parcel'].choices = [('', '--')]
+ if operation:
parcels = operation.parcels.all()
sort = lambda x: (x.town.name, x.section)
parcels = sorted(parcels, key=sort)
@@ -1762,3 +1777,12 @@ record_creation_wizard = RecordWizard([
('final-record_creation', FinalForm)],
url_name='record_creation',)
+record_modification_wizard = RecordWizard([
+ ('selec-record_modification', RecordFormSelection),
+ ('general-record_modification', RecordFormGeneral),
+ ('datings-record_modification', DatingFormSet),
+ ('units-record_modification', UnitFormSet),
+ ('interpretation-record_modification', RecordFormInterpretation),
+ ('final-record_modification', FinalForm)],
+ url_name='record_modification',)
+