Projet

Général

Profil

0001-misc-use-lazy-mode-for-global-action-expression-date.patch

Frédéric Péters, 09 mai 2020 10:58

Télécharger (2,56 ko)

Voir les différences:

Subject: [PATCH] misc: use lazy mode for global action expression date
 template (#42672)

 tests/test_workflows.py | 17 +++++++++++++++++
 wcs/workflows.py        |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
tests/test_workflows.py
40 40
        DisplayMessageWorkflowStatusItem,
41 41
        AbortActionException, WorkflowCriticalityLevel,
42 42
        AttachmentEvolutionPart, WorkflowBackofficeFieldsFormDef,
43
        WorkflowVariablesFieldsFormDef,
43 44
        perform_items)
44 45
from wcs.wf.aggregation_email import (AggregationEmailWorkflowStatusItem,
45 46
        AggregationEmail, send_aggregation_emails)
......
3475 3476
    assert formdef.data_class().get(formdata1.id).get_criticality_level_object().name == 'yellow'
3476 3477
    formdata1.store()
3477 3478

  
3479
    # django template (from form_option_)
3480
    workflow.variables_formdef = WorkflowVariablesFieldsFormDef(workflow=workflow)
3481
    workflow.variables_formdef.fields = [
3482
            DateField(id='4', label='Date', type='date', varname='date'),
3483
    ]
3484
    trigger.anchor = 'template'
3485
    trigger.anchor_template = '{{ form_option_date }}'
3486
    workflow.store()
3487
    formdef.workflow_options = {
3488
        'date': time.strptime('2015-05-12', '%Y-%m-%d'),
3489
    }
3490
    formdef.store()
3491
    pub.apply_global_action_timeouts()
3492
    assert formdef.data_class().get(formdata1.id).get_criticality_level_object().name == 'yellow'
3493
    formdata1.store()
3494

  
3478 3495

  
3479 3496
def test_global_timeouts_latest_arrival(two_pubs):
3480 3497
    pub = two_pubs
wcs/workflows.py
1194 1194
                    else:
1195 1195
                        break
1196 1196
        elif self.anchor == 'template':
1197
            variables = get_publisher().substitutions.get_context_variables()
1197
            variables = get_publisher().substitutions.get_context_variables(mode='lazy')
1198 1198
            anchor_date = Template(self.anchor_template, autoescape=False).render(variables)
1199 1199
        elif self.anchor == 'python':
1200 1200
            variables = get_publisher().substitutions.get_context_variables()
1201
-