[CMF-checkins] CVS: CMF/CMFDefault/skins/zpt_generic -
join_control.py:1.1 join_form.pt:1.7
Yvo Schubbe
cvs-admin at zope.org
Thu Oct 30 14:23:37 EST 2003
Update of /cvs-repository/CMF/CMFDefault/skins/zpt_generic
In directory cvs.zope.org:/tmp/cvs-serv4940/CMFDefault/skins/zpt_generic
Modified Files:
join_form.pt
Added Files:
join_control.py
Log Message:
membership management ui (part 1):
- made join_form.pt usable for user managers
- added join_control.py script
- passwords are now hidden from the url (Collector #130)
- register.py and registered.pt are now obsolete
=== Added File CMF/CMFDefault/skins/zpt_generic/join_control.py ===
## Script (Python) "join_control"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=member_id='', member_email='', password='', confirm='', send_password='', add='', cancel=''
##title=
##
from Products.CMFCore.CMFCorePermissions import ManageUsers
from Products.CMFCore.utils import getToolByName
mtool = getToolByName(script, 'portal_membership')
ptool = getToolByName(script, 'portal_properties')
rtool = getToolByName(script, 'portal_registration')
utool = getToolByName(script, 'portal_url')
portal_url = utool()
validate_email = ptool.getProperty('validate_email')
is_anon = mtool.isAnonymousUser()
is_newmember = 0
is_usermanager = mtool.checkPermission(ManageUsers, mtool)
message = ''
valid = 1
if add:
if validate_email:
password = rtool.generatePassword()
else:
msg = rtool.testPasswordValidity(password, confirm)
if msg:
valid = 0
message = msg
if valid:
try:
rtool.addMember( id=member_id, password=password,
properties={'username':member_id,
'email':member_email} )
except ValueError, msg:
valid = 0
message = msg
else:
if validate_email or send_password:
rtool.registeredNotify(member_id)
if is_usermanager:
message = 'Member registered.'
else:
message = 'Success!'
is_newmember = 1
is_anon = 0
elif cancel:
target = portal_url
context.REQUEST.RESPONSE.redirect(target)
if message:
context.REQUEST.set('portal_status_message', message)
control = {}
control['title'] = is_usermanager and 'Register Member' or 'Become a Member'
control['member_id'] = (not valid or is_newmember) and member_id or ''
control['member_email'] = not valid and member_email or ''
control['password'] = is_newmember and password or ''
control['send_password'] = not valid and send_password or ''
control['portal_url'] = portal_url
control['isAnon'] = is_anon
control['isAnonOrUserManager'] = is_anon or is_usermanager
control['isNewMember'] = is_newmember
control['isOrdinaryMember'] = not (is_anon or is_newmember or is_usermanager)
control['validate_email'] = validate_email
return control
=== CMF/CMFDefault/skins/zpt_generic/join_form.pt 1.6 => 1.7 ===
--- CMF/CMFDefault/skins/zpt_generic/join_form.pt:1.6 Fri Mar 14 15:00:41 2003
+++ CMF/CMFDefault/skins/zpt_generic/join_form.pt Thu Oct 30 14:23:37 2003
@@ -1,116 +1,115 @@
-<html xmlns:tal="http://xml.zope.org/namespaces/tal"
- xmlns:metal="http://xml.zope.org/namespaces/metal"
- metal:use-macro="here/main_template/macros/master">
+<tal:page
+ xmlns:tal="http://xml.zope.org/namespaces/tal"
+ xmlns:metal="http://xml.zope.org/namespaces/metal"
+ xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+ tal:define="control python: here.join_control(**request.form)"
+><html metal:use-macro="here/main_template/macros/master">
<body>
-<div metal:fill-slot="main" i18n:domain="cmf_default">
-<div class="Desktop"
- tal:define="mtool here/portal_membership;
- member mtool/getAuthenticatedMember;
- ptool here/portal_properties;
- ">
-<h1 i18n:translate="">Become a member</h1>
+<metal:block metal:fill-slot="header" i18n:domain="cmf_default">
+<h1 tal:content="control/title" i18n:translate="">Become a member</h1>
+</metal:block>
-<div tal:define="registered python:member.has_role('Member')">
-
- <div tal:condition="registered">
+<metal:block metal:fill-slot="main" i18n:domain="cmf_default">
+<div class="Desktop">
+<tal:case tal:condition="control/isOrdinaryMember">
<p i18n:translate=""> You are already a member. You may use the
<a href="personalize_form">personalization form</a>
to change your membership information. </p>
+</tal:case>
- </div><!-- registered -->
+<tal:case tal:condition="control/isNewMember">
+<p i18n:translate="">You have been registered as a member.</p>
- <div tal:condition="not: registered">
+<p tal:condition="control/validate_email" i18n:translate="">You will receive
+ an email shortly containing your password and instructions on how to
+ activate your membership.</p>
+
+<tal:case tal:condition="not: control/validate_email">
+<p>Click the button to log in immediately.</p>
+<form action="logged_in" method="post"
+ tal:attributes="action string:${control/portal_url}/logged_in">
+<input type="hidden" name="__ac_name" value=""
+ tal:attributes="value control/member_id" />
+<input type="hidden" name="__ac_password" value=""
+ tal:attributes="value control/password" />
+<input type="submit" name="login" value="Log in"
+ i18n:attributes="value" />
+</form>
+</tal:case>
+
+<p><a href="" tal:attributes="href string:${control/portal_url}"
+ i18n:translate="">Return to homepage</a></p>
+</tal:case>
+<tal:case tal:condition="control/isAnon">
<p i18n:translate="">Becoming a member gives you the ability to personalize
the site and participate in the community.</p>
<p i18n:translate="">It does not cost any money to become a member and your
email and other personal information will remain private.</p>
- <p tal:condition="python: ptool.validate_email" i18n:translate="">
+ <p tal:condition="control/validate_email" i18n:translate="">
You must submit a valid email address. This address will be used
to send you a randomly-generated password. Once you have logged
in with this password, you may change it to anything you like.</p>
+</tal:case>
- <div id="DesktopStatusBar"
- tal:content="request/error|nothing">
- <hr />
- </div>
-
- <form action="register" method="post"
- tal:attributes="action string:${here/portal_url}/register"
- >
-
- <input type="hidden" name="last_visit:date" value=""
- tal:attributes="value here/ZopeTime" />
- <input type="hidden" name="prev_visit:date" value=""
- tal:attributes="value here/ZopeTime" />
-
+<tal:case tal:condition="control/isAnonOrUserManager">
+ <form action="join_form" method="post"
+ tal:attributes="action string:${control/portal_url}/join_form">
<table class="FormLayout">
-
<tr>
- <th i18n:translate="">Login Name</th>
+ <th i18n:translate="">Member ID</th>
<td>
- <input type="text" name="username" size="30" value=""
- tal:attributes="value request/username|nothing" />
+ <input type="text" name="member_id" size="30" value=""
+ tal:attributes="value control/member_id" />
</td>
</tr>
-
<tr>
<th i18n:translate="">Email Address</th>
- <td align="left" valign="top">
- <input type="text" name="email" size="30" value=""
- tal:attributes="value request/email|nothing" />
+ <td>
+ <input type="text" name="member_email" size="30" value=""
+ tal:attributes="value control/member_email" />
</td>
- </tr>
-
- <tbody tal:condition="python: not(ptool.validate_email)">
-
+ </tr><tal:case tal:condition="not: control/validate_email">
<tr>
<th i18n:translate="">Password</th>
- <td align="left" valign="top">
+ <td>
<input type="password" name="password" size="30" />
</td>
</tr>
-
<tr>
<th i18n:translate="">Password (confirm)</th>
- <td align="left" valign="top">
+ <td>
<input type="password" name="confirm" size="30" />
</td>
</tr>
-
<tr>
<th i18n:translate="">Mail Password?</th>
<td>
- <input type="checkbox" name="mail_me" size="30" id="cb_mailme" />
- <em><label for="cb_mailme" i18n:translate="">Check this box to have your
- password mailed to you.</label></em>
+ <input type="checkbox" name="send_password" id="cb_send_password"
+ tal:attributes="checked control/send_password" />
+ <em><label for="cb_send_password" i18n:translate="">Check this box to
+ have the password mailed.</label></em>
</td>
- </tr>
- </tbody>
-
+ </tr></tal:case>
<tr>
- <td><br /></td>
+ <td> </td>
<td>
- <input type="submit" name="submit" value="Register"
+ <input type="submit" name="add" value="Register"
+ i18n:attributes="value" />
+ <input type="submit" name="cancel" value="Cancel"
i18n:attributes="value" />
</td>
</tr>
-
</table>
-
</form>
+</tal:case>
- </div><!-- not registered -->
-
-</div><!-- tal:define="registered" -->
-
-</div><!-- class="Desktop" -->
-
-</div><!-- metal:fill-slot="main" -->
+</div>
+</metal:block>
</body>
-</html>
+</html></tal:page>
More information about the CMF-checkins
mailing list