diff options
Diffstat (limited to 'archaeological_operations/views.py')
-rw-r--r-- | archaeological_operations/views.py | 69 |
1 files changed, 42 insertions, 27 deletions
diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index c4e4acb5e..9b420f594 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2010-2016 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2010-2017 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -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',) |