当前位置: 首页>>代码示例>>Python>>正文


Python TicketSystem.get_available_actions方法代码示例

本文整理汇总了Python中trac.ticket.api.TicketSystem.get_available_actions方法的典型用法代码示例。如果您正苦于以下问题:Python TicketSystem.get_available_actions方法的具体用法?Python TicketSystem.get_available_actions怎么用?Python TicketSystem.get_available_actions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trac.ticket.api.TicketSystem的用法示例。


在下文中一共展示了TicketSystem.get_available_actions方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_available_actions_no_perms

# 需要导入模块: from trac.ticket.api import TicketSystem [as 别名]
# 或者: from trac.ticket.api.TicketSystem import get_available_actions [as 别名]
 def test_available_actions_no_perms(self):
     ts = TicketSystem(self.env)
     perm = Mock(has_permission=lambda x: 0)
     self.assertEqual(['leave'],
                      ts.get_available_actions({'status': 'new'}, perm))
     self.assertEqual(['leave'],
                      ts.get_available_actions({'status': 'assigned'}, perm))
     self.assertEqual(['leave'],
                      ts.get_available_actions({'status': 'reopened'}, perm))
     self.assertEqual(['leave'],
                      ts.get_available_actions({'status': 'closed'}, perm))
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:13,代码来源:api.py

示例2: test_available_actions_create_only

# 需要导入模块: from trac.ticket.api import TicketSystem [as 别名]
# 或者: from trac.ticket.api.TicketSystem import get_available_actions [as 别名]
 def test_available_actions_create_only(self):
     ts = TicketSystem(self.env)
     perm = Mock(has_permission=lambda x: x == 'TICKET_CREATE')
     self.assertEqual(['leave'],
                      ts.get_available_actions({'status': 'new'}, perm))
     self.assertEqual(['leave'],
                      ts.get_available_actions({'status': 'assigned'}, perm))
     self.assertEqual(['leave'],
                      ts.get_available_actions({'status': 'reopened'}, perm))
     self.assertEqual(['leave', 'reopen'],
                      ts.get_available_actions({'status': 'closed'}, perm))
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:13,代码来源:api.py

示例3: test_available_actions_chgprop_only

# 需要导入模块: from trac.ticket.api import TicketSystem [as 别名]
# 或者: from trac.ticket.api.TicketSystem import get_available_actions [as 别名]
 def test_available_actions_chgprop_only(self):
     # CHGPROP is not enough for changing a ticket's state (#3289)
     ts = TicketSystem(self.env)
     perm = Mock(has_permission=lambda x: x == 'TICKET_CHGPROP')
     self.assertEqual(['leave'],
                      ts.get_available_actions({'status': 'new'}, perm))
     self.assertEqual(['leave'],
                      ts.get_available_actions({'status': 'assigned'}, perm))
     self.assertEqual(['leave'],
                      ts.get_available_actions({'status': 'reopened'}, perm))
     self.assertEqual(['leave'],
                      ts.get_available_actions({'status': 'closed'}, perm))
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:14,代码来源:api.py

示例4: _implementation

# 需要导入模块: from trac.ticket.api import TicketSystem [as 别名]
# 或者: from trac.ticket.api.TicketSystem import get_available_actions [as 别名]
        def _implementation(db):
            tkt = Ticket(self.env, ticket_id)
            ts = TicketSystem(self.env)
            tm = TicketModule(self.env)
            if action not in ts.get_available_actions(req, tkt):
                raise ValueError(["This ticket cannot be moved to this status,\
                      perhaps the ticket has been updated by someone else."])

            field_changes, problems = \
                tm.get_ticket_changes(req, tkt, action)

            if problems:
                raise ValueError(problems)

            tm._apply_ticket_changes(tkt, field_changes)
            valid = tm._validate_ticket(req, tkt, force_collision_check=True)
            if not valid:
                raise ValueError(req.chrome['warnings'])
            else:
                tkt.save_changes(req.authname, "", when=datetime.now(utc))
开发者ID:CGI-define-and-primeportal,项目名称:trac-plugin-agiletools,代码行数:22,代码来源:taskboard.py

示例5: getActions

