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


Python Ticket.save_changes方法代码示例

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


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

示例1: ticket_changed

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import save_changes [as 别名]
    def ticket_changed(self, ticket, comment, author, old_values):
        """
        ticket发生变化后,判断该ticket是否有父节点。
        判断父节点下所有子几点是否结束。
        """
        #closed , accepted, new , parents
        db = self.env.get_db_cnx()
        cursor = db.cursor()
        if ticket.values["status"] == "closed" and "parents" in ticket.values and len(ticket.values["parents"]) > 0:
            #这里可以做检查。下面是检查的方法
            #通过上面这一句sql就能搞定。
            cursor.execute("SELECT COUNT(*) AS UNCLOSED FROM TICKET WHERE ID IN (SELECT CHILD FROM SUBTICKETS WHERE PARENT = %s) AND STATUS != 'closed'" % ticket.values["parents"])
            row = cursor.fetchone()
            try:
                unclosed = int(row[0])
                if unclosed == 0 :
                    #do close the parent
                    parentTicket = Ticket(self.env,ticket.values["parents"])
                    parentTicket._old["status"] = parentTicket.values["status"]
                    parentTicket.values["status"] = "closed"
                    parentTicket.values["resolution"] = "fixed"

                    parentTicket.save_changes(author, comment="all children has been closed")
                    self.log.debug("parent %s has been closed" % ticket.values["parents"])
                else:
                    self.log.debug("has %d unclosed children,so it did not  close")
                self.log.debug("the parent %s has %d unclosed child" % (ticket["parents"], unclosed))
            except Exception, err :
                 self.log.exception("did not get the count")
开发者ID:jetgeng,项目名称:TracParentTicketCloser,代码行数:31,代码来源:TicketCloser.py

示例2: wake_up

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import save_changes [as 别名]
 def wake_up(self, *args):
     db = self.env.get_db_cnx()        
     cursor = db.cursor()
     # find still opened more recent milestone
     # select ticket whom milestone are due in less than specified delay
     cursor.execute("""
             SELECT m.name  FROM milestone m                        
             WHERE  m.completed is NULL or m.completed = 0
             AND m.due not NULL and m.due > 0
             ORDER BY m.due ASC LIMIT 1            
         """ )
     next_milestone = None
     for name, in cursor:
         next_milestone = name            
             
     # select ticket whom milestone are due in less than specified delay
     cursor.execute("""
             SELECT t.id , t.milestone  FROM ticket t, milestone m                        
             WHERE t.status != 'closed'
             AND    t.milestone = m.name  
             AND    m.completed not NULL and m.completed > 0            
         """ )        
     if next_milestone:          
         for id, milestone in cursor:
             mess = "ticket %s is opened in closed milestone %s. Should postpone this ticket to %s" % (id, milestone, next_milestone)
             self.env.log.debug(mess)
             ticket = Ticket(self.env, id)
             ticket.populate({'milestone':next_milestone})
             ticket.save_changes(self.getId(),mess)
     else:
         self.env.log.debug("No opened milestone found. Cannot postpone tickets")
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:33,代码来源:task.py

示例3: test_reset_milestone

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import save_changes [as 别名]
    def test_reset_milestone(self):
        self.env.config.set('ticket', 'workflow',
            'ConfigurableTicketWorkflow,TicketWorkflowOpResetMilestone')
        self._config_set('ticket-workflow', [
            ('reset-milestone', '* -> *'),
            ('reset-milestone.operations', 'reset_milestone'),
        ])
        tktid = self._insert_ticket(when=datetime(2017, 3, 9, tzinfo=utc),
                                    summary='reset milestone',
                                    milestone='milestone1',
                                    reporter='anonymous', owner='joe')

        ticket = Ticket(self.env, tktid)
        req = self._post_req('reset-milestone', ticket)
        self.assertTrue(self.tktmod.match_request(req))
        self.assertRaises(RequestDone, self.tktmod.process_request, req)
        ticket = Ticket(self.env, tktid)
        self.assertEqual('milestone1', ticket['milestone'])

        milestone = Milestone(self.env, ticket['milestone'])
        milestone.completed = datetime(2017, 3, 8, tzinfo=utc)
        milestone.update()
        req = self._post_req('reset-milestone', ticket)
        self.assertTrue(self.tktmod.match_request(req))
        self.assertRaises(RequestDone, self.tktmod.process_request, req)
        ticket = Ticket(self.env, tktid)
        self.assertEqual('', ticket['milestone'])

        ticket['milestone'] = 'unknown-milestone'
        ticket.save_changes(when=datetime(2017, 3, 8, 1, tzinfo=utc))
        req = self._post_req('reset-milestone', ticket)
        self.assertTrue(self.tktmod.match_request(req))
        self.assertRaises(RequestDone, self.tktmod.process_request, req)
        ticket = Ticket(self.env, tktid)
        self.assertEqual('unknown-milestone', ticket['milestone'])
