From 492a1b9c0acee48cb6d9334d93ab55512a5981a6 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 23 Mar 2017 11:52:54 +0100 Subject: Operation forms: filter some fields if "files" module is not activated (ref #3367) --- archaeological_operations/forms.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'archaeological_operations/forms.py') diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index 27ab4670a..041458ecd 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -857,21 +857,29 @@ class OperationFormGeneral(ManageOldType, forms.Form): def __init__(self, *args, **kwargs): super(OperationFormGeneral, self).__init__(*args, **kwargs) - if not get_current_profile().warehouse: - self.fields.pop('documentation_deadline') - self.fields.pop('documentation_received') - self.fields.pop('finds_deadline') - self.fields.pop('finds_received') + profile = get_current_profile() + if not profile.files: + self.fields.pop('report_delivery_date') + self.fields.pop('report_processing') + self.fields.pop('cira_rapporteur') + self.fields.pop('cira_date') + self.fields.pop('negative_result') + if not profile.warehouse: + self.fields.pop('documentation_deadline') + self.fields.pop('documentation_received') + self.fields.pop('finds_deadline') + self.fields.pop('finds_received') self.fields['operation_type'].choices = \ models.OperationType.get_types( initial=self.init_data.get('operation_type')) self.fields['operation_type'].help_text = \ models.OperationType.get_help() - self.fields['report_processing'].choices = \ - models.ReportState.get_types( - initial=self.init_data.get('report_processing')) - self.fields['report_processing'].help_text = \ - models.ReportState.get_help() + if 'report_processing' in self.fields: + self.fields['report_processing'].choices = \ + models.ReportState.get_types( + initial=self.init_data.get('report_processing')) + self.fields['report_processing'].help_text = \ + models.ReportState.get_help() self.fields['record_quality'].choices = \ [('', '--')] + list(models.QUALITY) if 'operation_code' in self.fields: -- cgit v1.2.3