api: include end_datetime for partial bookings events (#78056)
gitea/chrono/pipeline/head This commit looks good
Details
gitea/chrono/pipeline/head This commit looks good
Details
This commit is contained in:
parent
2a776007e0
commit
18470cb6be
|
@ -2291,6 +2291,11 @@ class Event(models.Model):
|
|||
|
||||
@property
|
||||
def end_datetime(self):
|
||||
if self.end_time:
|
||||
return localtime(self.start_datetime).replace(
|
||||
hour=self.end_time.hour, minute=self.end_time.minute
|
||||
)
|
||||
|
||||
if self.meeting_type:
|
||||
minutes = self.meeting_type.duration
|
||||
else:
|
||||
|
|
|
@ -1555,3 +1555,16 @@ def test_events_datetimes_max_booking_datetime_with_minimal_booking_time_to_none
|
|||
resp = app.get(api_url)
|
||||
assert resp.json['data'][-2]['datetime'] == '2023-04-05 09:00:00'
|
||||
assert resp.json['data'][-1]['datetime'] == '2023-04-05 11:00:00'
|
||||
|
||||
|
||||
@pytest.mark.freeze_time('2023-05-01')
|
||||
def test_events_datetime_partial_bookings_end_datetime(app, user):
|
||||
agenda = Agenda.objects.create(label='Foo bar', kind='events', partial_bookings=True)
|
||||
start_datetime = make_aware(datetime.datetime(2023, 5, 2, 8, 0))
|
||||
Event.objects.create(
|
||||
label='Event', start_datetime=start_datetime, end_time=datetime.time(18, 00), places=10, agenda=agenda
|
||||
)
|
||||
|
||||
resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug)
|
||||
assert resp.json['data'][0]['datetime'] == '2023-05-02 08:00:00'
|
||||
assert resp.json['data'][0]['end_datetime'] == '2023-05-02 18:00:00'
|
||||
|
|
Loading…
Reference in New Issue