Compare commits
1 Commits
57e26d83f9
...
e1aad892e1
Author | SHA1 | Date |
---|---|---|
Frédéric Péters | e1aad892e1 |
|
@ -3160,29 +3160,15 @@ class Booking(models.Model):
|
|||
r = requests_wrapper.post(self.cancel_callback_url, remote_service='auto', timeout=15)
|
||||
r.raise_for_status()
|
||||
|
||||
def accept(self, request=None):
|
||||
def accept(self):
|
||||
self.in_waiting_list = False
|
||||
with transaction.atomic():
|
||||
audit(
|
||||
'booking',
|
||||
_('acceptation of booking (%(booking_id)s) in event "%(event)s"')
|
||||
% {'booking_id': self.id, 'event': self.event},
|
||||
request=request,
|
||||
agenda=self.event.agenda,
|
||||
)
|
||||
self.secondary_booking_set.update(in_waiting_list=False)
|
||||
self.save()
|
||||
|
||||
def suspend(self, request=None):
|
||||
def suspend(self):
|
||||
self.in_waiting_list = True
|
||||
with transaction.atomic():
|
||||
audit(
|
||||
'booking',
|
||||
_('suspension of booking (%(booking_id)s) in event "%(event)s"')
|
||||
% {'booking_id': self.id, 'event': self.event},
|
||||
request=request,
|
||||
agenda=self.event.agenda,
|
||||
)
|
||||
self.secondary_booking_set.update(in_waiting_list=True)
|
||||
self.save()
|
||||
|
||||
|
|
|
@ -3024,8 +3024,16 @@ class AcceptBooking(APIView):
|
|||
raise APIError(N_('secondary booking'), err=2)
|
||||
if not booking.in_waiting_list:
|
||||
raise APIError(N_('booking is not in waiting list'), err=3)
|
||||
booking.accept(request=request)
|
||||
booking.accept()
|
||||
event = booking.event
|
||||
audit(
|
||||
'booking',
|
||||
_('acceptation of booking (%(booking_id)s) in event "%(event)s"')
|
||||
% {'booking_id': booking.id, 'event': event},
|
||||
request=request,
|
||||
agenda=event.agenda,
|
||||
)
|
||||
|
||||
response = {
|
||||
'err': 0,
|
||||
'booking_id': booking.pk,
|
||||
|
@ -3056,7 +3064,15 @@ class SuspendBooking(APIView):
|
|||
raise APIError(N_('secondary booking'), err=2)
|
||||
if booking.in_waiting_list:
|
||||
raise APIError(N_('booking is already in waiting list'), err=3)
|
||||
booking.suspend(request=request)
|
||||
booking.suspend()
|
||||
audit(
|
||||
'booking',
|
||||
_('suspension of booking (%(booking_id)s) in event "%(event)s"')
|
||||
% {'booking_id': booking.id, 'event': event},
|
||||
request=request,
|
||||
agenda=event.agenda,
|
||||
)
|
||||
|
||||
response = {'err': 0, 'booking_id': booking.pk}
|
||||
return Response(response)
|
||||
|
||||
|
|
|
@ -1248,7 +1248,7 @@ def test_agenda_meeting_api_multiple_desk(app, user):
|
|||
|
||||
with CaptureQueriesContext(connection) as ctx:
|
||||
resp = app.post('/api/agenda/%s/fillslot/%s/' % (agenda.pk, event_id))
|
||||
assert len(ctx.captured_queries) == 18
|
||||
assert len(ctx.captured_queries) == 19
|
||||
|
||||
assert resp_booking.json['datetime'] == localtime(Booking.objects.last().event.start_datetime).strftime(
|
||||
'%Y-%m-%d %H:%M:%S'
|
||||
|
|
Loading…
Reference in New Issue