From 246e14e7e4767c94da4ac11f6f0eedaaea2fb876 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Wed, 8 Sep 2021 12:24:15 +0200 Subject: [PATCH] misc: add event duration in export and api (#56786) --- chrono/agendas/models.py | 1 + chrono/api/views.py | 1 + tests/api/test_event.py | 1 + tests/test_import_export.py | 2 ++ 4 files changed, 5 insertions(+) diff --git a/chrono/agendas/models.py b/chrono/agendas/models.py index f6a07961..def9f2e9 100644 --- a/chrono/agendas/models.py +++ b/chrono/agendas/models.py @@ -1542,6 +1542,7 @@ class Event(models.Model): 'description': self.description, 'url': self.url, 'pricing': self.pricing, + 'duration': self.duration, } def duplicate(self, agenda_target=None): diff --git a/chrono/api/views.py b/chrono/api/views.py index 35d2d2e7..1baabfc5 100644 --- a/chrono/api/views.py +++ b/chrono/api/views.py @@ -469,6 +469,7 @@ def get_event_detail( 'description': event.description, 'pricing': event.pricing, 'url': event.url, + 'duration': event.duration, 'disabled': is_event_disabled(event, min_places=min_places, disable_booked=disable_booked), 'api': { 'bookings_url': request.build_absolute_uri( diff --git a/tests/api/test_event.py b/tests/api/test_event.py index be02efb5..9a6f5d6d 100644 --- a/tests/api/test_event.py +++ b/tests/api/test_event.py @@ -46,6 +46,7 @@ def test_status(app, user): 'pricing': None, 'url': None, 'disabled': False, + 'duration': None, 'api': { 'bookings_url': 'http://testserver/api/agenda/foo-bar/bookings/event-slug/', 'fillslot_url': 'http://testserver/api/agenda/foo-bar/fillslot/event-slug/', diff --git a/tests/test_import_export.py b/tests/test_import_export.py index 3bceaff7..a6d3d5ea 100644 --- a/tests/test_import_export.py +++ b/tests/test_import_export.py @@ -186,6 +186,7 @@ def test_import_export_event_details(app): publication_date=datetime.date(2020, 5, 11), places=42, start_datetime=now(), + duration=30, ) # check event (agenda, slug) unicity agenda2 = Agenda.objects.create(label='Foo Bar 2', kind='events') @@ -214,6 +215,7 @@ def test_import_export_event_details(app): assert first_imported_event.pricing == '100' assert first_imported_event.url == 'https://example.net/' assert first_imported_event.publication_date == datetime.date(2020, 5, 11) + assert first_imported_event.duration == 30 assert Agenda.objects.get(label='Foo Bar 2').event_set.first().slug == 'event' -- 2.30.2