# 需要导入模块: from trac.ticket.api import TicketSystem [as 别名]
# 或者: from trac.ticket.api.TicketSystem import get_available_actions [as 别名]
 def getActions(self, req, id):
     """Returns the actions that can be performed on the ticket as a list of
     `[action, label, hints, [input_fields]]` elements, where `input_fields` is
     a list of `[name, value, [options]]` for any required action inputs."""
     ts = TicketSystem(self.env)
     t = model.Ticket(self.env, id)
     actions = []
     for action in ts.get_available_actions(req, t):
         fragment = genshi.builder.Fragment()
         hints = []
         first_label = None
         for controller in ts.action_controllers:
             if action in [c_action for c_weight, c_action \
                             in controller.get_ticket_actions(req, t)]:
                 label, widget, hint = \
                     controller.render_ticket_action_control(req, t, action)
                 fragment += widget
                 hints.append(to_unicode(hint).rstrip('.') + '.')
                 first_label = first_label == None and label or first_label
         controls = []
         for elem in fragment.children:
             if not isinstance(elem, genshi.builder.Element):
                 continue
             if elem.tag == 'input':
                 controls.append((elem.attrib.get('name'),
                                 elem.attrib.get('value'), []))
             elif elem.tag == 'select':
                 value = ''
                 options = []
                 for opt in elem.children:
                     if not (opt.tag == 'option' and opt.children):
                         continue
                     option = opt.children[0]
                     options.append(option)
                     if opt.attrib.get('selected'):
                         value = option
                 controls.append((elem.attrib.get('name'),
                                 value, options))
         actions.append((action, first_label, " ".join(hints), controls))
     return actions
开发者ID:42cc,项目名称:XmlRpcPlugin,代码行数:42,代码来源:ticket.py

示例6: _get_actions

# 需要导入模块: from trac.ticket.api import TicketSystem [as 别名]
# 或者: from trac.ticket.api.TicketSystem import get_available_actions [as 别名]
 def _get_actions(self, ticket_dict):
     ts = TicketSystem(self.env)
     ticket = Ticket(self.env)
     ticket.populate(ticket_dict)
     id = ticket.insert()
     return ts.get_available_actions(self.req, Ticket(self.env, id))
开发者ID:domaemon,项目名称:bloodhound-qa,代码行数:8,代码来源:api.py

示例7: update

# 需要导入模块: from trac.ticket.api import TicketSystem [as 别名]
# 或者: from trac.ticket.api.TicketSystem import get_available_actions [as 别名]
 def update(self, req, id, comment, attributes={}, notify=False, author='', when=None):
     """ Update a ticket, returning the new ticket in the same form as
     get(). 'New-style' call requires two additional items in attributes:
     (1) 'action' for workflow support (including any supporting fields
     as retrieved by getActions()),
     (2) '_ts' changetime token for detecting update collisions (as received
     from get() or update() calls).
     ''Calling update without 'action' and '_ts' changetime token is
     deprecated, and will raise errors in a future version.'' """
     t = model.Ticket(self.env, id)
     # custom author?
     if author and not (req.authname == 'anonymous' \
                         or 'TICKET_ADMIN' in req.perm(t.resource)):
         # only allow custom author if anonymous is permitted or user is admin
         self.log.warn("RPC ticket.update: %r not allowed to change author "
                 "to %r for comment on #%d", req.authname, author, id)
         author = ''
     author = author or req.authname
     # custom change timestamp?
     if when and not 'TICKET_ADMIN' in req.perm(t.resource):
         self.log.warn("RPC ticket.update: %r not allowed to update #%d with "
                 "non-current timestamp (%r)", author, id, when)
         when = None
     when = when or to_datetime(None, utc)
     # and action...
     if not 'action' in attributes:
         # FIXME: Old, non-restricted update - remove soon!
         self.log.warning("Rpc ticket.update for ticket %d by user %s " \
                 "has no workflow 'action'." % (id, req.authname))
         req.perm(t.resource).require('TICKET_MODIFY')
         time_changed = attributes.pop('_ts', None)
         if time_changed and \
                 str(time_changed) != str(to_utimestamp(t.time_changed)):
             raise TracError("Ticket has been updated since last get().")
         for k, v in attributes.iteritems():
             t[k] = v
         t.save_changes(author, comment, when=when)
     else:
         ts = TicketSystem(self.env)
         tm = TicketModule(self.env)
         # TODO: Deprecate update without time_changed timestamp
         time_changed = attributes.pop('_ts', to_utimestamp(t.time_changed))
         try:
             time_changed = int(time_changed)
         except ValueError:
             raise TracError("RPC ticket.update: Wrong '_ts' token " \
                             "in attributes (%r)." % time_changed)
         action = attributes.get('action')
         avail_actions = ts.get_available_actions(req, t)
         if not action in avail_actions:
             raise TracError("Rpc: Ticket %d by %s " \
                     "invalid action '%s'" % (id, req.authname, action))
         controllers = list(tm._get_action_controllers(req, t, action))
         all_fields = [field['name'] for field in ts.get_ticket_fields()]
         for k, v in attributes.iteritems():
             if k in all_fields and k != 'status':
                 t[k] = v
         # TicketModule reads req.args - need to move things there...
         req.args.update(attributes)
         req.args['comment'] = comment
         # Collision detection: 0.11+0.12 timestamp
         req.args['ts'] = str(from_utimestamp(time_changed))
         # Collision detection: 0.13/1.0+ timestamp
         req.args['view_time'] = str(time_changed)
         changes, problems = tm.get_ticket_changes(req, t, action)
         for warning in problems:
             add_warning(req, "Rpc ticket.update: %s" % warning)
         valid = problems and False or tm._validate_ticket(req, t)
         if not valid:
             raise TracError(
                 " ".join([warning for warning in req.chrome['warnings']]))
         else:
             tm._apply_ticket_changes(t, changes)
             self.log.debug("Rpc ticket.update save: %s" % repr(t.values))
             t.save_changes(author, comment, when=when)
             # Apply workflow side-effects
             for controller in controllers:
                 controller.apply_action_side_effects(req, t, action)
     if notify:
         try:
             tn = TicketNotifyEmail(self.env)
             tn.notify(t, newticket=False, modtime=when)
         except Exception, e:
             self.log.exception("Failure sending notification on change of "
                                "ticket #%s: %s" % (t.id, e))
