From 77d171ada905e9f098d29577966b9f41b30be014 Mon Sep 17 00:00:00 2001 From: Paul Marillonnet Date: Wed, 27 Sep 2017 14:27:45 +0200 Subject: [PATCH] POC Campus Condorcet : ajout de la fonctionnalite "invitation a s'inscrire" --- django/sp_sso/invite/forms.py | 2 +- django/sp_sso/invite/views.py | 9 ++------- django/sp_sso/saml/decorators.py | 4 ++++ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/django/sp_sso/invite/forms.py b/django/sp_sso/invite/forms.py index 9d0ea58..01eb5e9 100644 --- a/django/sp_sso/invite/forms.py +++ b/django/sp_sso/invite/forms.py @@ -81,4 +81,4 @@ class InvitationForm(forms.Form): max_length=100, label=_("Your email address")) hote_type = forms.CharField( - max_length=100, label="hidden host type", initial='affiliate', required=False) + max_length=100, label="hidden host type", required=False) diff --git a/django/sp_sso/invite/views.py b/django/sp_sso/invite/views.py index 9b714a0..e446522 100644 --- a/django/sp_sso/invite/views.py +++ b/django/sp_sso/invite/views.py @@ -46,16 +46,11 @@ class InvitationFormView(FormView): if data.get(attribute_key): attribute_element = data.get(attribute_key)[0] initial[attribute_value] = attribute_element - if self.request.GET.get('type'): - initial['hote_type'] = self.request.GET.get('type') - #etablissement, unite = get_affectations_from_eppn( - # data.get('ep_principal_name',[None])[0]) - - #initial['hote_etablissement'] = etablissement - #initial['hote_unite'] = unite initial['hote_commentaire'] = '''EduPersonPrincipalName de l\'invitant''' + + initial['hote_type'] = self.request.session.get('host_type') return initial def form_valid(self, form): diff --git a/django/sp_sso/saml/decorators.py b/django/sp_sso/saml/decorators.py index f923899..ccf03f3 100644 --- a/django/sp_sso/saml/decorators.py +++ b/django/sp_sso/saml/decorators.py @@ -38,6 +38,10 @@ def user_in_ldap(function): """ def wrapped(request, *args, **kwargs): if not 'mellon_session' in request.session: + if request.GET.get('host_type') == 'member': + request.session['host_type'] = 'member' + else: + request.session['host_type'] = 'affiliate' return redirect(reverse('auth_login') + "?next=/invite/") user_data = saml_collect_data(request) if not ldap_contains_user(user_data):