summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Marillonnet <pmarillonnet@entrouvert.com>2017-06-01 14:14:15 (GMT)
committerPaul Marillonnet <pmarillonnet@entrouvert.com>2017-06-01 14:14:15 (GMT)
commitbbbe8ba1f97e817976d7bfe26d2b39ab767ceac4 (patch)
treedc23f82794800963d97536a684f06a6dba6e1d4e
parentdb1f29249d02c796c89f64d0fc4c5c3bdae2b289 (diff)
downloadpaul-synchro-bbbe8ba1f97e817976d7bfe26d2b39ab767ceac4.zip
paul-synchro-bbbe8ba1f97e817976d7bfe26d2b39ab767ceac4.tar.gz
paul-synchro-bbbe8ba1f97e817976d7bfe26d2b39ab767ceac4.tar.bz2
POC Campus Condorcet : commentaires dans le code de l'appli d'invitation
-rw-r--r--django/sp_sso/invite/forms.py6
-rw-r--r--django/sp_sso/invite/utils.py3
-rw-r--r--django/sp_sso/invite/views.py6
3 files changed, 14 insertions, 1 deletions
diff --git a/django/sp_sso/invite/forms.py b/django/sp_sso/invite/forms.py
index c4fb91f..fd849b5 100644
--- a/django/sp_sso/invite/forms.py
+++ b/django/sp_sso/invite/forms.py
@@ -6,12 +6,18 @@ class InvitationForm(forms.Form):
def __init__(self, *args, **kwargs):
super(InvitationForm, self).__init__(*args, **kwargs)
+ # Add a help text for sending multiple invitations
self.fields['email'].help_text = _(
'Blank-separated emails if multiple adresses.')
+ # Blank-seperated list of recipient email adresses
email = forms.CharField(max_length=100, label=_("Email address"))
+ # Invitation message that will be sent with the invite
message = forms.CharField(
max_length=999, label=_("Invitation message"), required=False)
+ # Host identity
+ # If the RENATER identity federation is used, this field will be pre-
+ # filled with the host's EPPN (EduPersonPrincalName)
hote_identite = forms.CharField(
max_length=100, label=_("Your identifier"))
diff --git a/django/sp_sso/invite/utils.py b/django/sp_sso/invite/utils.py
index 68b7991..39dda26 100644
--- a/django/sp_sso/invite/utils.py
+++ b/django/sp_sso/invite/utils.py
@@ -10,7 +10,8 @@ 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
+ # Forge a HTTP POST request
+ form["data"] = invitation
data = json.dumps(form)
req = Request(posturl, data)
diff --git a/django/sp_sso/invite/views.py b/django/sp_sso/invite/views.py
index 1866cb6..af7a71a 100644
--- a/django/sp_sso/invite/views.py
+++ b/django/sp_sso/invite/views.py
@@ -31,8 +31,10 @@ class InvitationFormView(FormView):
def get_initial(self):
initial = super(InvitationFormView, self).get_initial()
+ # User is logged in the identity provider
if 'mellon_session' in self.request.session:
+ # Fetch SSO attributes
for attribute_key, attribute_value in \
invitation_attributes_mapping.items():
@@ -48,10 +50,13 @@ class InvitationFormView(FormView):
post_dict = self.request.POST
hote_identite = post_dict.get('hote_identite')
+
+ # User cannot invite if she's not in the destination directory yet
if not hote_identite or not ldap_contains_user(
{'ep_principal_name':hote_identite}):
return redirect('not_registered')
+ # Craft any relevant invitation data
for form_attribute in self.form_class.base_fields.keys():
sanitized_form_entry = post_dict.get(form_attribute, False)
if sanitized_form_entry:
@@ -59,6 +64,7 @@ class InvitationFormView(FormView):
multiple_email_invitation = {}
+ # Send as many invites as there are email adresses (blank-separated)
for email in invitation['email'].split(' '):
multiple_email_invitation = invitation.copy()
multiple_email_invitation['email'] = email