Modernisation de l'inscription (suite).
authorBenoît Pin <pin@cri.ensmp.fr>
Thu, 16 Apr 2015 10:58:21 +0000 (12:58 +0200)
committerBenoît Pin <pin@cri.ensmp.fr>
Thu, 16 Apr 2015 10:58:21 +0000 (12:58 +0200)
Products/Plinn/skins/custom_generic/join_form.py
Products/Plinn/skins/custom_generic/join_template.pt

index 579a38f..0e07d03 100644 (file)
@@ -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
index aa53178..337aa94 100644 (file)
@@ -11,7 +11,7 @@
                 tal:define="form options/form">
       <h1 i18n:translate="">Become a member</h1>
       <div class="Desktop">
-        <p tal:condition="options/isOrdinaryMember" i18n:translate="">
+        <p tal:condition="not:options/isAnon" i18n:translate="">
             You are already authenticated. You may use the
             <a tal:attributes="href string:$portal_url/personalize_form"
                i18n:name="personalize_form"
@@ -53,7 +53,7 @@
           </p>
         </div>
         
-        <div tal:condition="options/isAnonOrUserManager">
+        <div tal:condition="options/isAnon">
           <form method="post" tal:attributes="action form/action">
             <table>
               <tr>
@@ -74,7 +74,7 @@
                          placeholder="Email address" i18n:attributes="placeholder"
                          tal:attributes="value options/member_email|nothing"/>
                   <label>
-                    <input type="checkbox" name="email_as_login"
+                    <input type="checkbox" name="email_as_login" value="email_as_login"
                            tal:attributes="checked python:options.get('email_as_login', True)"/>
                     <span tal:omit-tag="" i18n:translate="">use as login</span>
                   </label>