allow value 5 for documents_number
gitea/ants-hub/pipeline/head This commit looks good
Details
gitea/ants-hub/pipeline/head This commit looks good
Details
This commit is contained in:
parent
cafe298c22
commit
67e5c8578c
|
@ -167,7 +167,7 @@
|
|||
"type": "number",
|
||||
"description": "Nombre maximum de personnes pour ces rendez-vous",
|
||||
"minimum": 1,
|
||||
"maximum": 4
|
||||
"maximum": 5
|
||||
},
|
||||
"types_rdv": {
|
||||
"type": "array",
|
||||
|
|
|
@ -120,7 +120,7 @@ def available_time_slots_parse_qs(request):
|
|||
except KeyError:
|
||||
reason = TypeDeRdv.CNI
|
||||
try:
|
||||
documents_number = min(int(request.GET.get('documents_number', '').strip()), 4)
|
||||
documents_number = min(int(request.GET.get('documents_number', '').strip()), 5)
|
||||
except (ValueError, TypeError):
|
||||
documents_number = 1
|
||||
return meeting_point_ids, start_date, end_date, reason, documents_number
|
||||
|
|
|
@ -54,18 +54,26 @@ def authenticate(func):
|
|||
if not header:
|
||||
logger.warning('authentication failed, missing Authorization header')
|
||||
return Http401("Missing Authorization header")
|
||||
auth = header.split()
|
||||
if not auth or auth[0].lower() != b'basic' or len(auth) != 2:
|
||||
auth = header.split(maxsplit=1)
|
||||
if not auth or auth[0].lower() not in [b'basic', b'bearer'] or len(auth) != 2:
|
||||
logger.warning('authentication failed, invalid Authorization header')
|
||||
return Http401("Invalid Authorization header")
|
||||
|
||||
try:
|
||||
auth_decoded = base64.b64decode(auth[1]).decode()
|
||||
except (TypeError, UnicodeDecodeError, binascii.Error):
|
||||
logger.warning('authentication failed, invalid Authorization header')
|
||||
return Http401("Invalid Authorization header")
|
||||
if auth[0].lower() == b'basic':
|
||||
try:
|
||||
auth_decoded = base64.b64decode(auth[1]).decode()
|
||||
except (TypeError, UnicodeDecodeError, binascii.Error):
|
||||
logger.warning('authentication failed, invalid Authorization header')
|
||||
return Http401("Invalid Authorization header")
|
||||
|
||||
apikey = auth_decoded.split(':', 1)[0]
|
||||
apikey = auth_decoded.split(':', 1)[0]
|
||||
else:
|
||||
assert auth[0].lower() == b'bearer'
|
||||
try:
|
||||
apikey = auth[1].decode()
|
||||
except UnicodeDecodeError:
|
||||
logger.warning('authentication failed, invalid Authorization header')
|
||||
return Http401("Invalid Authorization header")
|
||||
raccordement = Raccordement.objects.get_by_apikey(apikey)
|
||||
|
||||
if not raccordement:
|
||||
|
|
|
@ -225,7 +225,7 @@ class Migration(migrations.Migration):
|
|||
default=1,
|
||||
validators=[
|
||||
django.core.validators.MinValueValidator(1),
|
||||
django.core.validators.MaxValueValidator(4),
|
||||
django.core.validators.MaxValueValidator(5),
|
||||
],
|
||||
verbose_name='Nombre de personnes maximum',
|
||||
),
|
||||
|
|
|
@ -340,7 +340,7 @@ class Plage(models.Model):
|
|||
personnes = models.SmallIntegerField(
|
||||
verbose_name='Nombre de personnes maximum',
|
||||
default=1,
|
||||
validators=[MinValueValidator(1), MaxValueValidator(4)],
|
||||
validators=[MinValueValidator(1), MaxValueValidator(5)],
|
||||
)
|
||||
created = models.DateTimeField(verbose_name='Création', auto_now_add=True)
|
||||
last_update = models.DateTimeField(verbose_name='Dernière mise à jour', auto_now=True)
|
||||
|
|
|
@ -156,6 +156,7 @@ class TestEndpoints:
|
|||
Plage.objects.create(**kwargs, personnes=2, horaires='10:30+02:00-11:00+02:00')
|
||||
Plage.objects.create(**kwargs, personnes=3, horaires='11:00+02:00-11:30+02:00')
|
||||
Plage.objects.create(**kwargs, personnes=4, horaires='12:00+02:00-12:30+02:00')
|
||||
Plage.objects.create(**kwargs, personnes=5, horaires='12:30+02:00-13:00+02:00')
|
||||
|
||||
# default is 1 person
|
||||
response = django_app.get(
|
||||
|
@ -205,18 +206,18 @@ class TestEndpoints:
|
|||
assert len(response.json[str(lieu.id)]) == 1
|
||||
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T11:00:00Z'}
|
||||
|
||||
# implicit maximum is 4
|
||||
# implicit maximum is 5
|
||||
response = django_app.get(
|
||||
'/api/ants/availableTimeSlots',
|
||||
params={
|
||||
'meeting_point_ids': str(lieu.id),
|
||||
'start_date': '2023-04-03',
|
||||
'end_date': '2023-04-05',
|
||||
'documents_number': 5,
|
||||
'documents_number': 6,
|
||||
},
|
||||
)
|
||||
assert len(response.json[str(lieu.id)]) == 1
|
||||
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T12:00:00Z'}
|
||||
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T12:30:00Z'}
|
||||
|
||||
def test_search_application_ids(self, db, django_app, lieu):
|
||||
RendezVous.objects.create(
|
||||
|
|
Loading…
Reference in New Issue