diff options
| -rw-r--r-- | archaeological_finds/forms.py | 69 | ||||
| -rw-r--r-- | archaeological_finds/models.py | 6 | ||||
| -rw-r--r-- | archaeological_finds/views.py | 12 | 
3 files changed, 60 insertions, 27 deletions
| diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index 884bbe9a1..497061e3a 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -79,6 +79,7 @@ __all__ = [      'TreatmentFileSourceFormSelection', 'DashboardTreatmentForm',      'DashboardTreatmentFileForm',      'RecordFormSelection', 'FindForm', 'DateForm', 'DatingFormSet', +    'PreservationForm',      'FindSelect', 'FindFormSelection', 'FindFormSelectionWarehouseModule',      'MultipleFindFormSelection', 'MultipleFindFormSelectionWarehouseModule',      'FindMultipleFormSelection', 'check_form', 'check_exist', 'check_not_exist', @@ -127,12 +128,9 @@ class FindForm(ManageOldType, forms.Form):      file_upload = True      form_label = _("Find")      base_models = ['get_first_base_find', 'object_type', 'material_type', -                   'preservation_to_consider', 'integritie', -                   'remarkabilitie'] +                   'integritie', 'remarkabilitie']      associated_models = {'material_type': models.MaterialType, -                         'conservatory_state': models.ConservatoryState,                           'object_type': models.ObjectType, -                         'preservation_to_consider': models.PreservationType,                           'integritie': models.IntegrityType,                           'get_first_base_find__batch': models.BatchType,                           'remarkabilitie': models.RemarkabilityType, @@ -154,17 +152,9 @@ class FindForm(ManageOldType, forms.Form):      material_type = widgets.Select2MultipleField(          label=_(u"Material type"), required=False      ) -    conservatory_state = forms.ChoiceField(label=_(u"Conservatory state"), -                                           choices=[], required=False) -    conservatory_comment = forms.CharField( -        label=_(u"Conservatory comment"), required=False, -        widget=forms.Textarea)      object_type = widgets.Select2MultipleField(          label=_(u"Object types"), required=False,      ) -    preservation_to_consider = forms.MultipleChoiceField( -        label=_(u"Preservation type"), choices=[], -        widget=widgets.Select2Multiple, required=False)      integritie = forms.MultipleChoiceField(          label=_(u"Integrity / interest"), choices=[],          widget=widgets.Select2Multiple, required=False) @@ -251,19 +241,6 @@ class FindForm(ManageOldType, forms.Form):                  initial=self.init_data.get('get_first_base_find__batch'))          self.fields['get_first_base_find__batch'].help_text = \              models.BatchType.get_help() - -        self.fields['conservatory_state'].choices = \ -            models.ConservatoryState.get_types( -                initial=self.init_data.get('conservatory_state')) -        self.fields['conservatory_state'].help_text = \ -            models.ConservatoryState.get_help() - -        self.fields['preservation_to_consider'].choices = \ -            models.PreservationType.get_types( -                empty_first=False, -                initial=self.init_data.get('preservation_to_consider')) -        self.fields['preservation_to_consider'].help_text = \ -            models.PreservationType.get_help()          self.fields['integritie'].choices = \              models.IntegrityType.get_types(                  empty_first=False, @@ -308,6 +285,48 @@ class FindForm(ManageOldType, forms.Form):          return self.cleaned_data +class PreservationForm(ManageOldType, forms.Form): +    form_label = _("Preservation") +    base_models = ['alteration', 'alteration_cause', +                   'preservation_to_consider'] +    associated_models = {'alteration': models.AlterationType, +                         'alteration_cause': models.AlterationCauseType, +                         'treatment_emergency': models.TreatmentEmergencyType, +                         'conservatory_state': models.ConservatoryState, +                         'preservation_to_consider': models.PreservationType, +                         } +    conservatory_state = forms.ChoiceField(label=_(u"Conservatory state"), +                                           choices=[], required=False) +    alteration = forms.MultipleChoiceField( +        label=_(u"Alteration"), choices=[], +        widget=widgets.Select2Multiple, required=False) +    alteration_cause = forms.MultipleChoiceField( +        label=_(u"Alteration cause"), choices=[], +        widget=widgets.Select2Multiple, required=False) +    preservation_to_consider = forms.MultipleChoiceField( +        label=_(u"Preservation type"), choices=[], +        widget=widgets.Select2Multiple, required=False) +    insurance_value = FloatField(label=_(u"Insurance value"), required=False) +    appraisal_date = forms.DateField( +        label=_(u"Appraisal date"), widget=widgets.JQueryDate, required=False) +    conservatory_comment = forms.CharField( +        label=_(u"Conservatory comment"), required=False, +        widget=forms.Textarea) + +    TYPES = [ +        ('conservatory_state', models.ConservatoryState, False), +        ('preservation_to_consider', models.PreservationType, True), +        ('alteration', models.AlterationType, True), +        ('alteration_cause', models.AlterationCauseType, True), +    ] + +    def __init__(self, *args, **kwargs): +        super(PreservationForm, self).__init__(*args, **kwargs) +        self.fields['insurance_value'].label = u"{} ({})".format( +            unicode(self.fields['insurance_value'].label), +            get_current_profile().currency) + +  class DateForm(ManageOldType, forms.Form):      form_label = _("Dating")      base_model = 'dating' diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index eb209461f..ab3686f08 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -1,7 +1,8 @@  from archaeological_finds.models_finds import MaterialType, ConservatoryState,\      PreservationType, IntegrityType, RemarkabilityType, ObjectType, BaseFind, \      FindBasket, Find, FindSource, Property, CHECK_CHOICES, BatchType, \ -    BFBulkView, FBulkView, FirstBaseFindView +    BFBulkView, FBulkView, FirstBaseFindView, AlterationType, \ +    AlterationCauseType, TreatmentEmergencyType  from archaeological_finds.models_treatments import TreatmentType, Treatment, \      AbsFindTreatments, FindUpstreamTreatments, FindDownstreamTreatments, \      FindTreatments, TreatmentSource, TreatmentFile, TreatmentFileType, \ @@ -10,7 +11,8 @@ from archaeological_finds.models_treatments import TreatmentType, Treatment, \  __all__ = ['MaterialType', 'ConservatoryState', 'PreservationType',             'IntegrityType', 'RemarkabilityType', 'ObjectType',             'BaseFind', 'FindBasket', 'Find', 'FindSource', 'Property', -           'BFBulkView', 'FBulkView', 'FirstBaseFindView', +           'BFBulkView', 'FBulkView', 'FirstBaseFindView', 'AlterationType', +           'AlterationCauseType', 'TreatmentEmergencyType',             'CHECK_CHOICES', 'BatchType', 'TreatmentType', 'TreatmentState',             'Treatment', 'AbsFindTreatments', 'FindUpstreamTreatments',             'FindDownstreamTreatments', 'FindTreatments', 'TreatmentSource', diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py index 828f9801d..f2be734e7 100644 --- a/archaeological_finds/views.py +++ b/archaeological_finds/views.py @@ -118,6 +118,10 @@ display_findbasket = display_item(models.FindBasket,                                    show_url='show-find/basket-') +def check_preservation_module(self): +    return get_current_profile().preservation + +  def check_warehouse_module(self):      return get_current_profile().warehouse @@ -129,13 +133,19 @@ def check_not_warehouse_module(self):  find_creation_steps = [      ('selecrecord-find_creation', RecordFormSelectionTable),      ('find-find_creation', FindForm), +    ('preservation-find_creation', PreservationForm),      ('dating-find_creation', DatingFormSet),      ('final-find_creation', FinalForm)  ] +find_creation_condition_dict = { +    'preservation-find_creation': check_preservation_module, +} +  find_creation_wizard = FindWizard.as_view(      find_creation_steps,      label=_(u"New find"), +    condition_dict=find_creation_condition_dict,      url_name='find_creation',)  find_search_condition_dict = { @@ -154,6 +164,7 @@ find_search_wizard = SearchWizard.as_view([  find_modification_condition_dict = {      'selec-find_modification': check_not_warehouse_module,      'selecw-find_modification': check_warehouse_module, +    'preservation-find_modification': check_preservation_module,  }  find_modification_wizard = FindModificationWizard.as_view([ @@ -161,6 +172,7 @@ find_modification_wizard = FindModificationWizard.as_view([      ('selecw-find_modification', FindFormSelectionWarehouseModule),      ('selecrecord-find_modification', RecordFormSelection),      ('find-find_modification', FindForm), +    ('preservation-find_modification', PreservationForm),      ('dating-find_modification', DatingFormSet),      ('final-find_modification', FinalForm)],      condition_dict=find_modification_condition_dict, | 
