diff options
Diffstat (limited to 'ishtar/furnitures')
| -rw-r--r-- | ishtar/furnitures/forms.py | 80 | ||||
| -rw-r--r-- | ishtar/furnitures/models.py | 23 |
2 files changed, 79 insertions, 24 deletions
diff --git a/ishtar/furnitures/forms.py b/ishtar/furnitures/forms.py index 6beec3744..b21f801a6 100644 --- a/ishtar/furnitures/forms.py +++ b/ishtar/furnitures/forms.py @@ -894,18 +894,18 @@ class FileFormPreventive(forms.Form): reception_date = forms.DateField(label=_(u"Reception date"), initial=get_now, widget=widgets.JQueryDate) -def is_preventive(form_name, file_type_key='file_type'): +def is_preventive(form_name, model, type_key='file_type', key=''): def func(self, request, storage): if storage.prefix not in request.session or \ 'step_data' not in request.session[storage.prefix] or \ form_name not in request.session[storage.prefix]['step_data'] or\ - form_name + '-' + file_type_key not in \ + form_name + '-' + type_key not in \ request.session[storage.prefix]['step_data'][form_name]: return False try: - file_type = int(request.session[storage.prefix]['step_data']\ - [form_name][form_name+'-'+file_type_key]) - return models.FileType.is_preventive(file_type) + type = int(request.session[storage.prefix]['step_data']\ + [form_name][form_name+'-'+type_key]) + return model.is_preventive(type, key) except ValueError: return False return func @@ -918,7 +918,7 @@ file_creation_wizard = FileWizard([ ('preventive-file_creation', FileFormPreventive), ('final-file_creation', FinalForm)], condition_list={ - 'preventive-file_creation':is_preventive('general-file_creation') +'preventive-file_creation':is_preventive('general-file_creation', models.FileType) }, url_name='file_creation',) @@ -931,7 +931,8 @@ file_modification_wizard = FileWizard([ ('preventive-file_modification', FileFormPreventive), ('final-file_modification', FinalForm)], condition_list={ - 'preventive-file_modification':is_preventive('general-file_modification') +'preventive-file_modification':is_preventive('general-file_modification', + models.FileType) }, url_name='file_modification',) @@ -1255,11 +1256,11 @@ class OperationFormReference(forms.Form): currents = {'associated_file':models.File} hidden_year = forms.IntegerField(widget=forms.HiddenInput) hidden_ope = forms.BooleanField(widget=forms.HiddenInput, required=False) - operation_code = forms.IntegerField(label=u"Operation code") + operation_code = forms.IntegerField(label=_(u"Operation code")) if settings.COUNTRY == 'fr': code_patriarche = forms.IntegerField(label=u"Code PATRIARCHE", required=False) - code_dracar = forms.CharField(label=_(u"Code DRACAR"), required=False, + code_dracar = forms.CharField(label=u"Code DRACAR", required=False, validators=[validators.MaxLengthValidator(10)]) def clean(self): cleaned_data = self.cleaned_data @@ -1277,6 +1278,23 @@ class OperationFormReference(forms.Form): 'last_val':max_val}) return cleaned_data +class OperationFormPreventive(forms.Form): + form_label = _("Preventive informations - excavation") + cost = forms.IntegerField(label=_(u"Cost"), required=False) + if settings.COUNTRY == 'fr': + fnap_financing = forms.FloatField(required=False, + label=u"Pourcentage de financement FNAP", + validators=[validators.MinValueValidator(0), + validators.MaxValueValidator(100)]) + +class OperationFormPreventiveDiag(forms.Form): + form_label = _("Preventive informations - diagnostic") + if settings.COUNTRY == 'fr': + zoning_prescription = forms.NullBooleanField(required=False) + large_area_prescription = forms.NullBooleanField(required=False) + geoarchaeological_context_prescription = forms.NullBooleanField( + required=False) + class SelectedTownForm(forms.Form): form_label = _("Towns") associated_models = {'town':models.Town} @@ -1362,22 +1380,40 @@ RemainFormSet = formset_factory(RemainForm, can_delete=True, RemainFormSet.form_label = _("Remain types") operation_creation_wizard = OperationWizard([ - ('general-operation_creation', OperationFormGeneral), - ('refs-operation_creation', OperationFormReference), - ('towns-operation_creation', SelectedTownFormSet), - ('parcels-operation_creation', SelectedParcelFormSet), - ('remains-operation_creation', RemainFormSet), - ('final-operation_creation', FinalForm)], + ('general-operation_creation', OperationFormGeneral), + ('refs-operation_creation', OperationFormReference), + ('preventive-operation_creation', OperationFormPreventive), + ('preventivediag-operation_creation', OperationFormPreventiveDiag), + ('towns-operation_creation', SelectedTownFormSet), + ('parcels-operation_creation', SelectedParcelFormSet), + ('remains-operation_creation', RemainFormSet), + ('final-operation_creation', FinalForm)], + condition_list={ +'preventive-operation_creation':is_preventive('general-operation_creation', + models.OperationType, 'operation_type', 'prev_excavation'), +'preventivediag-operation_creation':is_preventive('general-operation_creation', + models.OperationType, 'operation_type', 'arch_diagnostic') + }, url_name='operation_creation',) operation_modification_wizard = OperationWizard([ - ('selec-operation_modification', OperationFormSelection), - ('general-operation_modification', OperationFormGeneral), - ('refs-operation_modification', OperationFormReference), - ('towns-operation_modification', SelectedTownFormSet), - ('parcels-operation_modification', SelectedParcelFormSet), - ('remains-operation_modification', RemainFormSet), - ('final-operation_modification', FinalForm)], + ('selec-operation_modification', OperationFormSelection), + ('general-operation_modification', OperationFormGeneral), + ('refs-operation_modification', OperationFormReference), + ('preventive-operation_modification', OperationFormPreventive), + ('preventivediag-operation_modification', OperationFormPreventiveDiag), + ('towns-operation_modification', SelectedTownFormSet), + ('parcels-operation_modification', SelectedParcelFormSet), + ('remains-operation_modification', RemainFormSet), + ('final-operation_modification', FinalForm)], + condition_list={ +'preventive-operation_modification':is_preventive( + 'general-operation_modification', models.OperationType, + 'operation_type', 'prev_excavation'), +'preventivediag-operation_modification':is_preventive( + 'general-operation_modification', models.OperationType, + 'operation_type', 'arch_diagnostic') + }, url_name='operation_modification',) class OperationDateFormSelection(forms.Form): diff --git a/ishtar/furnitures/models.py b/ishtar/furnitures/models.py index fec52bfe5..0ce4ef057 100644 --- a/ishtar/furnitures/models.py +++ b/ishtar/furnitures/models.py @@ -250,9 +250,10 @@ class FileType(GeneralType): verbose_name_plural = _(u"Archaeological file types") @classmethod - def is_preventive(cls, file_type_id): + def is_preventive(cls, file_type_id, key=''): + key = key or 'preventive' try: - preventive = FileType.objects.get(txt_idx="preventive").pk + preventive = FileType.objects.get(txt_idx=key).pk return file_type_id == preventive except ObjectDoesNotExist: return False @@ -342,6 +343,15 @@ class OperationType(GeneralType): verbose_name = _(u"Operation type") verbose_name_plural = _(u"Operation types") + @classmethod + def is_preventive(cls, ope_type_id, key=''): + key = key or 'prev_excavation' + try: + preventive = OperationType.objects.get(txt_idx=key).pk + return ope_type_id == preventive + except ObjectDoesNotExist: + return False + class RemainType(GeneralType): class Meta: verbose_name = _(u"Remain type") @@ -362,12 +372,21 @@ class Operation(BaseHistorizedItem, OwnPerms): verbose_name=_(u"Operation type")) remains = models.ManyToManyField("RemainType", verbose_name=_(u'Remains')) towns = models.ManyToManyField("Town", verbose_name=_(u"Towns")) + cost = models.IntegerField(_(u"Cost"), blank=True, null=True) if settings.COUNTRY == 'fr': code_patriarche = models.IntegerField(u"Code PATRIARCHE", null=True, blank=True) code_dracar = models.CharField(u"Code DRACAR", max_length=10, null=True, blank=True) + fnap_financing = models.FloatField(u"Financement FNAP", + blank=True, null=True) TABLE_COLS += ["code_patriarche", "code_dracar"] + zoning_prescription = models.NullBooleanField(_(u"Prescription on zoning"), + blank=True, null=True) + large_area_prescription = models.NullBooleanField( + _(u"Prescription on large area"), blank=True, null=True) + geoarchaeological_context_prescription = models.NullBooleanField( + _(u"Prescription on geoarchaeological context"), blank=True, null=True) comment = models.TextField(_(u"Comment"), null=True, blank=True) history = HistoricalRecords() |
