api/chrono: fix cancellation of a rendez-vous with full synchronisation (#78692)
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
b4ee48df65
commit
8ec5582d9b
|
@ -185,7 +185,7 @@ class RendezVousDisponibleView(View):
|
|||
rdv_pks = set()
|
||||
for rdv in rdvs:
|
||||
rdv = self.handle_rdv_payload(lieu, rdv)
|
||||
if full:
|
||||
if full and rdv and rdv.pk:
|
||||
rdv_pks.add(rdv.pk)
|
||||
if full:
|
||||
_, count_by_model = lieu.rdvs.exclude(pk__in=rdv_pks).delete()
|
||||
|
|
|
@ -939,3 +939,72 @@ class TestUpdate:
|
|||
'collectivites_updated': 1,
|
||||
'lieux_updated': 1,
|
||||
}
|
||||
|
||||
|
||||
def test_annulation_rdv_full(django_app, db):
|
||||
Raccordement.objects.create(name='plateforme', apikey='abcd')
|
||||
django_app.set_authorization(('Basic', ('abcd', '')))
|
||||
|
||||
response = django_app.post_json(
|
||||
'/api/chrono/rendez-vous-disponibles/',
|
||||
params={
|
||||
'collectivites': [
|
||||
{
|
||||
'id': 'col1',
|
||||
'nom': 'Saint-Didier',
|
||||
'url': 'https://saint-didier.fr/rdv2/',
|
||||
'logo_url': 'https://saint-didier.fr/logo.png',
|
||||
'lieux': [
|
||||
{
|
||||
'id': 'lieu1',
|
||||
'nom': 'Mairie de Saint-Didier',
|
||||
'numero_rue': '2 rue du four',
|
||||
'code_postal': '99999',
|
||||
'ville': 'Saint-Didier',
|
||||
'longitude': 1.5,
|
||||
'latitude': 2.3,
|
||||
'full': True,
|
||||
'rdvs': [
|
||||
{
|
||||
'id': 'abcd',
|
||||
'date': '2023-03-20T15:00:00+02:00',
|
||||
}
|
||||
],
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
},
|
||||
)
|
||||
assert rdv_response(response) == {
|
||||
'collectivites_created': 1,
|
||||
'lieux_created': 1,
|
||||
'rdv_created': 1,
|
||||
}
|
||||
|
||||
response = django_app.post_json(
|
||||
'/api/chrono/rendez-vous-disponibles/',
|
||||
params={
|
||||
'collectivites': [
|
||||
{
|
||||
'id': 'col1',
|
||||
'lieux': [
|
||||
{
|
||||
'id': 'lieu1',
|
||||
'full': True,
|
||||
'rdvs': [
|
||||
{
|
||||
'id': 'abcd',
|
||||
'date': '2023-03-20T15:00:00+02:00',
|
||||
'annule': True,
|
||||
}
|
||||
],
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
},
|
||||
)
|
||||
assert rdv_response(response) == {
|
||||
'rdv_deleted': 1,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue