Projet

Général

Profil

0002-manager-refine-messages-when-adding-exception-47393.patch

Emmanuel Cazenave, 05 novembre 2020 12:01

Télécharger (3,19 ko)

Voir les différences:

Subject: [PATCH 2/2] manager: refine messages when adding exception (#47393)

 chrono/manager/views.py | 9 +++------
 tests/test_manager.py   | 9 ++++++---
 2 files changed, 9 insertions(+), 9 deletions(-)
chrono/manager/views.py
1909 1909
                        end_datetime=self.object.end_datetime,
1910 1910
                    )
1911 1911
                )
1912
        message = ungettext('Exception added.', 'Exceptions added.', len(exceptions),)
1913
        messages.info(self.request, message)
1912 1914
        for exception in exceptions:
1913 1915
            if exception.has_booking_within_time_slot():
1914
                message = ungettext(
1915
                    'Exception added. Note: one or several bookings exists within this time slot.',
1916
                    'Exceptions added. Note: one or several bookings exists within this time slot.',
1917
                    len(exceptions),
1918
                )
1919
                messages.info(self.request, message)
1916
                messages.warning(self.request, _('One or several bookings exists within this time slot.'))
1920 1917
                break
1921 1918
        return result
1922 1919

  
tests/test_manager.py
2148 2148
    resp.form['all_desks'] = True
2149 2149
    resp = resp.form.submit().follow()
2150 2150
    assert TimePeriodException.objects.count() == 4
2151
    assert 'Exceptions added. Note: one or several bookings exists within this time slot.' in resp.text
2151
    assert 'Exceptions added.' in resp.text
2152
    assert 'One or several bookings exists within this time slot.' in resp.text
2152 2153

  
2153 2154
    exception = TimePeriodException.objects.first()
2154 2155
    resp = app.get('/manage/time-period-exceptions/%s/edit' % exception.pk)
......
2173 2174
    resp.form['all_desks'] = False
2174 2175
    resp = resp.form.submit().follow()
2175 2176
    assert TimePeriodException.objects.count() == 5
2176
    assert 'Exception added. Note: one or several bookings exists within this time slot.' in resp.text
2177
    assert 'Exception added.' in resp.text
2178
    assert 'One or several bookings exists within this time slot.' in resp.text
2177 2179

  
2178 2180

  
2179 2181
def test_meetings_agenda_add_time_period_exception_when_booking_exists(app, admin_user):
......
2199 2201
    resp.form['end_datetime_0'] = '2017-05-26'
2200 2202
    resp.form['end_datetime_1'] = '17:30'
2201 2203
    resp = resp.form.submit().follow()
2202
    assert 'Exception added. Note: one or several bookings exists within this time slot.' in resp.text
2204
    assert 'Exception added.' in resp.text
2205
    assert 'One or several bookings exists within this time slot.' in resp.text
2203 2206
    assert TimePeriodException.objects.count() == 1
2204 2207

  
2205 2208

  
2206
-