Projet

Général

Profil

0002-api-display-minimal_booking_delay_in_working_days-on.patch

Nicolas Roche, 28 septembre 2021 18:48

Télécharger (6,99 ko)

Voir les différences:

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

 chrono/api/views.py   | 1 +
 tests/api/test_all.py | 7 +++++++
 2 files changed, 8 insertions(+)
chrono/api/views.py
355 355
    else:
356 356
        view_role = None
357 357
    agenda_detail = {
358 358
        'id': agenda.slug,
359 359
        'slug': agenda.slug,  # kept for compatibility
360 360
        'text': agenda.label,
361 361
        'kind': agenda.kind,
362 362
        'minimal_booking_delay': agenda.minimal_booking_delay,
363
        'minimal_booking_delay_in_working_days': agenda.minimal_booking_delay_in_working_days,
363 364
        'maximal_booking_delay': agenda.maximal_booking_delay,
364 365
        'edit_role': edit_role,
365 366
        'view_role': view_role,
366 367
    }
367 368

  
368 369
    if agenda.kind == 'meetings':
369 370
        agenda_detail['resources'] = [
370 371
            {'id': r.slug, 'text': r.label, 'description': r.description} for r in agenda.resources.all()
tests/api/test_all.py
58 58
        'err': 0,
59 59
        'data': [
60 60
            {
61 61
                'text': 'Foo bar',
62 62
                'id': 'foo-bar',
63 63
                'slug': 'foo-bar',
64 64
                'kind': 'events',
65 65
                'minimal_booking_delay': 1,
66
                'minimal_booking_delay_in_working_days': False,
66 67
                'maximal_booking_delay': 56,
67 68
                'edit_role': 'Edit',
68 69
                'view_role': None,
69 70
                'absence_reasons': [
70 71
                    {'id': reason.slug, 'slug': reason.slug, 'text': reason.label, 'label': reason.label},
71 72
                    {'id': reason2.slug, 'slug': reason2.slug, 'text': reason2.label, 'label': reason2.label},
72 73
                ],
73 74
                'api': {
......
76 77
                },
77 78
            },
78 79
            {
79 80
                'text': 'Foo bar 2',
80 81
                'id': 'foo-bar-2',
81 82
                'kind': 'events',
82 83
                'slug': 'foo-bar-2',
83 84
                'minimal_booking_delay': 1,
85
                'minimal_booking_delay_in_working_days': False,
84 86
                'maximal_booking_delay': 56,
85 87
                'edit_role': None,
86 88
                'view_role': None,
87 89
                'api': {
88 90
                    'datetimes_url': 'http://testserver/api/agenda/foo-bar-2/datetimes/',
89 91
                    'fillslots_url': 'http://testserver/api/agenda/foo-bar-2/fillslots/',
90 92
                },
91 93
            },
92 94
            {
93 95
                'text': 'Foo bar 3',
94 96
                'id': 'foo-bar-3',
95 97
                'kind': 'events',
96 98
                'slug': 'foo-bar-3',
97 99
                'minimal_booking_delay': 1,
100
                'minimal_booking_delay_in_working_days': False,
98 101
                'maximal_booking_delay': 56,
99 102
                'edit_role': None,
100 103
                'view_role': None,
101 104
                'absence_reasons': [
102 105
                    {'id': reason.slug, 'slug': reason.slug, 'text': reason.label, 'label': reason.label},
103 106
                    {'id': reason2.slug, 'slug': reason2.slug, 'text': reason2.label, 'label': reason2.label},
104 107
                ],
105 108
                'api': {
......
107 110
                    'fillslots_url': 'http://testserver/api/agenda/foo-bar-3/fillslots/',
108 111
                },
109 112
            },
110 113
            {
111 114
                'text': 'Foo bar Meeting',
112 115
                'id': 'foo-bar-meeting',
113 116
                'slug': 'foo-bar-meeting',
114 117
                'minimal_booking_delay': 1,
118
                'minimal_booking_delay_in_working_days': False,
115 119
                'maximal_booking_delay': 56,
116 120
                'edit_role': None,
117 121
                'view_role': 'View',
118 122
                'kind': 'meetings',
119 123
                'resources': [
120 124
                    {'id': 'resource-1', 'text': 'Resource 1', 'description': 'Foo bar Resource 1'},
121 125
                    {'id': 'resource-2', 'text': 'Resource 2', 'description': 'Foo bar Resource 2'},
122 126
                ],
......
127 131
                    'fillslots_url': 'http://testserver/api/agenda/foo-bar-meeting/fillslots/',
128 132
                },
129 133
            },
130 134
            {
131 135
                'text': 'Foo bar Meeting 2',
132 136
                'id': 'foo-bar-meeting-2',
133 137
                'slug': 'foo-bar-meeting-2',
134 138
                'minimal_booking_delay': 1,
139
                'minimal_booking_delay_in_working_days': False,
135 140
                'maximal_booking_delay': 56,
136 141
                'edit_role': None,
137 142
                'view_role': None,
138 143
                'kind': 'meetings',
139 144
                'resources': [],
140 145
                'api': {
141 146
                    'meetings_url': 'http://testserver/api/agenda/foo-bar-meeting-2/meetings/',
142 147
                    'desks_url': 'http://testserver/api/agenda/foo-bar-meeting-2/desks/',
......
144 149
                    'fillslots_url': 'http://testserver/api/agenda/foo-bar-meeting-2/fillslots/',
145 150
                },
146 151
            },
147 152
            {
148 153
                'text': 'Virtual Agenda',
149 154
                'id': 'virtual-agenda',
150 155
                'slug': 'virtual-agenda',
151 156
                'minimal_booking_delay': 1,
157
                'minimal_booking_delay_in_working_days': False,
152 158
                'maximal_booking_delay': 56,
153 159
                'edit_role': 'Edit',
154 160
                'view_role': 'View',
155 161
                'kind': 'virtual',
156 162
                'api': {
157 163
                    'meetings_url': 'http://testserver/api/agenda/virtual-agenda/meetings/',
158 164
                    'desks_url': 'http://testserver/api/agenda/virtual-agenda/desks/',
159 165
                    'fillslots_url': 'http://testserver/api/agenda/virtual-agenda/fillslots/',
......
493 499
def test_virtual_agenda_detail(app, virtual_meetings_agenda):
494 500
    resp = app.get('/api/agenda/%s/' % virtual_meetings_agenda.slug)
495 501
    assert resp.json == {
496 502
        'data': {
497 503
            'text': 'Virtual Agenda',
498 504
            'id': 'virtual-agenda',
499 505
            'slug': 'virtual-agenda',
500 506
            'minimal_booking_delay': None,
507
            'minimal_booking_delay_in_working_days': False,
501 508
            'maximal_booking_delay': None,
502 509
            'edit_role': None,
503 510
            'view_role': None,
504 511
            'kind': 'virtual',
505 512
            'api': {
506 513
                'meetings_url': 'http://testserver/api/agenda/%s/meetings/' % virtual_meetings_agenda.slug,
507 514
                'desks_url': 'http://testserver/api/agenda/%s/desks/' % virtual_meetings_agenda.slug,
508 515
                'fillslots_url': 'http://testserver/api/agenda/%s/fillslots/' % virtual_meetings_agenda.slug,
509
-