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


Python Ticket.populate方法代码示例

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


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

示例1: add_tickets

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import populate [as 别名]
    def add_tickets(self, project, customerrequest, tickets, reporter, notify=False):
        from trac.ticket.notification import TicketNotifyEmail
        from trac.util.text import exception_to_unicode
        from penelope.core.models.dashboard import User

        settings = get_current_registry().settings
        tracenvs = settings.get('penelope.trac.envs')
        request = get_current_request()

        for trac in project.tracs:
            for t in tickets:
                owner = DBSession.query(User).get(t['owner'])
                ticket = {'summary': t['summary'],
                        'description': t['description'],
                        'customerrequest': customerrequest.id,
                        'reporter': reporter.email,
                        'type': 'task',
                        'priority': 'major',
                        'milestone': 'Backlog',
                        'owner': owner.email,
                        'status': 'new'}
                tracenv = Environment('%s/%s' % (tracenvs, trac.trac_name))
                tracenv.abs_href.base = trac.api_uri
                t = Ticket(tracenv)
                t.populate(ticket)
                t.insert()
                if notify:
                    try:
                        tn = TicketNotifyEmail(tracenv)
                        tn.notify(t, newticket=True)
                    except Exception, e:
                        request.add_message('Failure sending notification on creation '
                        'of a ticket #%s: %s' % (t.id, exception_to_unicode(e)), 'error')
开发者ID:getpenelope,项目名称:penelope.core,代码行数:35,代码来源:tickets.py

示例2: test_populate_ticket

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import populate [as 别名]
    def test_populate_ticket(self):
        data = {
            "summary": "Hello world",
            "reporter": "john",
            "foo": "bar",
            "checkbox_cbon": "",
            "cbon": "on",
            "checkbox_cboff": "",
        }
        ticket = Ticket(self.env)
        ticket.populate(data)

        # Standard fields
        self.assertEqual("Hello world", ticket["summary"])
        self.assertEqual("john", ticket["reporter"])

        # An unknown field
        assert ticket["bar"] is None

        # Custom field
        self.assertEqual("bar", ticket["foo"])

        # Custom field of type 'checkbox'
        self.assertEqual("on", ticket["cbon"])
        self.assertEqual("0", ticket["cboff"])
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:27,代码来源:model.py