开发者ID:aroth-arsoft,项目名称:trac-advancedworkflow,代码行数:37,代码来源:controller.py

示例4: test_no_disown_from_changed_component

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import save_changes [as 别名]
    def test_no_disown_from_changed_component(self):
        """
        Verify that a ticket is not disowned when the component is changed to
        a non-assigned component.
        """
        component1 = Component(self.env)
        component1.name = "test1"
        component1.owner = "joe"
        component1.insert()

        component2 = Component(self.env)
        component2.name = "test2"
        component2.owner = ""
        component2.insert()

        ticket = Ticket(self.env)
        ticket["reporter"] = "santa"
        ticket["summary"] = "Foo"
        ticket["component"] = "test1"
        ticket["status"] = "new"
        tktid = ticket.insert()

        ticket = Ticket(self.env, tktid)
        ticket["component"] = "test2"
        ticket.save_changes("jane", "Testing")
        self.assertEqual("joe", ticket["owner"])
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:28,代码来源:model.py

示例5: test_owner_from_changed_component

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import save_changes [as 别名]
    def test_owner_from_changed_component(self):
        """
        Verify that the owner of a new ticket is updated when the component is
        changed.
        """
        component1 = Component(self.env)
        component1.name = "test1"
        component1.owner = "joe"
        component1.insert()

        component2 = Component(self.env)
        component2.name = "test2"
        component2.owner = "kate"
        component2.insert()

        ticket = Ticket(self.env)
        ticket["reporter"] = "santa"
        ticket["summary"] = "Foo"
        ticket["component"] = "test1"
        ticket["status"] = "new"
        tktid = ticket.insert()

        ticket = Ticket(self.env, tktid)
        ticket["component"] = "test2"
        ticket.save_changes("jane", "Testing")
        self.assertEqual("kate", ticket["owner"])
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:28,代码来源:model.py

示例6: test_changelog_with_attachment

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import save_changes [as 别名]
 def test_changelog_with_attachment(self):
     """Verify ordering of attachments and comments in the changelog."""
     tkt_id = self._insert_ticket("Test", reporter="joe", component="foo")
     ticket = Ticket(self.env, tkt_id)
     t1 = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
     ticket.save_changes("jane", "Testing", t1)
     t2 = datetime(2001, 1, 1, 1, 1, 2, 0, utc)
     db = self.env.get_db_cnx()
     cursor = db.cursor()
     cursor.execute(
         "INSERT INTO attachment (type,id,filename,size,time,"
         "                        description,author,ipnr) "
         "VALUES ('ticket',%s,'file.txt',1234,%s,"
         "        'My file','mark','')",
         (str(tkt_id), to_utimestamp(t2)),
     )
     db.commit()
     t3 = datetime(2001, 1, 1, 1, 1, 3, 0, utc)
     ticket.save_changes("jim", "Other", t3)
     log = ticket.get_changelog()
     self.assertEqual(4, len(log))
     self.assertEqual((t1, "jane", "comment", "1", "Testing", True), log[0])
     self.assertEqual(
         [(t2, "mark", "attachment", "", "file.txt", False), (t2, "mark", "comment", "", "My file", False)],
         sorted(log[1:3]),
     )
     self.assertEqual((t3, "jim", "comment", "2", "Other", True), log[3])
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:29,代码来源:model.py

