Changeset 1560
- Timestamp:
- 11/14/06 00:10:20 (2 years ago)
- Files:
-
- accountmanagerplugin/trunk/acct_mgr/templates/prefs_account.html (moved) (moved from accountmanagerplugin/trunk/acct_mgr/templates/account.html) (1 diff)
- accountmanagerplugin/trunk/acct_mgr/templates/reset_password.html (modified) (1 diff)
- accountmanagerplugin/trunk/acct_mgr/web_ui.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
accountmanagerplugin/trunk/acct_mgr/templates/prefs_account.html
r1534 r1560 5 5 xmlns:py="http://genshi.edgewall.org/" 6 6 xmlns:xi="http://www.w3.org/2001/XInclude"> 7 <xi:include href="layout.html" /> 7 <xi:include href="prefs.html" /> 8 9 <!--! FIXME [1] prevents this from matching its own output. 10 Should that really be necessary? --> 11 <div py:match="div[@id='tabcontent'][1]" py:attrs="select('@*')"> 12 ${select('*')} 13 <form method="post" action="" py:if="account.delete_enabled" 14 onsubmit="return confirm('Are you sure you want to delete your account?');"> 15 <div class="buttons"> 16 <input type="hidden" name="action" value="delete" /> 17 <input type="submit" value="Delete account" /> 18 </div> 19 </form> 20 </div> 21 8 22 <head> 9 <title> MyAccount</title>23 <title>Account</title> 10 24 </head> 11 25 12 26 <body> 13 <div id="content" class="register"> 14 <h1>My Account</h1> 27 <div class="system-message" py:if="account.error"> 28 <h2>Error</h2> 29 <p>$account.error</p> 30 </div> 15 31 16 <p>Manage your user account.</p>32 <p py:if="account.message">$account.message</p> 17 33 18 <div class="system-message" py:if="account_error"> 19 <h2>Error</h2> 20 <p>$account.error</p> 21 </div> 22 23 <p py:if="account.message">$account.message</p> 24 25 <form method="post" action=""> 26 <div> 27 <input type="hidden" name="action" value="change_password" /> 28 <label for="password">New Password:</label> 29 <input type="password" id="password" name="password" class="textwidget" 30 size="20" /> 31 </div> 32 <div> 33 <label for="password_confirm">Confirm Password:</label> 34 <input type="password" id="password_confirm" name="password_confirm" 35 class="textwidget" size="20" /> 36 </div> 37 <input type="submit" value="Change password" /> 38 </form> 39 40 <form method="post" action="" py:if="account.delete_enabled" 41 onsubmit="return confirm('Are you sure you want to delete your account?');"> 42 <input type="hidden" name="action" value="delete" /> 43 <input type="submit" value="Delete account" /> 44 </form> 45 34 <div class="field"> 35 <label>New Password: 36 <input type="password" name="password" class="textwidget" 37 size="20" /> 38 </label> 39 </div> 40 <div class="field"> 41 <label>Confirm Password: 42 <input type="password" name="password_confirm" class="textwidget" 43 size="20" /> 44 </label> 46 45 </div> 47 46 </body> accountmanagerplugin/trunk/acct_mgr/templates/reset_password.html
r1508 r1560 17 17 <div class="system-message" py:when="reset.logged_in"> 18 18 <h2>Already logged in</h2> 19 <p>You're already logged in. If you need to change your password please use 20 the <a href="${href.account()}">My Account</a> page.</p> 19 <p>You're already logged in. If you need to change your password 20 please use the 21 <a href="${href.prefs('account')}">Account Preferences</a> page.</p> 21 22 </div> 22 23 accountmanagerplugin/trunk/acct_mgr/web_ui.py
r1535 r1560 19 19 from trac.config import IntOption 20 20 from trac.notification import NotificationSystem, NotifyEmail 21 from trac.prefs import IPreferencePanelProvider 21 22 from trac.web import auth 22 23 from trac.web.api import IAuthenticator … … 121 122 """ 122 123 123 implements(I NavigationContributor, IRequestHandler, ITemplateProvider)124 implements(IPreferencePanelProvider, IRequestHandler, ITemplateProvider) 124 125 125 126 _password_chars = string.ascii_letters + string.digits … … 139 140 return writable 140 141 141 #INavigationContributor methods 142 def get_active_navigation_item(self, req): 143 return 'account' 144 145 def get_navigation_items(self, req): 142 #IPreferencePanelProvider methods 143 def get_preference_panels(self, req): 146 144 if not self._write_check(): 147 145 return 148 if req.authname != 'anonymous': 149 yield 'metanav', 'account', Markup('<a href="%s">My Account</a>', 150 (req.href.account())) 146 if req.authname and req.authname != 'anonymous': 147 yield 'account', 'Account' 148 149 def render_preference_panel(self, req, panel): 150 data = {'account': self._do_account(req)} 151 print data 152 return 'prefs_account.html', data 151 153 152 154 # IRequestHandler methods 153 155 def match_request(self, req): 154 return (req.path_info in ('/account', '/reset_password')156 return (req.path_info == '/reset_password' 155 157 and self._write_check(log=True)) 156 158 157 159 def process_request(self, req): 158 if req.path_info == '/account': 159 data = {'account': self._do_account(req)} 160 return 'account.html', data, None 161 elif req.path_info == '/reset_password': 162 data = {'reset': self._do_reset_password(req)} 163 return 'reset_password.html', data, None 160 data = {'reset': self._do_reset_password(req)} 161 return 'reset_password.html', data, None 164 162 165 163 def _do_account(self, req): 166 if req.authname == 'anonymous':164 if not req.authname or req.authname == 'anonymous': 167 165 req.redirect(self.env.href.wiki()) 168 166 action = req.args.get('action') … … 170 168 data = {'delete_enabled': delete_enabled} 171 169 if req.method == 'POST': 172 if action == ' change_password':170 if action == 'save': 173 171 data.update(self._do_change_password(req)) 174 elif action == 'delete' :172 elif action == 'delete' and delete_enabled: 175 173 data.update(self._do_delete(req)) 174 else: 175 data.update({'error': 'Invalid action'}) 176 176 return data 177 177 178 178 def _do_reset_password(self, req): 179 if req.authname != 'anonymous':179 if req.authname and req.authname != 'anonymous': 180 180 return {'logged_in': True} 181 181 if req.method != 'POST': … … 279 279 def process_request(self, req): 280 280 if req.authname != 'anonymous': 281 req.redirect(self.env.href. account())281 req.redirect(self.env.href.prefs('account')) 282 282 action = req.args.get('action') 283 283 data = {}
