diff --git a/django/sp_sso/invite/forms.py b/django/sp_sso/invite/forms.py index 0736a3c..9d0ea58 100644 --- a/django/sp_sso/invite/forms.py +++ b/django/sp_sso/invite/forms.py @@ -1,7 +1,11 @@ from django.utils.translation import ugettext_lazy as _ from django import forms -from .utils import get_invitaton_attributes_mapping, get_additional_prefilled_fields +from .utils import get_invitaton_attributes_mapping, get_additional_prefilled_fields, \ + ADDITIONAL_PREFILLED_FIELDS +from saml.utils import ldap_get_description_etablissements, \ + ldap_get_description_unites + class InvitationForm(forms.Form): @@ -32,6 +36,14 @@ class InvitationForm(forms.Form): if kwargs['initial'].get(prefilled_field): self.fields[prefilled_field].widget.attrs['readonly'] = True + etablissement_code = kwargs['initial'].get('hote_etablissement') + self.fields['hote_etablissement_description'].initial = ldap_get_description_etablissements(etablissement_code) + self.fields['hote_etablissement_description'].widget.attrs['readonly'] = True + + unite_code = kwargs['initial'].get('hote_unite') + self.fields['hote_unite_description'].initial = ldap_get_description_unites(unite_code) + self.fields['hote_unite_description'].widget.attrs['readonly'] = True + # Blank-seperated list of recipient email adresses email = forms.CharField( max_length=100, @@ -54,10 +66,19 @@ class InvitationForm(forms.Form): max_length=100, label=_("Your firstname")) hote_etablissement = forms.CharField( - max_length=100, label=_("Your institution")) + max_length=100, label=_("Your institution"), required=False) hote_unite = forms.CharField( - max_length=100, label=_("Your research unit")) + max_length=100, label=_("Your research unit"), required=False) + + hote_etablissement_description = forms.CharField( + max_length=100, label=_("Your institution"), required=False) + + hote_unite_description = forms.CharField( + max_length=100, label=_("Your research unit"), required=False) hote_courriel = forms.CharField( max_length=100, label=_("Your email address")) + + hote_type = forms.CharField( + max_length=100, label="hidden host type", initial='affiliate', required=False) diff --git a/django/sp_sso/invite/utils.py b/django/sp_sso/invite/utils.py index 4f49b39..31c2c0a 100644 --- a/django/sp_sso/invite/utils.py +++ b/django/sp_sso/invite/utils.py @@ -11,10 +11,12 @@ INVITATION_ATTRIBUTES_MAPPING = { 'ep_principal_name': 'hote_identite', 'email': 'hote_courriel', 'prenom': 'hote_prenom', - 'nom': 'hote_nom' + 'nom': 'hote_nom', + 's_etablissement': 'hote_etablissement', + 's_entite_affectation_principale': 'hote_unite' } -ADDITIONAL_PREFILLED_FIELDS = ['hote_etablissement', 'hote_unite'] +ADDITIONAL_PREFILLED_FIELDS = ['hote_etablissement', 'hote_unite', 'hote_type'] PASSERELLE_PEOPLE_QUERY = 'http://dir-condorcet.dev.entrouvert.org/ldapquery/condorcet/run/6/' diff --git a/django/sp_sso/invite/views.py b/django/sp_sso/invite/views.py index ce85b63..9b714a0 100644 --- a/django/sp_sso/invite/views.py +++ b/django/sp_sso/invite/views.py @@ -46,12 +46,14 @@ 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]) + #etablissement, unite = get_affectations_from_eppn( + # data.get('ep_principal_name',[None])[0]) - initial['hote_etablissement'] = etablissement - initial['hote_unite'] = unite + #initial['hote_etablissement'] = etablissement + #initial['hote_unite'] = unite initial['hote_commentaire'] = '''EduPersonPrincipalName de l\'invitant''' return initial @@ -67,6 +69,7 @@ class InvitationFormView(FormView): if sanitized_form_entry: invitation[form_attribute] = sanitized_form_entry + invitation['type'] = post_dict.get('hote_type') multiple_email_invitation = {} # Send as many invites as there are email adresses (blank-separated)