Projet

Général

Profil

0002-api-display-minimal_booking_delay_in_working_days-on.patch

Nicolas Roche, 05 octobre 2021 18:35

Télécharger (3,64 ko)

Voir les différences:

Subject: [PATCH 2/3] api: display minimal_booking_delay_in_working_days on
 meetings agenda details (#57103)

 chrono/api/views.py   | 1 +
 tests/api/test_all.py | 3 +++
 2 files changed, 4 insertions(+)
chrono/api/views.py
357 357
        'view_role': agenda.view_role.name if agenda.view_role else None,
358 358
    }
359 359

  
360 360
    if agenda.kind == 'meetings':
361 361
        agenda_detail['resources'] = [
362 362
            {'id': r.slug, 'text': r.label, 'description': r.description} for r in agenda.resources.all()
363 363
        ]
364 364
    if agenda.kind == 'events':
365
        agenda_detail['minimal_booking_delay_in_working_days'] = agenda.minimal_booking_delay_in_working_days
365 366
        agenda_detail['api'] = {
366 367
            'datetimes_url': request.build_absolute_uri(
367 368
                reverse('api-agenda-datetimes', kwargs={'agenda_identifier': agenda.slug})
368 369
            )
369 370
        }
370 371
        if check_events:
371 372
            agenda_detail['opened_events_available'] = bool(agenda.get_open_events(include_full=False))
372 373
        if agenda.absence_reasons_group:
tests/api/test_all.py
59 59
        'err': 0,
60 60
        'data': [
61 61
            {
62 62
                'text': 'Foo bar',
63 63
                'id': 'foo-bar',
64 64
                'slug': 'foo-bar',
65 65
                'kind': 'events',
66 66
                'minimal_booking_delay': 1,
67
                'minimal_booking_delay_in_working_days': False,
67 68
                'maximal_booking_delay': 56,
68 69
                'edit_role': 'Edit',
69 70
                'view_role': None,
70 71
                'absence_reasons': [
71 72
                    {'id': reason.slug, 'slug': reason.slug, 'text': reason.label, 'label': reason.label},
72 73
                    {'id': reason2.slug, 'slug': reason2.slug, 'text': reason2.label, 'label': reason2.label},
73 74
                ],
74 75
                'api': {
......
77 78
                },
78 79
            },
79 80
            {
80 81
                'text': 'Foo bar 2',
81 82
                'id': 'foo-bar-2',
82 83
                'kind': 'events',
83 84
                'slug': 'foo-bar-2',
84 85
                'minimal_booking_delay': 1,
86
                'minimal_booking_delay_in_working_days': False,
85 87
                'maximal_booking_delay': 56,
86 88
                'edit_role': None,
87 89
                'view_role': None,
88 90
                'api': {
89 91
                    'datetimes_url': 'http://testserver/api/agenda/foo-bar-2/datetimes/',
90 92
                    'fillslots_url': 'http://testserver/api/agenda/foo-bar-2/fillslots/',
91 93
                },
92 94
            },
93 95
            {
94 96
                'text': 'Foo bar 3',
95 97
                'id': 'foo-bar-3',
96 98
                'kind': 'events',
97 99
                'slug': 'foo-bar-3',
98 100
                'minimal_booking_delay': 1,
101
                'minimal_booking_delay_in_working_days': False,
99 102
                'maximal_booking_delay': 56,
100 103
                'edit_role': None,
101 104
                'view_role': None,
102 105
                'absence_reasons': [
103 106
                    {'id': reason.slug, 'slug': reason.slug, 'text': reason.label, 'label': reason.label},
104 107
                    {'id': reason2.slug, 'slug': reason2.slug, 'text': reason2.label, 'label': reason2.label},
105 108
                ],
106 109
                'api': {
107
-