diff options
Diffstat (limited to 'archaeological_finds/forms.py')
| -rw-r--r-- | archaeological_finds/forms.py | 37 | 
1 files changed, 23 insertions, 14 deletions
| diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index feaad0e23..367bff023 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -54,32 +54,39 @@ class FindForm(forms.Form):                                    widget=forms.Textarea)      base_finds__is_isolated = forms.NullBooleanField(label=_(u"Is isolated?"),                                           required=False) -    material_type = forms.ChoiceField(label=_("Material type"), -                               choices=models.MaterialType.get_types()) +    material_type = forms.ChoiceField(label=_("Material type"), choices=[])      volume = FloatField(label=_(u"Volume (l)"), required=False)      weight = FloatField(label=_(u"Weight (g)"), required=False)      find_number = forms.IntegerField(label=_(u"Find number"), required=False) +    def __init__(self, *args, **kwargs): +        super(FindForm, self).__init__(*args, **kwargs) +        self.fields['material_type'].choices = models.MaterialType.get_types() +        self.fields['material_type'].help_text = models.MaterialType.get_help() +  class DateForm(forms.Form):      form_label = _("Dating")      base_model = 'dating'      associated_models = {'dating__dating_type':DatingType,                           'dating__quality':DatingQuality,                           'dating__period':Period} -    dating__period = forms.ChoiceField(label=_("Period"), -                               choices=Period.get_types()) +    dating__period = forms.ChoiceField(label=_("Period"), choices=[])      dating__start_date = forms.IntegerField(label=_(u"Start date"),                                              required=False)      dating__end_date = forms.IntegerField(label=_(u"End date"), required=False)      dating__quality = forms.ChoiceField(label=_("Quality"), required=False, -                               choices=DatingQuality.get_types()) +                                        choices=[])      dating__dating_type = forms.ChoiceField(label=_("Dating type"), -                required=False, choices=[]) +                                            required=False, choices=[])      def __init__(self, *args, **kwargs):          super(DateForm, self).__init__(*args, **kwargs)          self.fields['dating__dating_type'].choices = DatingType.get_types()          self.fields['dating__dating_type'].help_text = DatingType.get_help() +        self.fields['dating__period'].choices = Period.get_types() +        self.fields['dating__period'].help_text = Period.get_help() +        self.fields['dating__quality'].choices = DatingQuality.get_types() +        self.fields['dating__quality'].help_text = DatingQuality.get_help()  class FindSelect(TableSelect):      base_finds__context_record__parcel__town = get_town_field() @@ -108,7 +115,7 @@ class FindFormSelection(forms.Form):      currents = {'pk':models.Find}      pk = forms.IntegerField(label="", required=False,         widget=widgets.JQueryJqGrid(reverse_lazy('get-find'), -          FindSelect(), models.Find, source_full=reverse_lazy('get-find-full')), +          FindSelect, models.Find, source_full=reverse_lazy('get-find-full')),         validators=[valid_id(models.Find)])  class BaseTreatmentForm(forms.Form): @@ -146,7 +153,7 @@ class FindMultipleFormSelection(forms.Form):      associated_labels = {'finds':_(u"Finds")}      finds = forms.CharField(label="", required=False,         widget=widgets.JQueryJqGrid(reverse_lazy('get-find'), -             FindSelect(), models.Find, multiple=True, multiple_cols=[2, 3, 4]), +             FindSelect, models.Find, multiple=True, multiple_cols=[2, 3, 4]),         validators=[valid_ids(models.Find)])      def clean(self): @@ -183,12 +190,16 @@ class ResultFindForm(forms.Form):                        validators=[validators.MaxLengthValidator(60)])      description = forms.CharField(label=_(u"Precise description"),                                    widget=forms.Textarea) -    material_type = forms.ChoiceField(label=_(u"Material type"), -                               choices=models.MaterialType.get_types()) +    material_type = forms.ChoiceField(label=_(u"Material type"), choices=[])      volume = forms.IntegerField(label=_(u"Volume (l)"))      weight = forms.IntegerField(label=_(u"Weight (g)"))      find_number = forms.IntegerField(label=_(u"Find number")) +    def __init__(self, *args, **kwargs): +        super(ResultFindForm, self).__init__(*args, **kwargs) +        self.fields['material_type'].choices = models.MaterialType.get_types() +        self.fields['material_type'].help_text = models.MaterialType.get_help() +  ResultFindFormSet = formset_factory(ResultFindForm, can_delete=True,                                      formset=FormSet)  ResultFindFormSet.form_label = _(u"Resulting finds") @@ -209,11 +220,9 @@ class FindSourceSelect(SourceSelect):      find__base_finds__context_record__operation__year = forms.IntegerField(                                                label=_(u"Year of the operation"))      find__dating__period = forms.ChoiceField( -            label=_(u"Period of the archaelogical find"), -            choices=[]) +            label=_(u"Period of the archaelogical find"), choices=[])      find__material_type = forms.ChoiceField( -            label=_("Material type of the archaelogical find"), -            choices=models.MaterialType.get_types()) +            label=_("Material type of the archaelogical find"), choices=[])      find__description = forms.CharField(              label=_(u"Description of the archaelogical find")) | 
