Changeset 538


Ignore:
Timestamp:
08/09/11 11:01:58 (9 years ago)
Author:
bas
Message:

email2trac only used the default workflow. We now use the ticket workflow that is defined in trac.ini, see #226

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/email2trac.py.in

    r537 r538  
    649649        Check if the mailer is allowed to update the ticket
    650650        """
    651         self.logger.debug('function check_permission_participants')
     651        self.logger.debug('function check_permission_participants %s')
    652652
    653653        if tkt['reporter'].lower() in [self.author.lower(), self.email_addr.lower()]:
     
    689689            - email2trac: ....
    690690        """
    691         self.logger.debug("function check_permission")
     691        self.logger.debug("function check_permission: %s" %(action))
    692692
    693693        if self.parameters.ticket_permission_system in ['trac']:
     
    863863            self.logger.debug('Workflow ticket update fields: ')
    864864
    865             from trac.ticket.default_workflow import ConfigurableTicketWorkflow
    866             from trac.test import Mock, MockPerm
    867865
    868866            req = Mock(authname=self.author, perm=MockPerm(), args={})
     867            ticket_system = TicketSystem(self.env)
     868
    869869            try:
    870870                workflow = self.parameters['workflow_%s' %tkt['status'].lower()]
     
    878878                    workflow = self.parameters.workflow
    879879
    880             controller = ConfigurableTicketWorkflow(self.env)
    881             #print controller.actions
    882             #print controller.actions.keys()
    883             #print controller.get_ticket_actions(req, tkt)
    884             #print controller.actions[workflow]
    885             #print controller.actions[workflow]['permissions'] is a list
    886880
    887881            if workflow:
    888882
    889                 if self.parameters.ticket_permission_system:
    890 
    891                     if self.check_permission(tkt, controller.actions[workflow]['permissions'][0]):
    892                         fields = controller.get_ticket_changes(req, tkt, workflow)
    893                     else:
    894                         fields = dict()
    895                         self.logger.info('Reporter: %s has no permission to trigger workflow' %self.author)
    896 
    897                 else:
     883                ## There can be several workflow implementations
     884                #
     885                for controller in ticket_system.action_controllers:
     886
     887                    if self.parameters.ticket_permission_system:
     888
     889                        ## Could be disabled in the future !?
     890                        #
     891                        try:
     892                            if not self.check_permission(tkt, controller.actions[workflow]['permissions'][0]):
     893                                self.logger.info('Reporter: %s has no permission to trigger workflow' %self.author)
     894                                break
     895                        except AttributeError, detail:
     896                                self.logger.info('controller %s has no actions implementations' %(controller))
     897
    898898                    fields = controller.get_ticket_changes(req, tkt, workflow)
    899899
    900                 for key in fields.keys():
    901                     self.logger.debug('\t %s : %s' %(key, fields[key]))
    902                     tkt[key] = fields[key]
    903 
     900                    for key in fields.keys():
     901                        self.logger.debug('\t workflow %s %s : %s' %(controller, key, fields[key]))
     902                        tkt[key] = fields[key]
     903                           
    904904            else:
    905905
     
    12911291        from tracfullblog.core import FullBlogCore
    12921292        from tracfullblog.model import BlogPost, BlogComment
    1293         from trac.test import Mock, MockPerm
    12941293
    12951294        ## instantiate blog core
     
    24592458            from trac.perm import PermissionSystem
    24602459            from trac.ticket.web_ui import TicketModule
     2460            from trac.ticket.api import TicketSystem
     2461            from trac.test import Mock, MockPerm
    24612462
    24622463            #
     
    24762477            from trac.perm import PermissionSystem
    24772478            from trac.ticket.web_ui import TicketModule
     2479            from trac.ticket.api import TicketSystem
     2480            from trac.test import Mock, MockPerm
    24782481
    24792482            #
Note: See TracChangeset for help on using the changeset viewer.