api: support overlapping events (#44644)
This commit is contained in:
parent
cedd70dbee
commit
4dc5481456
|
@ -169,7 +169,7 @@ def get_all_slots(base_agenda, meeting_type, resources=None, unique=False):
|
|||
)
|
||||
.exclude(booking__cancellation_datetime__isnull=False)
|
||||
# ordering is important for the later groupby, it works like sort | uniq
|
||||
.order_by('desk_id', 'start_datetime')
|
||||
.order_by('desk_id', 'start_datetime', 'meeting_type__duration')
|
||||
.values_list('desk_id', 'start_datetime', 'meeting_type__duration')
|
||||
)
|
||||
# compute exclusion set by desk from all bookings, using
|
||||
|
|
|
@ -3074,6 +3074,38 @@ def test_datetimes_api_meetings_agenda_start_hour_change(app, meetings_agenda):
|
|||
assert len([x for x in resp.json['data'] if x['disabled']]) == 2
|
||||
|
||||
|
||||
def test_datetimes_api_concurrent_bookings(app, user, meetings_agenda):
|
||||
meeting_type = MeetingType.objects.get(agenda=meetings_agenda)
|
||||
api_url = '/api/agenda/%s/meetings/%s/datetimes/' % (meeting_type.agenda.slug, meeting_type.slug)
|
||||
assert Booking.objects.count() == 0
|
||||
resp = app.get(api_url)
|
||||
assert resp.json['data'][0]['datetime'] == '2017-05-22 10:00:00'
|
||||
|
||||
# make a booking
|
||||
fillslot_url = resp.json['data'][0]['api']['fillslot_url']
|
||||
app.authorization = ('Basic', ('john.doe', 'password'))
|
||||
resp = app.post(fillslot_url)
|
||||
assert Booking.objects.count() == 1
|
||||
|
||||
# make a second one artificially on an overlapping slot
|
||||
meeting_type = MeetingType.objects.create(agenda=meetings_agenda, label='Boo', duration=8)
|
||||
booking = Booking.objects.first()
|
||||
event = booking.event
|
||||
new_event = Event.objects.create(
|
||||
meeting_type=meeting_type,
|
||||
start_datetime=event.start_datetime,
|
||||
desk=event.desk,
|
||||
places=event.places,
|
||||
agenda=meetings_agenda,
|
||||
)
|
||||
Booking.objects.create(event=new_event)
|
||||
|
||||
# should not crash and slot not showing up
|
||||
resp = app.get(api_url)
|
||||
assert resp.json['data'][0]['datetime'] == '2017-05-22 10:00:00'
|
||||
assert resp.json['data'][0]['disabled'] is True
|
||||
|
||||
|
||||
def test_agenda_detail_routing(app, meetings_agenda):
|
||||
api_url = '/api/agenda/%s/' % meetings_agenda.slug
|
||||
resp = app.get(api_url)
|
||||
|
|
Loading…
Reference in New Issue