From d4d3616ce351e6c0d424659d7fb9131870639cb7 Mon Sep 17 00:00:00 2001 From: Serghei Mihai Date: Thu, 30 Aug 2018 13:40:08 +0200 Subject: [PATCH] manager: allow timeperiod exceptions with the same summary if event uid defined (#25962) --- chrono/agendas/models.py | 2 +- tests/test_manager.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/chrono/agendas/models.py b/chrono/agendas/models.py index 16a2f06..e266724 100644 --- a/chrono/agendas/models.py +++ b/chrono/agendas/models.py @@ -528,7 +528,7 @@ class Desk(models.Model): kwargs = {} kwargs['desk'] = self - if keep_synced_by_uid: + if 'uid' in vevent.contents or keep_synced_by_uid: kwargs['external_id'] = vevent.contents['uid'][0].value else: kwargs['label'] = summary diff --git a/tests/test_manager.py b/tests/test_manager.py index 7f3c863..ff41e4c 100644 --- a/tests/test_manager.py +++ b/tests/test_manager.py @@ -987,6 +987,11 @@ DTSTART:20180101 DTEND:20180101 SUMMARY:New Year's Eve END:VEVENT +BEGIN:VEVENT +DTSTART:20190101 +DTEND:20190101 +SUMMARY:New Year's Eve +END:VEVENT END:VCALENDAR""" resp = app.get('/manage/agendas/%d/' % agenda.pk).follow() resp = resp.click('Settings') @@ -996,6 +1001,26 @@ END:VCALENDAR""" assert TimePeriodException.objects.filter(desk=desk).count() == 1 resp = resp.follow() assert 'An exception has been imported.' in resp.text + ics_with_exceptions_with_uids = b"""BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//foo.bar//EN +BEGIN:VEVENT +DTSTART:20180101 +UID:31f3f68e +DTEND:20180101 +SUMMARY:New Year's Eve +END:VEVENT +BEGIN:VEVENT +UID:31f3f68c +DTSTART:20190101 +DTEND:20190101 +SUMMARY:New Year's Eve +END:VEVENT +END:VCALENDAR""" + resp = resp.click('upload') + resp.form['ics_file'] = Upload('exceptions.ics', ics_with_exceptions_with_uids, 'text/calendar') + resp = resp.form.submit(status=302) + assert TimePeriodException.objects.filter(desk=desk, label='New Year\'s Eve').count() == 3 @pytest.mark.freeze_time('2017-12-01') -- 2.19.0.rc1