示例3: wake_up

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import populate [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

示例4: apply_preset

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import populate [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

示例5: test_component_change

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import populate [as 别名]
    def test_component_change(self):
        """New ticket owner is updated when the component is changed.
        """
        self._add_component('component3', 'cowner3')
        self._add_component('component4', 'cowner4')

        ticket = Ticket(self.env)
        ticket.populate({
            'reporter': 'reporter1',
            'summary': 'the summary',
            'component': 'component3',
            'owner': 'cowner3',
            'status': 'new',
        })
        tkt_id = ticket.insert()

        req = self._create_request(method='POST', args={
            'id': tkt_id,
            'field_component': 'component4',
            'submit': True,
            'action': 'leave',
            'view_time': str(to_utimestamp(ticket['changetime'])),
        })
        self.assertRaises(RequestDone, self.ticket_module.process_request, req)
        ticket = Ticket(self.env, tkt_id)

        self.assertEqual('component4', ticket['component'])
        self.assertEqual('cowner4', ticket['owner'])
开发者ID:pkdevbox,项目名称:trac,代码行数:30,代码来源:default_workflow.py

示例6: test_prop_whitespace_change_is_not_saved

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import populate [as 别名]
    def test_prop_whitespace_change_is_not_saved(self):
        ticket = Ticket(self.env)
        ticket.populate({'summary': 'ticket summary'})
        ticket.insert()

        ticket['summary'] = ' ticket summary '
        ticket.save_changes()
        self.assertEqual(0, len(ticket.get_changelog()))
开发者ID:thimalk,项目名称:bloodhound,代码行数:10,代码来源:model.py

示例7: _create_ticket_with_change

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import populate [as 别名]
 def _create_ticket_with_change(self, old_props, new_props):
     """Create a ticket with `old_props` and apply properties
     in `new_props`.
     """
     t = Ticket(self.env)
     t.populate(old_props)
     t.insert()
     t.populate(new_props)
     t.save_changes('actor')
     return t
开发者ID:pkdevbox,项目名称:trac,代码行数:12,代码来源:web_ui.py

示例8: ticket_setup

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import populate [as 别名]
def ticket_setup(tc):
    config = tc.env.config
    config.set('ticket-custom', 'custom1', 'text')
    config.save()
    ticket = Ticket(tc.env)

    ticket.populate({'reporter': 'santa',
                     'summary': 'This is the summary',
                     'status': 'new'})
    ticket.insert()
开发者ID:pkdevbox,项目名称:trac,代码行数:12,代码来源:wikisyntax.py

示例9: update_ticket_on_db

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import populate [as 别名]
    def update_ticket_on_db(self, ticketId, author, comment, req):
        db = self.env.get_db_cnx()
        ticket = Ticket(self.env, ticketId, db=db)

        ticket.populate(req.args)

        now = int(time.time())
        ticket.save_changes(author, comment, when=now, db=db)
        db.commit()

        return True
开发者ID:lkraav,项目名称:trachacks,代码行数:13,代码来源:autotrac.py

示例10: query2_setup

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import populate [as 别名]
def query2_setup(tc):
    ticket = Ticket(tc.env)
    ticket.populate({'reporter': 'santa',
                     'summary': 'This is the summary',
                     'status': 'new'})
    ticket.insert()
    ticket = Ticket(tc.env)
    ticket.populate({'reporter': 'claus',
                     'summary': 'This is another summary',
                     'status': 'new'})
    ticket.insert()
开发者ID:pkdevbox,项目名称:trac,代码行数:13,代码来源:wikisyntax.py

示例11: _create_ticket_with_change

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import populate [as 别名]
 def _create_ticket_with_change(self, old_props, new_props,
                                author='anonymous'):
     """Create a ticket with `old_props` and apply properties
     in `new_props`.
     """
     t = Ticket(self.env)
     t.populate(old_props)
     t.insert()
     comment = new_props.pop('comment', None)
     t.populate(new_props)
     t.save_changes(author, comment=comment)
     return t
开发者ID:aroth-arsoft,项目名称:trac-crashdump,代码行数:14,代码来源:web_ui.py

示例12: add_ticket

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import populate [as 别名]
	def add_ticket(self, request, cleaned_data):
		"""Initializes a trac ticket, saves it to the database, and returns
		the result."""
		# Trac's version: trac.ticket.web_ui:375 (_process_newticket_request)
		data = {
			'summary': cleaned_data['summary'],
			'description': cleaned_data['description'],
			'reporter': self._get_trac_user(request.user),
		}
		ticket = Ticket(self.env)
		ticket.populate(data)
		ticket_id = ticket.insert()
		return ticket_id
开发者ID:melinath,项目名称:django-ticketeer,代码行数:15,代码来源:backend.py

示例13: comment_setup

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import populate [as 别名]
def comment_setup(tc):
    ticket1 = Ticket(tc.env)
    ticket1.populate({'reporter': 'santa',
                      'summary': 'This is the summary for ticket 1',
                      'status': 'new'})
    ticket1.insert()
    ticket1.save_changes(comment='This is the comment for ticket 1')
    ticket2 = Ticket(tc.env)
    ticket2.populate({'reporter': 'claws',
                      'summary': 'This is the summary for ticket 2',
                      'status': 'closed'})
    ticket2.insert()
    ticket2.save_changes(comment='This is the comment for ticket 2')
开发者ID:pkdevbox,项目名称:trac,代码行数:15,代码来源:wikisyntax.py

示例14: fix_issue

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import populate [as 别名]
 def fix_issue(self, db, data, author):
     """This base fix updates a ticket with the field/value pairs in
     data.  The data object can either be a dict or a list of dicts
     with the 'ticket' field of each identifying the ticket to change."""
     if not isinstance(data,list):
         data = [data]
     
     # update each ticket
     for changes in data:
         ticket = Ticket(self.env, changes['ticket'])
         del changes['ticket']
         ticket.populate(changes)
         ticket.save_changes(author=author, comment='')
     return None
开发者ID:lkraav,项目名称:trachacks,代码行数:16,代码来源:analysis.py

示例15: test_delete_milestone_retarget_tickets

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import populate [as 别名]
    def test_delete_milestone_retarget_tickets(self):
        self.env.db_transaction("INSERT INTO milestone (name) VALUES ('Test')")

        tkt1 = Ticket(self.env)
        tkt1.populate({'summary': 'Foo', 'milestone': 'Test'})
        tkt1.insert()
        tkt2 = Ticket(self.env)
        tkt2.populate({'summary': 'Bar', 'milestone': 'Test'})
        tkt2.insert()

        milestone = Milestone(self.env, 'Test')
        milestone.delete(retarget_to='Other')
        self.assertEqual(False, milestone.exists)

        self.assertEqual('Other', Ticket(self.env, tkt1.id)['milestone'])
        self.assertEqual('Other', Ticket(self.env, tkt2.id)['milestone'])
开发者ID:thimalk,项目名称:bloodhound,代码行数:18,代码来源:model.py


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