Changeset 1503

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

AccountManagerPlugin:

port admin page to Genshi so it works on Trac 0.11

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • accountmanagerplugin/trunk/acct_mgr/admin.py

    r1291 r1503  
    1414from trac.util import sorted 
    1515from trac.util.datefmt import format_datetime 
    16 from webadmin.web_ui import IAdminPageProvider 
     16from trac.admin import IAdminPanelProvider 
    1717 
    1818from acct_mgr.api import AccountManager 
     
    2121class AccountManagerAdminPage(Component): 
    2222 
    23     implements(IAdminPageProvider) 
     23    implements(IAdminPanelProvider) 
    2424 
    2525    def __init__(self): 
     
    2727 
    2828    # IAdminPageProvider 
    29     def get_admin_pages(self, req): 
     29    def get_admin_panels(self, req): 
    3030        if req.perm.has_permission('TRAC_ADMIN'): 
    3131            yield ('general', 'General', 'accounts', 'Accounts') 
    3232 
    33     def process_admin_request(self, req, cat, page, path_info): 
     33    def render_admin_panel(self, req, cat, page, path_info): 
    3434        perm = PermissionSystem(self.env) 
     35        data = {} 
    3536        if req.method == 'POST': 
    3637            if req.args.get('add'): 
     
    3839                    _create_user(req, self.env, check_permissions=False) 
    3940                except TracError, e: 
    40                     req.hdf['registration.error'] = e.message 
     41                    data['registration_error'] = e.message 
    4142            elif req.args.get('remove'): 
    4243                sel = req.args.get('sel') 
     
    6364                account['last_visit'] = format_datetime(last_visit) 
    6465 
    65         req.hdf['accounts'] = sorted(accounts.itervalues(), 
    66                                      key=lambda acct: acct['username']) 
     66        data['accounts'] = sorted(accounts.itervalues(), 
     67                                  key=lambda acct: acct['username']) 
    6768 
    68         return 'admin_accounts.cs', None 
     69        return 'admin_accounts.html', data 
    6970 
  • accountmanagerplugin/trunk/acct_mgr/templates/admin_accounts.html

    r1290 r1503  
    1 <h2>Manage User Accounts</h2> 
     1<!DOCTYPE html 
     2    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
     3    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
     4<html xmlns="http://www.w3.org/1999/xhtml" 
     5      xmlns:xi="http://www.w3.org/2001/XInclude" 
     6      xmlns:py="http://genshi.edgewall.org/"> 
     7  <xi:include href="admin.html" /> 
     8  <head> 
     9    <title>Basics</title> 
     10  </head> 
    211 
    3 <form id="addaccount" class="addnew" method="post"> 
    4  <fieldset> 
    5   <?cs if registration.error ?> 
    6   <div class="system-message"><p><?cs var:registration.error ?></p></div> 
    7   <?cs /if ?> 
     12  <body> 
     13    <h2>Manage User Accounts</h2> 
    814 
    9   <legend>Add Account:</legend> 
    10   <div class="field"> 
    11    <label>Username: <input type="text" name="user" class="textwidget" /></label> 
    12   </div> 
    13   <div class="field"> 
    14    <label>Password: <input type="password" name="password" class="textwidget" /></label> 
    15   </div> 
    16   <div class="field"> 
    17    <label>Confirm password: <input type="password" name="password_confirm" class="textwidget" /></label> 
    18   </div> 
    19   <div class="field"> 
    20    <label>Name: <input type="text" name="name" class="textwidget" /></label> 
    21   </div> 
    22   <div class="field"> 
    23    <label>Email: <input type="text" name="email" class="textwidget" /></label> 
    24   </div> 
    25   <p class="help">Add a new user account.</p> 
    26   <div class="buttons"> 
    27    <input type="submit" name="add" value=" Add "> 
    28   </div> 
    29  </fieldset> 
    30 </form> 
     15    <form id="addaccount" class="addnew" method="post"> 
     16      <fieldset> 
     17        <div class="system-message" 
     18             py:if="registration_error"><p>${registration_error}</p></div> 
    3119 
    32 <form method="post"> 
    33  <table class="listing" id="accountlist"> 
    34   <thead> 
    35    <tr><th class="sel">&nbsp;</th><th>Account</th><th>Name</th><th>Email</th><th>Last Login</th></tr> 
    36   </thead><tbody><?cs 
    37   each:account = accounts ?> 
    38    <tr> 
    39     <td><input type="checkbox" name="sel" value="<?cs var:account.username ?>" /></td> 
    40     <td><?cs var:account.username ?></td> 
    41         <td><?cs var:account.name ?></td> 
    42         <td><?cs var:account.email ?></td> 
    43         <td><?cs var:account.last_visit ?></td> 
    44    </tr><?cs 
    45   /each ?></tbody> 
    46  </table> 
    47  <div class="buttons"> 
    48   <input type="submit" name="remove" value="Remove selected accounts" /> 
    49  </div> 
    50 </form> 
     20        <legend>Add Account:</legend> 
     21        <div class="field"> 
     22          <label>Username: <input type="text" name="user" class="textwidget" /></label> 
     23        </div> 
     24        <div class="field"> 
     25          <label>Password: <input type="password" name="password" class="textwidget" /></label> 
     26        </div> 
     27        <div class="field"> 
     28          <label>Confirm password: <input type="password" name="password_confirm" class="textwidget" /></label> 
     29        </div> 
     30        <div class="field"> 
     31          <label>Name: <input type="text" name="name" class="textwidget" /></label> 
     32        </div> 
     33        <div class="field"> 
     34          <label>Email: <input type="text" name="email" class="textwidget" /></label> 
     35        </div> 
     36        <p class="help">Add a new user account.</p> 
     37        <div class="buttons"> 
     38          <input type="submit" name="add" value=" Add " /> 
     39        </div> 
     40      </fieldset> 
     41    </form> 
    5142 
    52  
     43    <form method="post"> 
     44      <table class="listing" id="accountlist"> 
     45        <thead> 
     46          <tr><th class="sel">&nbsp;</th><th>Account</th><th>Name</th><th>Email</th><th>Last Login</th></tr> 
     47        </thead> 
     48        <tbody> 
     49          <tr py:for="account in accounts"> 
     50            <td><input type="checkbox" name="sel" value="${account.username}" /></td> 
     51            <td>${account.username}</td> 
     52            <td>${account.name}</td> 
     53            <td>${account.email}</td> 
     54            <td>${account.last_visit}</td> 
     55          </tr> 
     56        </tbody> 
     57      </table> 
     58      <div class="buttons"> 
     59        <input type="submit" name="remove" value="Remove selected accounts" /> 
     60      </div> 
     61    </form> 
     62  </body> 
     63</html> 
  • accountmanagerplugin/trunk/setup.py

    r1128 r1503  
    55setup( 
    66    name = 'TracAccountManager', 
    7     version = '0.1.2', 
     7    version = '0.2', 
    88    author = 'Matthew Good', 
    99    author_email = 'trac@matt-good.net', 
     
    2222 
    2323    install_requires = [ 
    24         'TracWebAdmin', 
     24        #'trac>=0.11', 
    2525    ], 
    2626