Projet

Général

Profil

0002-api-dependencies-wscalls-can-be-used-in-conditions-7.patch

Lauréline Guérin, 14 novembre 2022 08:58

Télécharger (4,86 ko)

Voir les différences:

Subject: [PATCH 2/2] api: dependencies, wscalls can be used in conditions
 (#71252)

 tests/api/test_export_import.py | 22 +++++++++++++++++++---
 wcs/fields.py                   |  2 ++
 wcs/workflows.py                |  1 +
 3 files changed, 22 insertions(+), 3 deletions(-)
tests/api/test_export_import.py
116 116
    wscall.store()
117 117
    wscall = NamedWsCall(name='Test bis')
118 118
    wscall.store()
119
    wscall = NamedWsCall(name='Test ter')
120
    wscall.store()
121
    wscall = NamedWsCall(name='Test quater')
122
    wscall.store()
123
    wscall = NamedWsCall(name='Test quinquies')
124
    wscall.store()
119 125

  
120 126
    carddef = CardDef()
121 127
    carddef.name = 'Test'
......
216 222
    send_mail.to = [role.id]
217 223
    send_mail.subject = '{{ webservice.test }}'
218 224
    send_mail.body = '{{ cards|objects:"test" }} {{ forms|objects:"test-ter" }}'
219
    send_mail.condition = {'type': 'django', 'value': '{{ cards|objects:"test-ter" }}'}
225
    send_mail.condition = {
226
        'type': 'django',
227
        'value': '{{ cards|objects:"test-ter" }} {{ webservice.test_ter }}',
228
    }
220 229

  
221 230
    dispatch_auto = status.add_action('dispatch')
222 231
    dispatch_auto.rules = [{'role_id': role.id, 'value': 'xxx'}]
......
234 243
                {
235 244
                    'condition': {
236 245
                        'type': 'django',
237
                        'value': '{{ cards|objects:"test-bis" }} {{ forms|objects:"test-quater" }}',
246
                        'value': '{{ cards|objects:"test-bis" }} {{ forms|objects:"test-quater" }} {{ webservice.test_quater }}',
238 247
                    },
239 248
                    'error_message': 'You shall not pass.',
240 249
                }
......
244 253
            id='1',
245 254
            label='test',
246 255
            type='block:test',
247
            condition={'type': 'django', 'value': '{{ forms|objects:"test-bis" }}'},
256
            condition={
257
                'type': 'django',
258
                'value': '{{ forms|objects:"test-bis" }} {{ webservice.test_quinquies }}',
259
            },
248 260
        ),
249 261
        CommentField(
250 262
            id='2',
......
262 274
        ('test', 'workflows'),
263 275
        ('test', 'blocks'),
264 276
        ('test', 'wscalls'),
277
        ('test_quater', 'wscalls'),
278
        ('test_quinquies', 'wscalls'),
265 279
        ('test', 'cards'),
266 280
        ('test-bis', 'cards'),
267 281
        ('test-bis', 'forms'),
......
279 293
        ('foobar', 'data-sources'),
280 294
        ('test', 'wscalls'),
281 295
        ('test_bis', 'wscalls'),
296
        ('test_ter', 'wscalls'),
282 297
        ('test', 'cards'),
283 298
        ('test-bis', 'cards'),
284 299
        ('test-ter', 'cards'),
......
304 319
    assert {(x['id'], x['type']) for x in resp.json['data']} == {
305 320
        ('foobar', 'data-sources'),
306 321
        ('test_bis', 'wscalls'),
322
        ('test_ter', 'wscalls'),
307 323
        ('test-bis', 'cards'),
308 324
        ('test-ter', 'cards'),
309 325
        ('test-bis', 'forms'),
wcs/fields.py
714 714
            condition = self.condition
715 715
            if condition:
716 716
                if condition.get('type') == 'django':
717
                    yield from check_wscalls(condition.get('value'))
717 718
                    yield from check_carddefs(condition.get('value'))
718 719
                    yield from check_formdefs(condition.get('value'))
719 720

  
......
3070 3071
            for post_condition in post_conditions:
3071 3072
                condition = post_condition.get('condition') or {}
3072 3073
                if condition.get('type') == 'django':
3074
                    yield from check_wscalls(condition.get('value'))
3073 3075
                    yield from check_carddefs(condition.get('value'))
3074 3076
                    yield from check_formdefs(condition.get('value'))
3075 3077

  
wcs/workflows.py
2383 2383
            condition = self.condition
2384 2384
            if condition:
2385 2385
                if condition.get('type') == 'django':
2386
                    yield from check_wscalls(condition.get('value'))
2386 2387
                    yield from check_carddefs(condition.get('value'))
2387 2388
                    yield from check_formdefs(condition.get('value'))
2388 2389

  
2389
-