nanterre: allow partial updates
This commit is contained in:
parent
39c01c86d5
commit
b7a7dbedc6
|
@ -84,31 +84,7 @@ def test_create_individu(app, rsu_schema):
|
|||
'identifier': first_id})
|
||||
|
||||
response = app.post_json(update_url, {
|
||||
'prenoms': 'Jean Eude',
|
||||
'nom_de_naissance': 'Michalon-Gourde',
|
||||
'nom_d_usage': '',
|
||||
'date_de_naissance': '1991-03-04',
|
||||
'genre': 'homme',
|
||||
'email': '',
|
||||
'telephones': [
|
||||
{
|
||||
'numero': '0609080604',
|
||||
'type': 'mobile',
|
||||
},
|
||||
],
|
||||
'adresse': {
|
||||
'at': '',
|
||||
'streetnumber': '123',
|
||||
'streetnumberext': '',
|
||||
'streetname': 'ALLE DE L\'ARLEQUIN',
|
||||
'ext1': '',
|
||||
'ext2': '',
|
||||
'streetmatriculation': '00032',
|
||||
'zipcode': '92000',
|
||||
'inseecode': '92000',
|
||||
'city': 'NANTERRE',
|
||||
'country': 'FRANCE',
|
||||
}
|
||||
})
|
||||
assert response.json['err'] == 0
|
||||
assert response.json['data']['id'] == first_id
|
||||
|
|
|
@ -123,7 +123,7 @@ class ReseauView(APIView):
|
|||
)
|
||||
individu = get_object_or_404(qs, schema__slug='individu', id=identifier)
|
||||
utils.PersonSearch.decorate_individu(individu)
|
||||
serializer = CreateIndividuSerializer(data=request.data)
|
||||
serializer = CreateIndividuSerializer(data=request.data, partial=True)
|
||||
if not serializer.is_valid():
|
||||
return Response({
|
||||
'err': 1,
|
||||
|
@ -140,18 +140,28 @@ class ReseauView(APIView):
|
|||
transaction = Transaction.get_transaction()
|
||||
v = serializer.validated_data
|
||||
individu.modified = transaction
|
||||
individu.content['prenoms'] = v['prenoms']
|
||||
individu.content['nom_de_naissance'] = v['nom_de_naissance']
|
||||
individu.content['nom_d_usage'] = v['nom_d_usage']
|
||||
individu.content['date_de_naissance'] = v['date_de_naissance'].isoformat()
|
||||
individu.content['genre'] = v['genre']
|
||||
cles_de_federation = individu.content.get('cles_de_federation', {})
|
||||
for key in ['authentic']:
|
||||
if v['cles_de_federation'] and key in v['cles_de_federation']:
|
||||
cles_de_federation[key] = v['cles_de_federation'][key]
|
||||
individu.content['cles_de_federation'] = cles_de_federation
|
||||
if 'prenoms' in v:
|
||||
individu.content['prenoms'] = v['prenoms']
|
||||
if 'nom_de_naissance' in v:
|
||||
individu.content['nom_de_naissance'] = v['nom_de_naissance']
|
||||
if 'nom_d_usage' in v:
|
||||
individu.content['nom_d_usage'] = v['nom_d_usage']
|
||||
if 'date_de_naissance' in v:
|
||||
individu.content['date_de_naissance'] = v['date_de_naissance'].isoformat()
|
||||
if 'genre' in v:
|
||||
individu.content['genre'] = v['genre']
|
||||
if 'cles_de_federation' in v:
|
||||
cles_de_federation = individu.content.get('cles_de_federation', {})
|
||||
for key in ['authentic']:
|
||||
if v['cles_de_federation'] and key in v['cles_de_federation']:
|
||||
cles_de_federation[key] = v['cles_de_federation'][key]
|
||||
individu.content['cles_de_federation'] = cles_de_federation
|
||||
if 'email' in v:
|
||||
individu.content['email'] = v['email']
|
||||
if 'telephones' in v:
|
||||
individu.content['telephones'] = v['telephones']
|
||||
individu.save()
|
||||
if individu.content['statut_legal'] == 'majeur':
|
||||
if individu.content['statut_legal'] == 'majeur' and 'adresse' in 'v':
|
||||
for adresse, rel in utils.adresses(individu):
|
||||
adresse.content = v['adresse']
|
||||
rel.modified = individu.modified
|
||||
|
|
Loading…
Reference in New Issue