summaryrefslogtreecommitdiffstats
path: root/django/sp_sso/invite/utils.py
diff options
context:
space:
mode:
authorPaul Marillonnet <pmarillonnet@entrouvert.com>2017-05-29 16:17:50 (GMT)
committerPaul Marillonnet <pmarillonnet@entrouvert.com>2017-05-30 08:30:00 (GMT)
commitea77e8cee787ee368c2d6ec410ca776b0d934b4b (patch)
tree40779bf713f059a5f561d16c07c8f74d663a0358 /django/sp_sso/invite/utils.py
parent021b93bc16ae99ef45346672c11ad9f1cef4416a (diff)
downloadpaul-synchro-ea77e8cee787ee368c2d6ec410ca776b0d934b4b.zip
paul-synchro-ea77e8cee787ee368c2d6ec410ca776b0d934b4b.tar.gz
paul-synchro-ea77e8cee787ee368c2d6ec410ca776b0d934b4b.tar.bz2
POC Campus Condorcet : traitement des invitations, partie 1
Diffstat (limited to 'django/sp_sso/invite/utils.py')
-rw-r--r--django/sp_sso/invite/utils.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/django/sp_sso/invite/utils.py b/django/sp_sso/invite/utils.py
new file mode 100644
index 0000000..68b7991
--- /dev/null
+++ b/django/sp_sso/invite/utils.py
@@ -0,0 +1,26 @@
+import json
+
+from urllib2 import build_opener, HTTPHandler, Request
+
+pocform = 'invitation'
+wcs = 'http://forms-condorcet.dev.entrouvert.org/'
+posturl = wcs+'/api/formdefs/'+pocform+'/submit'
+
+def do_invite(invitation):
+ opener = build_opener(HTTPHandler)
+ # Generate a JSON to bind against the wcs ReST API
+ form = {}
+ form["data"] = invitation # see wcs documentation
+ data = json.dumps(form)
+
+ req = Request(posturl, data)
+ req.add_header("Content-Type", "application/json")
+ req.add_header("Accept", "application/json")
+
+ ret = 0
+ try:
+ opener.open(req)
+ except :
+ ret = -1
+
+ return ret