Commits

ejucovy  committed 2c4c6da

start working on an admin panel

  • Participants
  • Parent commits cdd780e

Comments (0)

Files changed (2)

File trac_gitolite/conf_writer.py

+import pkg_resources
+
 from trac.admin import IAdminPanelProvider
 from trac.core import *
 from trac.config import Option, BoolOption
 from trac.util.translation import _
+from trac.web.chrome import ITemplateProvider
 
 from trac_gitolite import utils
 
 class GitoliteConfWriter(Component):
-    implements(IAdminPanelProvider)
+    implements(IAdminPanelProvider, ITemplateProvider)
 
     gitolite_admin_reponame = Option('trac-gitolite', 'admin_reponame',
                                      default="gitolite-admin")
         if req.method == 'POST':
             req.redirect(req.href.admin(category, page))
         
-        data = {'perms': perms}
+        flattened_perms = set()
+        for p in perms.values():
+            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)
+
+        data = {'repositories': perms, 'permissions': flattened_perms}
         return 'admin_repository_permissions.html', data
+
+    # ITemplateProvider methods
+
+    def get_htdocs_dirs(self):
+        return []
+
+    def get_templates_dirs(self):
+        return [pkg_resources.resource_filename('trac_gitolite', 'templates')]

File trac_gitolite/templates/admin_repository_permissions.html

+<!DOCTYPE html
+    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:xi="http://www.w3.org/2001/XInclude"
+      xmlns:py="http://genshi.edgewall.org/"
+      xmlns:i18n="http://genshi.edgewall.org/i18n">
+  <xi:include href="admin.html"/>
+  <head>
+    <title>Repository Permissions</title>
+  </head>
+
+  <body>
+    <h2>Manage Repository Permissions</h2>
+
+    <table class="listing">
+      <thead>
+	<tr>
+	  <th>Repository</th>
+	  <th py:for="perm in permissions">$perm</th>
+	</tr>
+      </thead>
+      <tbody>
+	<tr py:for="repo, perms in repositories.items()">
+	  <td>$repo</td>
+	  <td py:for="perm, users in perms.items()">
+	    $users
+	  </td>
+	</tr>
+      </tbody>
+    </table>
+
+  </body>
+
+</html>