Fix booking slots order
This commit is contained in:
parent
9d4a672d67
commit
70b2110744
|
|
@ -14,6 +14,12 @@ class CheckWhetherBookingAvailable(generics.GenericAPIView):
|
||||||
""" Checks which service to use if establishmend is managed by any """
|
""" Checks which service to use if establishmend is managed by any """
|
||||||
|
|
||||||
_VALID_GUESTONLINE_PERIODS = {'lunch', 'dinner', 'afternoon', 'breakfast'}
|
_VALID_GUESTONLINE_PERIODS = {'lunch', 'dinner', 'afternoon', 'breakfast'}
|
||||||
|
_GUESTONLINE_PERIODS_TO_PRIOR = {
|
||||||
|
'breakfast': 1,
|
||||||
|
'lunch': 2,
|
||||||
|
'afternoon': 3,
|
||||||
|
'dinner': 4,
|
||||||
|
}
|
||||||
|
|
||||||
permission_classes = (permissions.AllowAny,)
|
permission_classes = (permissions.AllowAny,)
|
||||||
serializer_class = CheckBookingSerializer
|
serializer_class = CheckBookingSerializer
|
||||||
|
|
@ -32,7 +38,7 @@ class CheckWhetherBookingAvailable(generics.GenericAPIView):
|
||||||
|
|
||||||
period_template = iter(periods_by_name.values()).__next__().copy()
|
period_template = iter(periods_by_name.values()).__next__().copy()
|
||||||
period_template.pop('total_left_seats')
|
period_template.pop('total_left_seats')
|
||||||
period_template.pop('hours')
|
period_template['hours'] = []
|
||||||
period_template.pop('period')
|
period_template.pop('period')
|
||||||
|
|
||||||
processed_periods = [
|
processed_periods = [
|
||||||
|
|
@ -46,7 +52,8 @@ class CheckWhetherBookingAvailable(generics.GenericAPIView):
|
||||||
for unnamed_period in unnamed_periods:
|
for unnamed_period in unnamed_periods:
|
||||||
processed_periods.append(unnamed_period)
|
processed_periods.append(unnamed_period)
|
||||||
|
|
||||||
response['periods'] = processed_periods
|
response['periods'] = sorted(processed_periods,
|
||||||
|
key=lambda x: self._GUESTONLINE_PERIODS_TO_PRIOR[x.get('period', 'lunch')])
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user