diff options
Diffstat (limited to 'ishtar/ishtar_base/forms_items.py')
| -rw-r--r-- | ishtar/ishtar_base/forms_items.py | 143 | 
1 files changed, 136 insertions, 7 deletions
diff --git a/ishtar/ishtar_base/forms_items.py b/ishtar/ishtar_base/forms_items.py index b6da0f889..7e3047741 100644 --- a/ishtar/ishtar_base/forms_items.py +++ b/ishtar/ishtar_base/forms_items.py @@ -33,9 +33,10 @@ from ishtar import settings  import models  import widgets -from forms import Wizard, FinalForm, FormSet, SearchWizard, FloatField,\ -                  formset_factory, get_now, reverse_lazy -from forms_common import get_town_field +from forms import Wizard, FinalForm, FormSet, SearchWizard, DeletionWizard,\ +      FloatField, formset_factory, get_now, get_form_selection, reverse_lazy +from forms_common import get_town_field, SourceForm, SourceWizard, \ +                         SourceSelect, SourceDeletionForm, AuthorFormset  from forms_context_records import RecordFormSelection  class ItemWizard(Wizard): @@ -139,14 +140,23 @@ class ItemSelect(forms.Form):                                                               label=_(u"Year"))      base_items__context_record__operation__code_patriarche = \                                   forms.IntegerField(label=_(u"Code PATRIARCHE")) -    dating__period = forms.ChoiceField( -            label=_(u"Period"), choices=models.Period.get_types()) +    dating__period = forms.ChoiceField(label=_(u"Period"), choices=[])      # TODO search by warehouse -    material_type = forms.ChoiceField( -            label=_("Material type"), choices=models.MaterialType.get_types()) +    material_type = forms.ChoiceField(label=_(u"Material type"), choices=[])      base_items__item__description = forms.CharField(label=_(u"Description"))      base_items__is_isolated = forms.NullBooleanField(label=_(u"Is isolated?")) +    def __init__(self, *args, **kwargs): +        super(ItemSelect, self).__init__(*args, **kwargs) +        self.fields['dating__period'].choices = \ +                                            models.Period.get_types() +        self.fields['dating__period'].help_text = \ +                                            models.Period.get_help() +        self.fields['material_type'].choices = \ +                                            models.MaterialType.get_types() +        self.fields['material_type'].help_text = \ +                                            models.MaterialType.get_help() +  class ItemFormSelection(forms.Form):      form_label = _("Item search")      associated_models = {'pk':models.Item} @@ -278,3 +288,122 @@ treatment_creation_wizard = TreatmentWizard([                              },       url_name='treatment_creation',) +############################################# +# Source management for archaelogical items # +############################################# + +class ItemSourceWizard(SourceWizard): +    model = models.ItemSource + +SourceItemFormSelection = get_form_selection( +    'SourceItemFormSelection', _(u"Archaelogical item search"), 'item', +    models.Item, ItemSelect, 'get-item', +    _(u"You should select an archaelogical item.")) + +item_source_creation_wizard = ItemSourceWizard([ +             ('selec-item_source_creation', SourceItemFormSelection), +             ('source-item_source_creation', SourceForm), +             ('authors-item_source_creation', AuthorFormset), +             ('final-item_source_creation', FinalForm)], +                  url_name='item_source_creation',) + +class ItemSourceSelect(SourceSelect): +    item__base_items__context_record__operation__year = forms.IntegerField( +                                              label=_(u"Year of the operation")) +    item__dating__period = forms.ChoiceField( +            label=_(u"Period of the archaelogical item"), +            choices=[]) +    item__material_type = forms.ChoiceField( +            label=_("Material type of the archaelogical item"), +            choices=models.MaterialType.get_types()) +    item__description = forms.CharField( +            label=_(u"Description of the archaelogical item")) + +    def __init__(self, *args, **kwargs): +        super(ItemSourceSelect, self).__init__(*args, **kwargs) +        self.fields['item__dating__period'].choices = \ +                                            models.Period.get_types() +        self.fields['item__dating__period'].help_text = \ +                                            models.Period.get_help() +        self.fields['item__material_type'].choices = \ +                                            models.MaterialType.get_types() +        self.fields['item__material_type'].help_text = \ +                                            models.MaterialType.get_help() + +ItemSourceFormSelection = get_form_selection( +    'ItemSourceFormSelection', _(u"Documentation search"), 'pk', +    models.ItemSource, ItemSourceSelect, 'get-itemsource', +    _(u"You should select a document.")) + +item_source_modification_wizard = ItemSourceWizard([ +         ('selec-item_source_modification', ItemSourceFormSelection), +         ('source-item_source_modification', SourceForm), +         ('authors-item_source_modification', AuthorFormset), +         ('final-item_source_modification', FinalForm)], +          url_name='item_source_modification',) + +class ItemSourceDeletionWizard(DeletionWizard): +    model = models.ItemSource +    fields = ['item', 'title', 'source_type', 'authors',] + +item_source_deletion_wizard = ItemSourceDeletionWizard([ +         ('selec-item_source_deletion', ItemSourceFormSelection), +         ('final-item_source_deletion', SourceDeletionForm)], +          url_name='item_source_deletion',) + +""" + +#################################### +# Source management for treatments # +#################################### + +class TreatmentSourceWizard(SourceWizard): +    model = models.TreamentSource + +SourceTreatementFormSelection = get_form_selection( +    'SourceTreatmentFormSelection', _(u"Treatment search"), 'operation', +    models.Treatment, TreatmentSelect, 'get-treatment', +    _(u"You should select a treatment.")) + +treatment_source_creation_wizard = TreatmentSourceWizard([ +             ('selec-treatment_source_creation', SourceTreatmentFormSelection), +             ('source-treatment_source_creation', SourceForm), +             ('authors-treatment_source_creation', AuthorFormset), +             ('final-treatment_source_creation', FinalForm)], +                  url_name='treatment_source_creation',) + +class TreatmentSourceSelect(SourceSelect): +    operation__towns = get_town_field(label=_(u"Operation's town")) +    treatment__treatment_type = forms.ChoiceField(label=_(u"Operation type"), +                                                  choices=[]) +    operation__year = forms.IntegerField(label=_(u"Operation's year")) + +    def __init__(self, *args, **kwargs): +        super(OperationSourceSelect, self).__init__(*args, **kwargs) +        self.fields['operation__operation_type'].choices = \ +                                            models.OperationType.get_types() +        self.fields['operation__operation_type'].help_text = \ +                                            models.OperationType.get_help() + + +OperationSourceFormSelection = get_form_selection( +    'OperationSourceFormSelection', _(u"Documentation search"), 'pk', +    models.OperationSource, OperationSourceSelect, 'get-operationsource', +    _(u"You should select a document.")) + +operation_source_modification_wizard = OperationSourceWizard([ +         ('selec-operation_source_modification', OperationSourceFormSelection), +         ('source-operation_source_modification', SourceForm), +         ('authors-operation_source_modification', AuthorFormset), +         ('final-operation_source_modification', FinalForm)], +          url_name='operation_source_modification',) + +class OperationSourceDeletionWizard(DeletionWizard): +    model = models.OperationSource +    fields = ['operation', 'title', 'source_type', 'authors',] + +operation_source_deletion_wizard = OperationSourceDeletionWizard([ +         ('selec-operation_source_deletion', OperationSourceFormSelection), +         ('final-operation_source_deletion', SourceDeletionForm)], +          url_name='operation_source_deletion',) +"""  | 
