summaryrefslogtreecommitdiff
path: root/archaeological_operations/views.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-03-23 11:52:54 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-03-23 11:52:54 +0100
commitf772e30d0270e39c0dc3bd2bf5322fdf38f57cd8 (patch)
tree4d0441a7deb96b5fa0dd31416f3a2d8e9ebab4c4 /archaeological_operations/views.py
parentc5d174881ba9e15446500d52c9c5659b49af60b8 (diff)
downloadIshtar-f772e30d0270e39c0dc3bd2bf5322fdf38f57cd8.tar.bz2
Ishtar-f772e30d0270e39c0dc3bd2bf5322fdf38f57cd8.zip
Operation forms: filter some fields if "files" module is not activated (ref #3367)
Diffstat (limited to 'archaeological_operations/views.py')
-rw-r--r--archaeological_operations/views.py67
1 files changed, 41 insertions, 26 deletions
diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py
index c4e4acb5e..c886d9095 100644
--- a/archaeological_operations/views.py
+++ b/archaeological_operations/views.py
@@ -185,20 +185,29 @@ wizard_steps = [
('final-operation_creation', FinalForm)]
-def check_files_for_operation(self):
- if not check_rights_condition(['view_file'])(self):
- return False
- return get_current_profile().files
+def get_check_files_for_operation(other_check=None):
+ def func(self):
+ if not get_current_profile().files or \
+ not check_rights_condition(['view_file'])(self):
+ return False
+ if not other_check:
+ return True
+ return other_check(self)
+ return func
+
+check_files_for_operation = get_check_files_for_operation()
+
ope_crea_condition_dict = {
- 'filechoice-operation_creation':
- check_files_for_operation,
+ 'filechoice-operation_creation': check_files_for_operation,
'preventive-operation_creation':
- is_preventive('general-operation_creation', models.OperationType,
- 'operation_type', 'prev_excavation'),
+ get_check_files_for_operation(
+ 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'),
+ get_check_files_for_operation(
+ is_preventive('general-operation_creation', models.OperationType,
+ 'operation_type', 'arch_diagnostic')),
'townsgeneral-operation_creation': has_associated_file(
'filechoice-operation_creation', negate=True),
'towns-operation_creation': has_associated_file(
@@ -232,25 +241,31 @@ operation_modif_wizard_steps = [
('final-operation_modification', FinalForm)
]
+
+ope_modif_condition_dict = {
+ 'preventive-operation_modification':
+ get_check_files_for_operation(
+ is_preventive('general-operation_modification', models.OperationType,
+ 'operation_type', 'prev_excavation')),
+ 'preventivediag-operation_modification':
+ get_check_files_for_operation(
+ is_preventive('general-operation_modification', models.OperationType,
+ 'operation_type', 'arch_diagnostic')),
+ 'townsgeneral-operation_modification': has_associated_file(
+ 'general-operation_modification', negate=True),
+ 'towns-operation_modification': has_associated_file(
+ 'general-operation_modification'),
+ 'parcelsgeneral-operation_modification': has_associated_file(
+ 'general-operation_modification', negate=True),
+ 'parcels-operation_modification': has_associated_file(
+ 'general-operation_modification'),
+
+}
+
operation_modification_wizard = OperationModificationWizard.as_view(
operation_modif_wizard_steps,
label=_(u"Operation modification"),
- condition_dict={
- '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'),
- 'townsgeneral-operation_modification': has_associated_file(
- 'general-operation_modification', negate=True),
- 'towns-operation_modification': has_associated_file(
- 'general-operation_modification'),
- 'parcelsgeneral-operation_modification': has_associated_file(
- 'general-operation_modification', negate=True),
- 'parcels-operation_modification': has_associated_file(
- 'general-operation_modification'),
-},
+ condition_dict=ope_modif_condition_dict,
url_name='operation_modification',)