This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
cg14-osc/home:entrouvert:cg14/passerelle/0001-bdp-add-parameters-to-...

41 lines
1.7 KiB
Diff

From db6a038ab98f828fa3c478c41449068a328f1e9d Mon Sep 17 00:00:00 2001
From: Thomas NOEL <tnoel@entrouvert.com>
Date: Thu, 19 Mar 2015 13:29:37 +0100
Subject: [PATCH] bdp: add parameters to post/adherent (#6577)
---
passerelle/apps/bdp/views.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/passerelle/apps/bdp/views.py b/passerelle/apps/bdp/views.py
index ddced57..4f13826 100644
--- a/passerelle/apps/bdp/views.py
+++ b/passerelle/apps/bdp/views.py
@@ -50,6 +50,12 @@ class PostAdherentView(View, SingleObjectMixin):
date_de_naissance = data['fields'].get('date_de_naissance')
# force 1973-04-18T00:00:00Z
date_de_naissance = date_de_naissance[:10] + 'T00:00:00Z'
+ abonnements = data['fields'].get('abonnements_raw') or \
+ data['fields'].get('abonnements_raw') or \
+ request.GET.get('abonnements')
+ bibliotheque_id = data['fields'].get('bibliotheque_raw') or \
+ data['fields'].get('bibliotheque') or \
+ request.GET.get('bibliotheque')
adherent = {
'nom': data['fields'].get('nom'),
'prenom': data['fields'].get('prenom'),
@@ -57,8 +63,8 @@ class PostAdherentView(View, SingleObjectMixin):
'hashpass': data['fields'].get('mot_de_passe').get('cleartext'),
'dateNaissance': date_de_naissance,
'actif': 'on',
- 'bibliotheque': {'id': data['fields'].get('bibliotheque_raw')},
- 'abonnements': '15',
+ 'bibliotheque': {'id': bibliotheque_id},
+ 'abonnements': abonnements,
}
return self.get_object().post_api('adherents', adherent)
--
2.1.4