Changeset 1560

Show
Ignore:
Timestamp:
11/14/06 00:10:20 (2 years ago)
Author:
mgood
Message:

AccountManagerPlugin:

move "My Account" page into a new "Preferences" panel (fixes #58)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • accountmanagerplugin/trunk/acct_mgr/templates/prefs_account.html

    r1534 r1560  
    55      xmlns:py="http://genshi.edgewall.org/" 
    66      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  
    822  <head> 
    9     <title>My Account</title> 
     23    <title>Account</title> 
    1024  </head> 
    1125 
    1226  <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> 
    1531 
    16       <p>Manage your user account.</p> 
     32    <p py:if="account.message">$account.message</p> 
    1733 
    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> 
    4645    </div> 
    4746  </body> 
  • accountmanagerplugin/trunk/acct_mgr/templates/reset_password.html

    r1508 r1560  
    1717      <div class="system-message" py:when="reset.logged_in"> 
    1818        <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> 
    2122      </div> 
    2223 
  • accountmanagerplugin/trunk/acct_mgr/web_ui.py

    r1535 r1560  
    1919from trac.config import IntOption 
    2020from trac.notification import NotificationSystem, NotifyEmail 
     21from trac.prefs import IPreferencePanelProvider 
    2122from trac.web import auth 
    2223from trac.web.api import IAuthenticator 
     
    121122    """ 
    122123 
    123     implements(INavigationContributor, IRequestHandler, ITemplateProvider) 
     124    implements(IPreferencePanelProvider, IRequestHandler, ITemplateProvider) 
    124125 
    125126    _password_chars = string.ascii_letters + string.digits 
     
    139140        return writable 
    140141 
    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): 
    146144        if not self._write_check(): 
    147145            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 
    151153 
    152154    # IRequestHandler methods 
    153155    def match_request(self, req): 
    154         return (req.path_info in ('/account', '/reset_password') 
     156        return (req.path_info == '/reset_password' 
    155157                and self._write_check(log=True)) 
    156158 
    157159    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 
    164162 
    165163    def _do_account(self, req): 
    166         if req.authname == 'anonymous': 
     164        if not req.authname or req.authname == 'anonymous': 
    167165            req.redirect(self.env.href.wiki()) 
    168166        action = req.args.get('action') 
     
    170168        data = {'delete_enabled': delete_enabled} 
    171169        if req.method == 'POST': 
    172             if action == 'change_password': 
     170            if action == 'save': 
    173171                data.update(self._do_change_password(req)) 
    174             elif action == 'delete'
     172            elif action == 'delete' and delete_enabled
    175173                data.update(self._do_delete(req)) 
     174            else: 
     175                data.update({'error': 'Invalid action'}) 
    176176        return data 
    177177 
    178178    def _do_reset_password(self, req): 
    179         if req.authname != 'anonymous': 
     179        if req.authname and req.authname != 'anonymous': 
    180180            return {'logged_in': True} 
    181181        if req.method != 'POST': 
     
    279279    def process_request(self, req): 
    280280        if req.authname != 'anonymous': 
    281             req.redirect(self.env.href.account()) 
     281            req.redirect(self.env.href.prefs('account')) 
    282282        action = req.args.get('action') 
    283283        data = {}