示例7: apply_preset

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import save_changes [as 别名]
    def apply_preset(self, req, tickets, preset=None):
        if preset is None:
            return tickets
            
        presets = preset and [kw.split('=', 1) for kw in preset.split('&')] or []
        fields = dict([(field, value) for field, value in presets])

        warn = []
        modified_tickets = []
        if tickets and presets:
            db = self.env.get_db_cnx()
            ticket_module = TicketModule(self.env)
            action = fields.get('action')

            for ticket_id in tickets:
                if 'TICKET_CHGPROP' in req.perm('ticket', ticket_id):
                    ticket  = Ticket(self.env, ticket_id, db)
                    ticket.populate(fields)
                    if action:
                        field_changes, problems = ticket_module.get_ticket_changes(req, ticket, action)
                        if problems:
                            for problem in problems:
                                warn.append(problem)
                        ticket_module._apply_ticket_changes(ticket, field_changes) # Apply changes made by the workflow

                    ticket.save_changes(req.authname, None, db=db)
                    modified_tickets.append(ticket_id)
                else:
                    warn.append(_("You have no permission to modify ticket '%(ticket)s'", ticket=ticket_id))
            db.commit()
        return { 'tickets' : modified_tickets, 'warnings': warn}
开发者ID:esogs,项目名称:IttecoTracPlugin,代码行数:33,代码来源:rpc.py

示例8: set_resource_tags

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import save_changes [as 别名]
 def set_resource_tags(self, req, ticket_or_resource, tags, comment=u'',
                       when=None):
     try:
         resource = ticket_or_resource.resource
     except AttributeError:
         resource = ticket_or_resource
         assert resource.realm == self.realm
         if not self._check_permission(req, resource, 'modify'):
             raise PermissionError(resource=resource, env=self.env)
         tag_set = set(tags)
         # Processing a call from TracTags, try to alter the ticket.
         tkt = Ticket(self.env, resource.id)
         all = self._ticket_tags(tkt)
         # Avoid unnecessary ticket changes, considering comments below.
         if tag_set != all:
             # Will only alter tags in 'keywords' ticket field.
             keywords = split_into_tags(tkt['keywords'])
             # Assume, that duplication is depreciated and consolitation
             # wanted to primarily affect 'keywords' ticket field.
             # Consequently updating ticket tags and reducing (tag)
             # 'ticket_fields' afterwards may result in undesired tag loss.
             tag_set.difference_update(all.difference(keywords))
             tkt['keywords'] = u' '.join(sorted(map(to_unicode, tag_set)))
             tkt.save_changes(get_reporter_id(req), comment)
     else:
         # Processing a change listener event.
         tags = self._ticket_tags(ticket_or_resource)
         super(TicketTagProvider,
               self).set_resource_tags(req, resource, tags)
开发者ID:kzhamaji,项目名称:TracTagsPlugin,代码行数:31,代码来源:ticket.py

示例9: test_set_tags

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import save_changes [as 别名]
 def test_set_tags(self):
     tags = ['tag3']
     ticket = Ticket(self.env, 1)
     ticket['keywords'] = tags[0]
     # Tags get updated by TicketChangeListener method.
     ticket.save_changes(self.req.authname)
     self.assertEquals(self.tag_sys.get_all_tags(self.req).keys(), tags)
开发者ID:kzhamaji,项目名称:TracTagsPlugin,代码行数:9,代码来源:ticket.py

示例10: process_commit

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import save_changes [as 别名]
 def process_commit(self, commit):
     """
     Update ticket using message from commit
     """
     try:
         original = commit.get_original_commit()
     except:
         original = None
     
     if not commit.is_clone() or \
         original is None  or \
         commit.message != original.message:
         
         for action, ticket_id in commit.parse_message():
             try:
                 ticket = Ticket(self.env, ticket_id)
                 self._update_ticket(ticket, action, commit)                   
                 msg = "Commit %s:\n\n%s\n\nSource: [%s]" % (commit.id, commit.message, commit.url,)
                 ticket.save_changes(
                     commit.author,
                     msg,
                     when=datetime.fromtimestamp(commit.time, utc))
             except Exception, e:
                 self.log.error('Could not update ticket %s with commit %s: %s' % (
                     ticket_id,commit.id,str(e),))
开发者ID:dinoboff,项目名称:trachub,代码行数:27,代码来源:ticket.py

