POC Campus Condorcet : generation eppn unique
This commit is contained in:
parent
4aaddaa8e1
commit
a0adf324c7
|
@ -5,7 +5,7 @@ from django.utils.translation import ugettext as _
|
|||
|
||||
from .forms import RegistrationForm
|
||||
from .utils import ldap_contains_user, wcs_submit, \
|
||||
sso_attributes, craft_user_nickname \
|
||||
sso_attributes, craft_user_nickname, \
|
||||
generate_eppn
|
||||
|
||||
logger = logging.getLogger('django')
|
||||
|
@ -64,9 +64,9 @@ class RegistrationFormView(FormView):
|
|||
def form_valid(self, form):
|
||||
post_dict = self.request.POST
|
||||
form_adequate_data = {}
|
||||
form_adequate_data['ep_principal_name'] = post_dict.get('ep_principal_name') or generate_eppn(post_dict.get('lastname', 'undefined'))
|
||||
form_adequate_data['ep_principal_name'] = post_dict.get('ep_principal_name')
|
||||
|
||||
if ldap_contains_user(form_adequate_data):
|
||||
if form_adequate_data['ep_principal_name'] and ldap_contains_user(form_adequate_data):
|
||||
return usernone(self.request)
|
||||
else:
|
||||
delimiter = ','
|
||||
|
@ -80,5 +80,8 @@ class RegistrationFormView(FormView):
|
|||
sanizted_form_list = post_dict.getlist(multiple_field, [])
|
||||
wcs_rest_data[multiple_field] = delimiter.join(sanizted_form_list)
|
||||
|
||||
if post_dict.get('ep_principal_name', '') == '':
|
||||
wcs_rest_data['ep_principal_name'] = generate_eppn(post_dict.get('nom',''))
|
||||
|
||||
wcs_submit(wcs_rest_data)
|
||||
return super(RegistrationFormView, self).form_valid(form)
|
||||
|
|
Reference in New Issue