summaryrefslogtreecommitdiffstats
path: root/django/sp_sso/invite
diff options
context:
space:
mode:
Diffstat (limited to 'django/sp_sso/invite')
-rw-r--r--django/sp_sso/invite/forms.py16
-rw-r--r--django/sp_sso/invite/utils.py13
-rw-r--r--django/sp_sso/invite/views.py10
3 files changed, 39 insertions, 0 deletions
diff --git a/django/sp_sso/invite/forms.py b/django/sp_sso/invite/forms.py
index 1b5f3bb..0736a3c 100644
--- a/django/sp_sso/invite/forms.py
+++ b/django/sp_sso/invite/forms.py
@@ -5,7 +5,23 @@ from .utils import get_invitaton_attributes_mapping, get_additional_prefilled_fi
class InvitationForm(forms.Form):
+ """ Used when sending invites to the Campus
+
+ Invites are sent to the `email` field. Multiple adresses are handled if
+ they are separated by a blank space ` ` character.
+
+ This form is restricted to users having previously registered to the
+ Campus ; therefore they must log in to their RENATER-federated account
+ before accessing the form.
+ """
def __init__(self, *args, **kwargs):
+ """
+ Attributes fetched from the identity provider are used to pre-fill
+ the fields.
+ An extra hidden field is used to store the user's
+ eduPersonPrincipalName, used as key identity attribute in the
+ corresponding LDAP entry.
+ """
super(InvitationForm, self).__init__(*args, **kwargs)
# Add a help text for sending multiple invitations
self.fields['email'].help_text = _(
diff --git a/django/sp_sso/invite/utils.py b/django/sp_sso/invite/utils.py
index 5cc40fd..4f49b39 100644
--- a/django/sp_sso/invite/utils.py
+++ b/django/sp_sso/invite/utils.py
@@ -21,12 +21,21 @@ PASSERELLE_PEOPLE_QUERY = 'http://dir-condorcet.dev.entrouvert.org/ldapquery/con
logger = logging.getLogger('django')
def get_invitaton_attributes_mapping():
+ """ Full copy of the invitation attributes mapping dictionary """
return INVITATION_ATTRIBUTES_MAPPING.copy()
def get_additional_prefilled_fields():
+ """
+ Returns a full copy of the additional fields to be prefilled with the
+ user's fetched attributes.
+ """
return ADDITIONAL_PREFILLED_FIELDS[:]
def do_invite(invitation):
+ """
+ Sends invitation data to the invitation w.c.s. form.
+ Invitations will then be sent as part of the w.c.s. workflow.
+ """
opener = build_opener(HTTPHandler)
# Generate a JSON to bind against the wcs ReST API
form = {}
@@ -48,6 +57,10 @@ def do_invite(invitation):
def get_affectations_from_eppn(eppn):
+ """
+ Returns a tuple (<Institution identifier>, <Researcher unit identifier>)
+ for a given eduPersonPrincipalName (a.k.a. `eppn`)
+ """
if eppn:
try:
ldapquery = urlopen(PASSERELLE_PEOPLE_QUERY)
diff --git a/django/sp_sso/invite/views.py b/django/sp_sso/invite/views.py
index e5b21fd..ce85b63 100644
--- a/django/sp_sso/invite/views.py
+++ b/django/sp_sso/invite/views.py
@@ -15,10 +15,20 @@ MSG_INVITATION_SENT = _("Your invitation has been sent.")
def invitation_sent(request):
+ """
+ Notifies the user about her invitation(s) by displaying a validation
+ message.
+ """
return render_message(request, MSG_INVITATION_SENT)
class InvitationFormView(FormView):
+ """
+ Main FormView for the invitation process.
+
+ Gathers SSO attributes from the identity provider, used to pre-fill and
+ set as readonly the `InvitationForm` fields.
+ """
form_class = InvitationForm
template_name = 'invite/invitation_form.html'
success_url = '/invite/sent'