1. BoldProgressives
  2. Untitled project
  3. trac-gitolite-plugin

Commits

ejucovy  committed 0ce1241

implement HTML for admin perm-management panel

  • Participants
  • Parent commits 2c4c6da
  • Branches default

Comments (0)

Files changed (2)

File trac_gitolite/conf_writer.py

View file
  • Ignore whitespace
 
     gitolite_admin_reponame = Option('trac-gitolite', 'admin_reponame',
                                      default="gitolite-admin")
+    
+    def get_users(self):
+        repo = self.env.get_repository(reponame=self.gitolite_admin_reponame)
+        node = repo.get_node("keydir")
+        assert node.isdir, "Node %s at /keydir/ is not a directory" % node
+        for child in node.get_entries():
+            name = child.get_name()
+            assert name.endswith(".pub"), "Node %s" % name
+            yield name[:-4]
 
     def read_config(self):
         repo = self.env.get_repository(reponame=self.gitolite_admin_reponame)
             for perm in p:
                 flattened_perms.add(perm)
         flattened_perms = list(flattened_perms)
-        tail = []
-        ## Ensure the + goes last
-        if '+' in flattened_perms:
-            flattened_perms.remove("+")
-            tail.append("+")
-        flattened_perms = sorted(flattened_perms)
-        flattened_perms.extend(tail)
+        def sort_perms(perms):
+            tail = []
+            ## Ensure the + goes last
+            if '+' in perms:
+                perms.remove("+")
+                tail.append("+")
+            perms = sorted(perms)
+            perms.extend(tail)
+            return perms
+        flattened_perms = sort_perms(flattened_perms)
 
-        data = {'repositories': perms, 'permissions': flattened_perms}
+        data = {'repositories': perms, 'permissions': flattened_perms, 'users': list(self.get_users()),
+                'sort_perms': sort_perms}
         return 'admin_repository_permissions.html', data
 
     # ITemplateProvider methods

File trac_gitolite/templates/admin_repository_permissions.html

View file
  • Ignore whitespace
       <thead>
 	<tr>
 	  <th>Repository</th>
-	  <th py:for="perm in permissions">$perm</th>
+	  <th py:for="user in users">$user</th>
 	</tr>
       </thead>
       <tbody>
-	<tr py:for="repo, perms in repositories.items()">
+	<tr py:for="repo, repo_perms in repositories.items()">
 	  <td>$repo</td>
-	  <td py:for="perm, users in perms.items()">
-	    $users
+	  <td py:for="user in users">
+	    <label py:for="perm in sort_perms(repo_perms.keys())"
+		   for="$repo|$user|$perm"
+		   style="border: 1px solid lightgray; border-radius: 5px; padding: 2px; margin-right: 2px">
+	      $perm
+	      <input type="checkbox" checked="checked" py:if="user in repo_perms[perm]" />
+	      <input type="checkbox" py:if="user not in repo_perms[perm]" />
+	    </label>
 	  </td>
 	</tr>
       </tbody>