Changes between Initial Version and Version 2 of Ticket #728


Ignore:
Timestamp:
Sep 21, 2006, 3:45:42 AM (18 years ago)
Author:
Noah Kantrowitz
Comment:

Rmoving patch from description at the request of the reporter.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #728

    • Property Type changed from defect to enhancement
  • Ticket #728 – Description

    initial v2  
    1 Here's a patch that adds aditional info to the admin page of the account manager plugin:
    2 {{{
    3 #!diff
    4 Index: acct_mgr/admin.py
    5 ===================================================================
    6 --- acct_mgr/admin.py   (revision 1286)
    7 +++ acct_mgr/admin.py   (working copy)
    8 @@ -9,6 +9,8 @@
    9  #
    10  # Author: Matthew Good <trac@matt-good.net>
    11 
    12 +from datetime import date
    13 +
    14  from trac.core import *
    15  from trac.perm import PermissionSystem
    16  from trac.util import sorted
    17 @@ -43,7 +45,26 @@
    18                  for account in sel:
    19                      self.account_manager.delete_user(account)
    20 
    21 -        req.hdf['accounts'] = sorted(self.account_manager.get_users())
    22 +        accounts = sorted(self.account_manager.get_users())
    23 +        db = self.env.get_db_cnx()
    24 +        cursor = db.cursor()
    25 +        hdf_accounts = []
    26 +        for account in accounts:
    27 +            QUERY = "SELECT name,value FROM session_attribute WHERE sid=%s AND authenticated=%s"
    28 +            cursor.execute(QUERY, (account,1))
    29 +            attrs = cursor.fetchall()
    30 +            acc_dict = dict(attrs)
    31 +            acc_dict['username'] = account
    32 +            QUERY = "SELECT last_visit FROM session WHERE sid=%s AND authenticated=%s"
    33 +            cursor.execute(QUERY, (account,1))
    34 +            acc_dict['last_visit'] = date.fromtimestamp(cursor.fetchone()[0])
    35 +            hdf_accounts.append(acc_dict)
    36 +
    37 +
    38 +        decorated = [(dict_['username'], dict_) for dict_ in hdf_accounts]
    39 +        decorated.sort()
    40 +        sorted_accounts = [dict_ for (key, dict_) in decorated]
    41 +        req.hdf['accounts'] = sorted_accounts
    42 
    43          return 'admin_accounts.cs', None
    44 -
    45 +
    46 Index: acct_mgr/templates/admin_accounts.cs
    47 ===================================================================
    48 --- acct_mgr/templates/admin_accounts.cs     (revision 1286)
    49 +++ acct_mgr/templates/admin_accounts.cs     (working copy)
    50 @@ -32,12 +32,15 @@
    51  <form method="post">
    52   <table class="listing" id="accountlist">
    53    <thead>
    54 -   <tr><th class="sel">&nbsp;</th><th>Account</th></tr>
    55 +   <tr><th class="sel">&nbsp;</th><th>Account</th><th>Name</th><th>Email</th><th>Last Login</th></tr>
    56    </thead><tbody><?cs
    57    each:account = accounts ?>
    58     <tr>
    59 -    <td><input type="checkbox" name="sel" value="<?cs var:account ?>" /></td>
    60 -    <td><?cs var:account ?></td>
    61 +    <td><input type="checkbox" name="sel" value="<?cs var:account.username ?>" /></td>
    62 +    <td><?cs var:account.username ?></td>
    63 +    <td><?cs var:account.name ?></td>
    64 +    <td><?cs var:account.email ?></td>
    65 +    <td><?cs var:account.last_visit ?></td>
    66     </tr><?cs
    67    /each ?></tbody>
    68   </table>
    69 }}}
     1Here's a patch that adds aditional info to the admin page of the account manager plugin.