summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Marillonnet <pmarillonnet@entrouvert.com>2017-06-20 15:35:39 (GMT)
committerPaul Marillonnet <pmarillonnet@entrouvert.com>2017-06-20 15:35:39 (GMT)
commitac543c6fad923918ded53f9451c212d231a29dfa (patch)
tree0f5466fc26f33fea27e6830861cc8d641c158bfa
parente1f5c1743e3e3e1c21f4ffce15b774db284704cb (diff)
downloadpaul-synchro-ac543c6fad923918ded53f9451c212d231a29dfa.zip
paul-synchro-ac543c6fad923918ded53f9451c212d231a29dfa.tar.gz
paul-synchro-ac543c6fad923918ded53f9451c212d231a29dfa.tar.bz2
POC Campus Condorcet : retrait du champ hote_identite, partie2
On laissera a la place un simple champ commentaire ou l'utilisateur sera libre de preciser l'identite de l'invitant s'il le souhaite
-rw-r--r--django/sp_sso/invite/forms.py15
-rw-r--r--django/sp_sso/invite/utils.py8
-rw-r--r--django/sp_sso/invite/views.py8
-rw-r--r--django/sp_sso/saml/utils.py4
-rw-r--r--django/sp_sso/templates/invite/invitation_form.html1
5 files changed, 25 insertions, 11 deletions
diff --git a/django/sp_sso/invite/forms.py b/django/sp_sso/invite/forms.py
index c222864..455ac94 100644
--- a/django/sp_sso/invite/forms.py
+++ b/django/sp_sso/invite/forms.py
@@ -1,6 +1,8 @@
from django.utils.translation import ugettext_lazy as _
from django import forms
+from .utils import get_invitaton_attributes_mapping
+
class InvitationForm(forms.Form):
@@ -10,12 +12,14 @@ class InvitationForm(forms.Form):
self.fields['email'].help_text = _(
_('Blank-separated emails if multiple adresses.'))
# Pre-filled fields are readonly
- if kwargs['initial'].get('hote_identite'):
- self.fields['hote_identite'].widget.attrs['readonly'] = True
+ for prefilled_field in get_invitaton_attributes_mapping().values():
+ if kwargs['initial'].get(prefilled_field):
+ self.fields[prefilled_field].widget.attrs['readonly'] = True
# Blank-seperated list of recipient email adresses
- email = forms.CharField(max_length=100, label=_("Email address"))
+ email = forms.CharField(max_length=100, label=_('''Email address(es) where
+ to send an invite'''))
# Invitation message that will be sent with the invite
message = forms.CharField(
widget=forms.Textarea(), max_length=999, label=_("Invitation message"),
@@ -24,6 +28,7 @@ class InvitationForm(forms.Form):
# 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 email address"))
-
+ max_length=100, label=_("Your RENATER identifier"))
+ hote_courriel = forms.CharField(
+ max_length=100, label=_("Your email address"))
diff --git a/django/sp_sso/invite/utils.py b/django/sp_sso/invite/utils.py
index 39dda26..d9921f5 100644
--- a/django/sp_sso/invite/utils.py
+++ b/django/sp_sso/invite/utils.py
@@ -6,6 +6,14 @@ pocform = 'invitation'
wcs = 'http://forms-condorcet.dev.entrouvert.org/'
posturl = wcs+'/api/formdefs/'+pocform+'/submit'
+INVITATION_ATTRIBUTES_MAPPING = {
+ 'ep_principal_name': 'hote_identite',
+ 'email': 'hote_courriel'
+}
+
+def get_invitaton_attributes_mapping():
+ return INVITATION_ATTRIBUTES_MAPPING
+
def do_invite(invitation):
opener = build_opener(HTTPHandler)
# Generate a JSON to bind against the wcs ReST API
diff --git a/django/sp_sso/invite/views.py b/django/sp_sso/invite/views.py
index 0c61b79..9ac1f68 100644
--- a/django/sp_sso/invite/views.py
+++ b/django/sp_sso/invite/views.py
@@ -3,13 +3,9 @@ from django.shortcuts import render, redirect
from django.utils.translation import ugettext as _
from .forms import InvitationForm
-from .utils import do_invite
+from .utils import do_invite, get_invitaton_attributes_mapping
from saml.utils import ldap_contains_user
-invitation_attributes_mapping = {
- 'email':'hote_identite',
-}
-
# Create your views here.
def invitation_sent(request):
@@ -36,7 +32,7 @@ class InvitationFormView(FormView):
# Fetch SSO attributes
for attribute_key, attribute_value in \
- invitation_attributes_mapping.items():
+ get_invitaton_attributes_mapping().items():
attribute_element = self.request.session['mellon_session'].get(
attribute_key,
diff --git a/django/sp_sso/saml/utils.py b/django/sp_sso/saml/utils.py
index 8db16a2..73f70b0 100644
--- a/django/sp_sso/saml/utils.py
+++ b/django/sp_sso/saml/utils.py
@@ -158,6 +158,10 @@ def initial_from_tracking_code(tracking_code):
'http://forms-condorcet.dev.entrouvert.org/api/forms/invitation/'\
+form_number)
initial_response = json.loads(req.read())
+ # Add comments aimed at w.c.s. backoffice agents
+ initial_response.get('fields', {}).update(
+ {'hote_commentaire': 'Email de l\'invitant : %s'% \
+ initial_response.get('fields', {}).get('hote_courriel')})
except:
return {}
diff --git a/django/sp_sso/templates/invite/invitation_form.html b/django/sp_sso/templates/invite/invitation_form.html
index c46b8bb..6b20f1c 100644
--- a/django/sp_sso/templates/invite/invitation_form.html
+++ b/django/sp_sso/templates/invite/invitation_form.html
@@ -17,6 +17,7 @@
{% include "registration_field.html" with field=form.email %}
{% include "registration_field.html" with field=form.message %}
{% include "registration_field.html" with field=form.hote_identite %}
+ {% include "registration_field.html" with field=form.hote_courriel %}
<input type="submit" value="{% trans "Submit" %}"/>
</form>
{% if form.errors %}