开发者ID:42cc,项目名称:XmlRpcPlugin,代码行数:87,代码来源:ticket.py

示例8: invoke

# 需要导入模块: from trac.ticket.api import TicketSystem [as 别名]
# 或者: from trac.ticket.api.TicketSystem import get_available_actions [as 别名]
    def invoke(self, message, warnings):
        """reply to a ticket"""
        ticket = self.ticket
        reporter = self._reporter(message)
        # get the mailBody and attachments
        mailBody, attachments = get_body_and_attachments(message)
        if not mailBody:
            warnings.append("Seems to be a reply to %s but I couldn't find a comment")
            return message

        #go throught work

        ts = TicketSystem(self.env)
        tm = TicketModule(self.env)
        perm = PermissionSystem(self.env)
        # TODO: Deprecate update without time_changed timestamp
        mockReq = self._MockReq(perm.get_user_permissions(reporter), reporter)
        avail_actions = ts.get_available_actions(mockReq, ticket)

        mailBody, inBodyFields, actions = self._get_in_body_fields(mailBody, avail_actions, reporter)
        if inBodyFields or actions :
            # check permissions
            perm = PermissionSystem(self.env)
            #we have properties movement, cheking user permission to do so
            if not perm.check_permission('MAIL2TICKET_PROPERTIES', reporter) : # None -> 'anoymous'
                raise ("%s does not have MAIL2TICKET_PROPERTIES permissions" % (user or 'anonymous'))

        action = None
        if actions :
            action = actions.keys()[0] 
        controllers = list(tm._get_action_controllers(mockReq, ticket, action))
        all_fields = [field['name'] for field in ts.get_ticket_fields()]


        #impact changes find in inBodyFields
        for field in inBodyFields :
            ticket._old[field] = ticket[field]
            ticket.values[field] = inBodyFields[field]
            mockReq.args[field] = inBodyFields[field]
        if action : 
            mockReq.args['action_%s_reassign_owner' % action] = ticket['owner']



        mockReq.args['comment'] = mailBody
        mockReq.args['ts'] = datetime.now()#to_datetime(None, utc)


        mockReq.args['ts'] = str(ticket.time_changed)
        
        changes, problems = tm.get_ticket_changes(mockReq, ticket, action)
        valid = problems and False or tm._validate_ticket(mockReq, ticket)

        tm._apply_ticket_changes(ticket, changes)


        # add attachments to the ticket
        add_attachments(self.env, ticket, attachments)

        ticket.save_changes(reporter, mailBody)
        
        for controller in controllers:
            controller.apply_action_side_effects(mockReq, ticket, action)
            # Call ticket change listeners
        for listener in ts.change_listeners:
            listener.ticket_changed(ticket, mailBody, reporter, ticket._old)

        tn = TicketNotifyEmail(self.env)
        tn.notify(ticket, newticket=0, modtime=ticket.time_changed)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:71,代码来源:email2ticket.py

示例9: getAvailableActions

# 需要导入模块: from trac.ticket.api import TicketSystem [as 别名]
# 或者: from trac.ticket.api.TicketSystem import get_available_actions [as 别名]
 def getAvailableActions(self, req, id):
     """Returns the actions that can be performed on the ticket."""
     ticketSystem = TicketSystem(self.env)
     t = model.Ticket(self.env, id)
     return ticketSystem.get_available_actions(t, req.perm)
开发者ID:Puppet-Finland,项目名称:trac,代码行数:7,代码来源:ticket.py


注:本文中的trac.ticket.api.TicketSystem.get_available_actions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。