Anonymous committed 9433274

[svn r6684] Added BUILD_VIEW permission; no build nav menu or build entries in the
timeline are displayed if the user does not have this permission.

Upgrade note: your builds will not show up anymore until you give users
this permission.

This closes #2555.

  • Participants
  • Parent commits 594ba37

Comments (0)

Files changed (1)

File 0.10/HudsonTrac/

 from datetime import datetime
 from trac.core import *
 from trac.config import Option, BoolOption
+from trac.perm import IPermissionRequestor
 from trac.util import Markup, format_datetime, pretty_timedelta
 from import INavigationContributor, ITemplateProvider, add_stylesheet
     from trac.Timeline import ITimelineEventProvider
 class HudsonTracPlugin(Component):
-    implements(INavigationContributor, ITimelineEventProvider, ITemplateProvider)
+    implements(INavigationContributor, ITimelineEventProvider, ITemplateProvider,
+               IPermissionRequestor)
     disp_mod = BoolOption('hudson', 'display_modules', 'false',
                           'Display status of modules in the timeline too. ' +
         self.env.log.debug("Build-info url: '%s'" % self.info_url)
+    # IPermissionRequestor methods  
+    def get_permission_actions(self):
+        return ['BUILD_VIEW']
     # INavigationContributor methods
     def get_active_navigation_item(self, req):
         return 'builds'
     def get_navigation_items(self, req):
-        if self.nav_url:
+        if self.nav_url and 'BUILD_VIEW' in req.perm:
             yield 'mainnav', 'builds', Markup('<a href="%s"%s>Builds</a>' % \
                         (self.nav_url, self.disp_tab and ' target="hudson"' or ''))
     # ITimelineEventProvider methods
     def get_timeline_filters(self, req):
-        if req.perm.has_permission('CHANGESET_VIEW'):
+        if 'BUILD_VIEW' in req.perm:
             yield ('build', 'Hudson Builds')
     def get_timeline_events(self, req, start, stop, filters):
-        if not 'build' in filters:
+        if 'build' not in filters or 'BUILD_VIEW' not in req.perm:
         # xml parsing helpers