dev/passerelle: new patch for #6577

This commit is contained in:
Thomas NOËL 2015-03-19 13:35:01 +01:00
parent 29a89986ba
commit 6d13b70a47
3 changed files with 41 additions and 29 deletions

View File

@ -0,0 +1,40 @@
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

View File

@ -1,28 +0,0 @@
--- passerelle-ef79c2a/passerelle/apps/bdp/views.py.orig 2015-03-19 11:16:32.966003088 +0100
+++ passerelle-ef79c2a/passerelle/apps/bdp/views.py 2015-03-19 11:23:26.232711866 +0100
@@ -16,6 +16,7 @@
# See documentation:
# https://dev.entrouvert.org/projects/bdp/wiki/WebServices
+DEFAULT_ABONNEMENTS = '15'
class ResourcesView(View, SingleObjectMixin):
model = Bdp
@@ -50,6 +51,8 @@
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 \
+ request.GET.get('abonnements') or DEFAULT_ABONNEMENTS
adherent = {
'nom': data['fields'].get('nom'),
'prenom': data['fields'].get('prenom'),
@@ -58,7 +61,7 @@
'dateNaissance': date_de_naissance,
'actif': 'on',
'bibliotheque': {'id': data['fields'].get('bibliotheque_raw')},
- 'abonnements': '15',
+ 'abonnements': abonnements,
}
return self.get_object().post_api('adherents', adherent)

View File

@ -28,7 +28,7 @@ Source5: synchro-cron.sh
Source6: wcs-au-quotidien.cron.d
Source7: passerelle-manage
Source8: cg14_config.py
Patch1: abonnements-from-request.patch
Patch1: 0001-bdp-add-parameters-to-post-adherent-6577.patch
BuildArch: noarch