示例11: _save_changes

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import save_changes [as 别名]
 def _save_changes(self, changes, author):
     """Save ticket changes."""
     if self.audit in ('log','none'):
         db = self.env.get_db_cnx()
         cursor = db.cursor()
         for id,(field,new_pos) in changes.items():
             cursor.execute("""
                 SELECT value from ticket_custom
                  WHERE name=%s AND ticket=%s
                 """, (field,id))
             result = cursor.fetchone()
             if result:
                 old_pos = result[0]
                 cursor.execute("""
                     UPDATE ticket_custom SET value=%s
                      WHERE name=%s AND ticket=%s
                     """, (new_pos,field,id))
             else:
                 old_pos = '(none)'
                 cursor.execute("""
                     INSERT INTO ticket_custom (ticket,name,value)
                      VALUES (%s,%s,%s)
                     """, (id,field,new_pos))
             if self.audit == 'log':
                 self.log.info("%s reordered ticket #%s's %s from %s to %s" \
                     % (author,id,field,old_pos,new_pos))
         db.commit()
     else:
         for id,(field,new_pos) in changes.items():
             ticket = Ticket(self.env, id)
             ticket[field] = new_pos
             ticket.save_changes(author=author, comment='')
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:34,代码来源:web_ui.py

示例12: test_no_disown_from_changed_component

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import save_changes [as 别名]
    def test_no_disown_from_changed_component(self):
        """
        Verify that a ticket is not disowned when the component is changed to
        a non-assigned component.
        """
        component1 = Component(self.env)
        component1.name = 'test1'
        component1.owner = 'joe'
        component1.insert()

        component2 = Component(self.env)
        component2.name = 'test2'
        component2.owner = ''
        component2.insert()

        ticket = Ticket(self.env)
        ticket['reporter'] = 'santa'
        ticket['summary'] = 'Foo'
        ticket['component'] = 'test1'
        ticket['status'] = 'new'
        tktid = ticket.insert()

        ticket = Ticket(self.env, tktid)
        ticket['component'] = 'test2'
        ticket.save_changes('jane', 'Testing')
        self.assertEqual('joe', ticket['owner'])
开发者ID:zjj,项目名称:trac_hack,代码行数:28,代码来源:model.py

示例13: _change_ticket_states

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import save_changes [as 别名]
 def _change_ticket_states(self, id, history):
     ticket = Ticket(self.env, id)
     keys = history.keys()
     keys.sort()
     for key in keys:
         ticket['status'] = history[key]
         ticket.save_changes("me", "testing", datetime.combine(key, datetime.now(utc).timetz()))       
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:9,代码来源:burndownchart.py

示例14: _change_ticket

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import save_changes [as 别名]
 def _change_ticket(self, id, history):
     ticket = Ticket(self.env, id)
     keys = history.keys()
     keys.sort()
     for key in keys:
         ticket['hours_remaining'] = history[key]
         ticket.save_changes("me", "testing", time.mktime(key.timetuple()))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:9,代码来源:burndownchart.py

示例15: test_closed_does_not_dup_to_None

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import save_changes [as 别名]
    def test_closed_does_not_dup_to_None(self):
        # tests that dup_of can go from non-existing to None
        # (when a pre-existing ticket gets changed, and custom fields added)
        t1 = self._create_a_ticket()

        self.failIf(t1.values.has_key('dup_of'))

        # apparently setting status to new didn't get saved; assert it
        t1 = Ticket(self.env, 1)
    
        self.assertEquals(t1['status'], 'new')
        self.failIf(t1.values.has_key('dup_of'))

        # close the ticket
        t1['status'] = 'closed'
        t1['resolution'] = 'fixed'
        t1.save_changes('test', 'test', when=1)
        
        t1 = Ticket(self.env, 1)
        self.assertEquals(t1['status'], 'closed')
        self.failIf(t1.values.has_key('dup_of'))

        # t1 does not have dup_of set at all, set it to ''
        # as if the summary was changed through the web ui and try to save
        t1['dup_of'] = ''
        t1['summary'] = 'changed summary'
        t1.save_changes('test', 'test', when=2)

        t1 = Ticket(self.env, 1)
        self.failUnless(t1.values.has_key('dup_of'))

        # make sure the status did not get changed at all
        self.assertEquals(t1['status'], 'closed')
        self.assertEquals(t1['resolution'], 'fixed')
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:36,代码来源:ticket.py


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