Code

fixed history to display username instead of userid
[roundup.git] / roundup / cgi / templating.py
index 9f24a19fe400831077aebdc1b7f8886d62661b2f..cfe998e01dd97b4d149e654d29b8e1581bb57b2d 100644 (file)
@@ -126,10 +126,10 @@ class RoundupPageTemplate(PageTemplate.PageTemplate):
            - methods for easy filterspec link generation
            - *user*, the current user node as an HTMLItem instance
            - *form*, the current CGI form information as a FieldStorage
-        *tracker*
-          The current tracker
+        *config*
+          The current tracker config.
         *db*
-          The current database, through which db.config may be reached.
+          The current database, used to access arbitrary database items.
     '''
     def getContext(self, client, classname, request):
         c = {
@@ -137,6 +137,7 @@ class RoundupPageTemplate(PageTemplate.PageTemplate):
              'nothing': None,
              'request': request,
              'db': HTMLDatabase(client),
+             'config': client.instance.config,
              'tracker': client.instance,
              'utils': TemplatingUtils(client),
              'templates': Templates(client.instance.config.TEMPLATES),
@@ -489,7 +490,7 @@ class HTMLItem(HTMLPermissions):
         # XXX do this
         return []
 
-    def history(self, direction='descending'):
+    def history(self, direction='descending', dre=re.compile('\d+')):
         l = ['<table class="history">'
              '<tr><th colspan="4" class="header">',
              _('History'),
@@ -628,6 +629,10 @@ class HTMLItem(HTMLPermissions):
                     handled by the history display!</em></strong>''')
                 arg_s = '<strong><em>' + str(args) + '</em></strong>'
             date_s = date_s.replace(' ', '&nbsp;')
+            # if the user's an itemid, figure the username (older journals
+            # have the username)
+            if dre.match(user):
+                user = self._db.user.get(user, 'username')
             l.append('<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>'%(
                 date_s, user, action, arg_s))
         if comments: