Ticket #2667: TIME_VIEW_and_TIME_ADMIN.diff

File TIME_VIEW_and_TIME_ADMIN.diff, 2.1 kB (added by fecht, 10 months ago)

patch that makes the necessary changes in webui.py@rev3290

  • timingandestimationplugin/webui.py

    old new  
    77from usermanual import *  
    88from trac.log import logger_factory 
    99from trac.core import * 
     10from trac.perm import IPermissionRequestor 
    1011from trac.web import IRequestHandler 
    1112from trac.util import Markup 
    1213from trac.web.chrome import add_stylesheet, add_script, \ 
     
    1819#get_statuses = api.get_statuses 
    1920 
    2021class TimingEstimationAndBillingPage(Component): 
    21     implements(INavigationContributor, IRequestHandler, ITemplateProvider) 
     22    implements(IPermissionRequestor, INavigationContributor, IRequestHandler, ITemplateProvider) 
    2223 
    2324    def __init__(self): 
    2425        pass 
     
    3839        """ 
    3940        dbhelper.execute_non_query(sql, when, now, strwhen) 
    4041 
    41      
    42  
    4342         
    44          
     43    # IPermissionRequestor methods 
     44    def get_permission_actions(self): 
     45        return ["TIME_VIEW", ("TIME_ADMIN", ["TIME_VIEW"])] 
    4546             
    4647    # INavigationContributor methods 
    4748    def get_active_navigation_item(self, req): 
     
    5253 
    5354    def get_navigation_items(self, req): 
    5455        url = req.href.Billing() 
    55         if req.perm.has_permission("REPORT_VIEW"): 
    56             yield 'mainnav', "Billing", \ 
     56        if req.perm.has_permission("TIME_VIEW"): 
     57            yield 'mainnav', "billing", \ 
    5758                  Markup('<a href="%s">%s</a>' % \ 
    5859                         (url , "Management")) 
    5960 
     
    8384 
    8485        if req.method == 'POST': 
    8586            if req.args.has_key('setbillingtime'): 
    86                 self.set_bill_date(req.authname) 
    87                 addMessage("All tickets last bill date updated") 
     87                if req.perm.has_permission("TIME_ADMIN"): 
     88                    self.set_bill_date(req.authname) 
     89                    addMessage("All tickets last bill date updated") 
     90                else: 
     91                    addMessage("You don't have permission to set a new bill date!") 
    8892 
    8993        mgr = CustomReportManager(self.env, self.log) 
    9094        data = {};