Edgewall Software

Ticket #3921: sort-and-perm-display-enhancement.2.patch

File sort-and-perm-display-enhancement.2.patch, 2.1 KB (added by awbacker@…, 2 years ago)

(new) patch for perm.py&admin_perm.py, now with code style

  • webadmin/perm.py

     
    6060                        perm.revoke_permission(subject, action) 
    6161                req.redirect(self.env.href.admin(cat, page)) 
    6262         
    63         perms.sort(lambda a, b: cmp(a[0], b[0])) 
     63        #sort by subject+perm, so we get the perms sorted inside the subject 
     64        perms.sort(lambda a, b: cmp(a[0]+a[1], b[0]+b[1])) 
    6465        req.hdf['admin.actions'] = perm.get_actions() 
    6566        req.hdf['admin.perms'] = [{'subject': p[0], 
    6667                                   'action': p[1], 
  • webadmin/templates/admin_perm.cs

     
    3636<form method="post"> 
    3737 <table class="listing" id="permlist"> 
    3838  <thead> 
    39    <tr><th class="sel">&nbsp;</th><th>Subject</th><th>Action</th></tr> 
    40   </thead><tbody><?cs 
    41   each:perm = admin.perms ?> 
    42    <tr> 
    43     <td><input type="checkbox" name="sel" value="<?cs var:perm.key ?>" /></td> 
    44     <td><?cs var:perm.subject ?></td> 
    45     <td><?cs var:perm.action ?></td> 
    46    </tr><?cs 
    47   /each ?></tbody> 
     39   <tr><th width="100">Subject</th><th>Action</th></tr> 
     40  </thead> 
     41  <tbody> 
     42   <?cs set:firstRun="1" ?> 
     43   <?cs each:perm = admin.perms ?>          
     44    <?cs # draws the start of a row for each new person ?> 
     45     <?cs if:(perm.subject != lastSubject) ?> 
     46      <?cs if:(firstRun=="0")?></td></tr><?cs /if ?> 
     47       <tr> 
     48        <td><?cs var:perm.subject ?></td> 
     49        <td> 
     50      <?cs /if ?>          
     51 
     52          <div style="width:150px;display:block;float:left;"> 
     53       <input type="checkbox" name="sel" value="<?cs var:perm.key ?>" /> 
     54       <?cs var:perm.action ?> 
     55      </div> 
     56         
     57      <?cs set:firstRun="0"?>          
     58      <?cs set:lastSubject=perm.subject?> 
     59    <?cs /each ?> 
     60    <?cs # this is needed to close-up after the last subject  ?> 
     61    </td></tr> 
     62  </tbody> 
    4863 </table> 
    4964 <div class="buttons"> 
    5065  <input type="submit" name="remove" value="Remove selected items" />