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-dev/passerelle/abonnements-from-request.patch

29 lines
1.1 KiB
Diff

--- 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)