From: Benoît Pin Date: Thu, 16 Apr 2015 10:58:21 +0000 (+0200) Subject: Modernisation de l'inscription (suite). X-Git-Url: https://svn.cri.ensmp.fr/git/Plinn.git/commitdiff_plain/c842e5e6424e39757c43950456c66e7bb14c32c8?ds=sidebyside Modernisation de l'inscription (suite). --- diff --git a/Products/Plinn/skins/custom_generic/join_form.py b/Products/Plinn/skins/custom_generic/join_form.py index 579a38f..0e07d03 100644 --- a/Products/Plinn/skins/custom_generic/join_form.py +++ b/Products/Plinn/skins/custom_generic/join_form.py @@ -1,4 +1,4 @@ -##parameters=b_start=0, member_id='', given_name='', name='', member_email='', password='', confirm='', send_password='', add='', ajax='' +##parameters=member_id='', given_name='', name='', member_email='', email_as_login='', password='', confirm='', add='', ajax='' ## from Products.CMFCore.utils import getToolByName from Products.CMFDefault.permissions import ManageUsers @@ -20,11 +20,31 @@ is_usermanager = mtool.checkPermission(ManageUsers, mtool) form = context.REQUEST.form -if add and \ - context.validatePassword(**form) and \ - context.members_add_control(**form) and \ - context.setRedirect(atool, 'user/join', b_start=b_start, ajax=ajax): - return + +if add : + if validate_email : + password = confirm = rtool.generatePassword() + else : + ok = context.validatePassword(**form) + try : + if email_as_login : + member_id = member_email + rtool.addMember(id=member_id, password=password, + properties={'username': member_id, + 'given_name' : given_name, + 'name' : name, + 'email': member_email}) + context.setStatus(True, _('Success!')) + except ValueError, errmsg: + context.setStatus(False, errmsg) + + + +# if add and \ +# context.validatePassword(**form) and \ +# context.members_add_control(**form) and \ +# context.setRedirect(atool, 'user/join', b_start=b_start, ajax=ajax): +# return options = {} @@ -37,12 +57,9 @@ options['given_name'] = given_name options['name'] = name options['member_email'] = member_email options['password'] = is_newmember and context.REQUEST.get('password', '') or '' -options['send_password'] = send_password options['portal_url'] = portal_url options['isAnon'] = is_anon -options['isAnonOrUserManager'] = is_anon or is_usermanager options['isNewMember'] = is_newmember -options['isOrdinaryMember'] = not (is_anon or is_newmember or is_usermanager) options['validate_email'] = validate_email options['isAnonRegistration'] = rtool.getMode() == MODE_ANONYMOUS options['isReviewedRegistration'] = rtool.getMode() == MODE_REVIEWED diff --git a/Products/Plinn/skins/custom_generic/join_template.pt b/Products/Plinn/skins/custom_generic/join_template.pt index aa53178..337aa94 100644 --- a/Products/Plinn/skins/custom_generic/join_template.pt +++ b/Products/Plinn/skins/custom_generic/join_template.pt @@ -11,7 +11,7 @@ tal:define="form options/form">

Become a member

-

+

You are already authenticated. You may use the

-
+
@@ -74,7 +74,7 @@ placeholder="Email address" i18n:attributes="placeholder" tal:attributes="value options/member_email|nothing"/>