diff options
Diffstat (limited to 'archaeological_finds/forms_treatments.py')
-rw-r--r-- | archaeological_finds/forms_treatments.py | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/archaeological_finds/forms_treatments.py b/archaeological_finds/forms_treatments.py index 99813ea31..4e5994ca9 100644 --- a/archaeological_finds/forms_treatments.py +++ b/archaeological_finds/forms_treatments.py @@ -37,7 +37,7 @@ from archaeological_operations.forms import AdministrativeActOpeForm, \ AdministrativeActOpeFormSelection, AdministrativeActModifForm from ishtar_common.forms import reverse_lazy, TableSelect, FinalForm, \ - ManageOldType, get_form_selection + ManageOldType, get_form_selection, CustomForm, FieldType from ishtar_common.forms_common import SourceSelect from ishtar_common import widgets @@ -75,8 +75,10 @@ class TreatmentFormSelection(forms.Form): validators=[valid_id(models.Treatment)]) -class BaseTreatmentForm(ManageOldType, forms.Form): +class BaseTreatmentForm(CustomForm, ManageOldType, forms.Form): form_label = _(u"Base treatment") + form_admin_name = _(u"Treatment - 020 - General") + form_slug = "treatment-020-general" base_models = ['treatment_type'] associated_models = {'treatment_type': models.TreatmentType, 'person': Person, @@ -154,6 +156,13 @@ class BaseTreatmentForm(ManageOldType, forms.Form): 'height': settings.IMAGE_MAX_SIZE[1]}), max_length=255, required=False, widget=widgets.ImageFileInput()) + 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}}) + ] + def __init__(self, *args, **kwargs): user = kwargs.pop('user') super(BaseTreatmentForm, self).__init__(*args, **kwargs) @@ -172,20 +181,6 @@ class BaseTreatmentForm(ManageOldType, forms.Form): self.fields['organization'].initial = person.attached_to.pk self.fields['target_is_basket'].widget.choices = \ ((False, _(u"Single find")), (True, _(u"Basket"))) - self.fields['treatment_type'].choices = models.TreatmentType.get_types( - initial=self.init_data.get('treatment_type'), - dct={'upstream_is_many': False, 'downstream_is_many': False}, - empty_first=False - ) - self.fields['treatment_type'].help_text = \ - models.TreatmentType.get_help( - dct={'upstream_is_many': False, 'downstream_is_many': False}) - self.fields['treatment_state'].choices = \ - models.TreatmentState.get_types( - initial=self.init_data.get('treatment_state'), - ) - self.fields['treatment_state'].help_text = \ - models.TreatmentState.get_help() # TODO """ self.fields['basket'].required = False @@ -266,8 +261,10 @@ class TreatmentModifyForm(BaseTreatmentForm): return cleaned_data -class TreatmentFormFileChoice(forms.Form): +class TreatmentFormFileChoice(CustomForm, forms.Form): form_label = _(u"Associated request") + form_admin_name = _(u"Treatment - 010 - Request choice") + form_slug = "treatment-010-requestchoice" associated_models = {'file': models.TreatmentFile, } currents = {'file': models.TreatmentFile} file = forms.IntegerField( @@ -383,15 +380,14 @@ class AdministrativeActTreatmentFormSelection( class AdministrativeActTreatmentForm(AdministrativeActOpeForm): + form_admin_name = _(u"Treatment - Administrative act - General") + form_slug = "treatment-adminact-general" act_type = forms.ChoiceField(label=_(u"Act type"), choices=[]) - def __init__(self, *args, **kwargs): - super(AdministrativeActTreatmentForm, self).__init__(*args, **kwargs) - self.fields['act_type'].choices = ActType.get_types( - initial=self.init_data.get('act_type'), - dct={'intented_to': 'T'}) - self.fields['act_type'].help_text = ActType.get_help( - dct={'intented_to': 'T'}) + TYPES = [ + FieldType('act_type', ActType, + extra_args={"dct": {'intented_to': 'T'}}), + ] class AdministrativeActTreatmentModifForm( @@ -640,16 +636,14 @@ class AdministrativeActTreatmentFileFormSelection( class AdministrativeActTreatmentFileForm(AdministrativeActOpeForm): + form_admin_name = _(u"Treatment request - Administrative act - General") + form_slug = "treatmentfile-adminact-general" act_type = forms.ChoiceField(label=_(u"Act type"), choices=[]) - def __init__(self, *args, **kwargs): - super(AdministrativeActTreatmentFileForm, self).__init__(*args, - **kwargs) - self.fields['act_type'].choices = ActType.get_types( - initial=self.init_data.get('act_type'), - dct={'intented_to': 'TF'}) - self.fields['act_type'].help_text = ActType.get_help( - dct={'intented_to': 'TF'}) + TYPES = [ + FieldType('act_type', ActType, + extra_args={"dct": {'intented_to': 'TF'}}), + ] class AdministrativeActTreatmentFileModifForm( |