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


Python model.Milestone类代码示例

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


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

示例1: copy_milestone

def copy_milestone(source_env, dest_env, name, dest_db=None):
    # In case a string gets passed in
    if not isinstance(source_env, Environment):
        source_env = _open_environment(source_env)
    if not isinstance(dest_env, Environment):
        dest_env = _open_environment(dest_env)
        
    # Log message
    source_env.log.info('DatamoverPlugin: Moving milestone %s to the environment at %s', name, dest_env.path)
    dest_env.log.info('DatamoverPlugin: Moving milestone %s from the environment at %s', name, source_env.path)
    
    # Open databases
    source_db = source_env.get_db_cnx()
    source_cursor = source_db.cursor()
    handle_commit = True
    if not dest_db:
        dest_db, handle_commit = dest_env.get_db_cnx(), False
    dest_cursor = dest_db.cursor()
    
    # Remove the milestone from the destination
    try:
        dest_milestone = Milestone(dest_env, name, db=dest_db)
        dest_milestone.delete(retarget_to=name, db=dest_db)
    except TracError:
        pass

    # Copy each entry in the milestone table
    source_cursor.execute('SELECT * FROM milestone WHERE name=%s',(name,))
    for row in source_cursor:
        milestone_data = dict(zip([d[0] for d in source_cursor.description], row))
        q = make_query(milestone_data, 'milestone')
        dest_cursor.execute(*q)
       
    if handle_commit:
        dest_db.commit()
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:35,代码来源:util.py

示例2: process_request

    def process_request(self, req):
        milestone_id = req.args.get('id')
        req.perm('milestone', milestone_id).require('MILESTONE_VIEW')

        add_link(req, 'up', req.href.roadmap(), _('Roadmap'))

        action = req.args.get('action', 'view')
        try:
            milestone = Milestone(self.env, milestone_id)
        except ResourceNotFound:
            if 'MILESTONE_CREATE' not in req.perm('milestone', milestone_id):
                raise
            milestone = Milestone(self.env, None)
            milestone.name = milestone_id
            action = 'edit' # rather than 'new' so that it works for POST/save

        if req.method == 'POST':
            if 'cancel' in req.args:
                if milestone.exists:
                    req.redirect(req.href.milestone(milestone.name))
                else:
                    req.redirect(req.href.roadmap())
            elif action == 'edit':
                return self._do_save(req, milestone)
            elif action == 'delete':
                self._do_delete(req, milestone)
        elif action in ('new', 'edit'):
            return self._render_editor(req, milestone)
        elif action == 'delete':
            return self._render_confirm(req, milestone)

        if not milestone.name:
            req.redirect(req.href.roadmap())

        return self._render_view(req, milestone)
开发者ID:exocad,项目名称:exotrac,代码行数:35,代码来源:roadmap.py

示例3: test_reset_milestone

    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,代码行数:35,代码来源:controller.py

示例4: test_delete_milestone

    def test_delete_milestone(self):
        self.env.db_transaction("INSERT INTO milestone (name) VALUES ('Test')")

        milestone = Milestone(self.env, 'Test')
        milestone.delete()
        self.assertEqual(False, milestone.exists)
        self.assertEqual([],
            self.env.db_query("SELECT * FROM milestone WHERE name='Test'"))
开发者ID:thimalk,项目名称:bloodhound,代码行数:8,代码来源:model.py

示例5: test_update_milestone_without_name

    def test_update_milestone_without_name(self):
        cursor = self.db.cursor()
        cursor.execute("INSERT INTO milestone (name) VALUES ('Test')")
        cursor.close()

        milestone = Milestone(self.env, 'Test')
        milestone.name = None
        self.assertRaises(TracError, milestone.update)
开发者ID:zjj,项目名称:trac_hack,代码行数:8,代码来源:model.py

示例6: test_create_milestone

    def test_create_milestone(self):
        milestone = Milestone(self.env)
        milestone.name = 'Test'
        milestone.insert()

        cursor = self.db.cursor()
        cursor.execute("SELECT name,due,completed,description FROM milestone "
                       "WHERE name='Test'")
        self.assertEqual(('Test', 0, 0, ''), cursor.fetchone())
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:9,代码来源:model.py

示例7: test_delete_milestone

    def test_delete_milestone(self):
        cursor = self.db.cursor()
        cursor.execute("INSERT INTO milestone (name) VALUES ('Test')")
        cursor.close()

        milestone = Milestone(self.env, 'Test')
        milestone.delete()

        cursor = self.db.cursor()
        cursor.execute("SELECT * FROM milestone WHERE name='Test'")
        self.assertEqual(None, cursor.fetchone())
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:11,代码来源:model.py

示例8: milestone_setup

def milestone_setup(tc):
    from datetime import datetime
    from trac.util.datefmt import utc
    boo = Milestone(tc.env)
    boo.name = 'boo'
    boo.completed = boo.due = None
    boo.insert()
    roo = Milestone(tc.env)
    roo.name = 'roo'
    roo.completed = datetime.now(utc)
    roo.due = None
    roo.insert()
开发者ID:dafrito,项目名称:trac-mirror,代码行数:12,代码来源:wikisyntax.py

示例9: ticket_changed

 def ticket_changed(self, ticket, comment, author, old_values):
     old_summary = old_values.get('summary')
     if ticket['type']==milestone_ticket_type \
         and old_summary \
         and ticket['summary'] != old_summary:
             try:
                 milestone = Milestone(self.env, old_summary)
                 if milestone.exists:
                     milestone.name = ticket['summary']
                     milestone.update()
             except ResourceNotFound:
                 pass
开发者ID:esogs,项目名称:IttecoTracPlugin,代码行数:12,代码来源:roadmap.py

示例10: select

 def select(env, include_completed=True, db=None):
     if not db:
         db = env.get_db_cnx()
         
     milestones = [ StructuredMilestone(env, milestone) \
                     for milestone in Milestone.select(env, include_completed, db)]
     return StructuredMilestone.reorganize(milestones)
开发者ID:esogs,项目名称:IttecoTracPlugin,代码行数:7,代码来源:model.py

示例11: _go_graph

 def _go_graph(self, req):
     #search all artifacts.
     artifacts = ArtifactManager.find_all(self.env)
     
     milestones = [m for m in Milestone.select(self.env)
                   if 'MILESTONE_VIEW' in req.perm(m.resource)]
     
     #add artifacts to milestone.
     for m in milestones:
         artifacts_of_m = [artifact for artifact in artifacts
                if artifact.milestone == m.name]
         setattr(m, 'artifacts', artifacts_of_m)
     
     manager = SCMManager(self.env, req)
     nodes = manager.artifacts_to_nodes(artifacts)
     
     roots = manager.get_roots(nodes)
     
     gm = GraphManager(self.env)
     nodes = gm.to_graphnode(roots)
     
     gm.to_s(nodes)
     
     graph = gm.to_graphviz(nodes, milestones)
     
     self.env.log.info('graphviz graph:\n%s' % graph)
     
     data = {'milestones':milestones, 'artifacts':artifacts, 'graph':graph}
     return 'releaseartifactgraph.html', data, None
开发者ID:wadahiro,项目名称:trac-release-artifacts-plugin,代码行数:29,代码来源:web_ui.py

示例12: _render_editor

    def _render_editor(self, req, milestone):
        # Suggest a default due time of 18:00 in the user's timezone
        now = datetime.now(req.tz)
        default_due = datetime(now.year, now.month, now.day, 18)
        if now.hour > 18:
            default_due += timedelta(days=1)
        default_due = to_datetime(default_due, req.tz)

        data = {
            'milestone': milestone,
            'datetime_hint': get_datetime_format_hint(req.lc_time),
            'default_due': default_due,
            'milestone_groups': [],
        }

        if milestone.exists:
            req.perm(milestone.resource).require('MILESTONE_MODIFY')
            milestones = [m for m in Milestone.select(self.env)
                          if m.name != milestone.name
                          and 'MILESTONE_VIEW' in req.perm(m.resource)]
            data['milestone_groups'] = group_milestones(milestones,
                'TICKET_ADMIN' in req.perm)
        else:
            req.perm(milestone.resource).require('MILESTONE_CREATE')
            if milestone.name:
                add_notice(req, _("Milestone %(name)s does not exist. You can"
                                  " create it here.", name=milestone.name))

        chrome = Chrome(self.env)
        chrome.add_jquery_ui(req)
        chrome.add_wiki_toolbars(req)
        return 'milestone_edit.html', data, None
开发者ID:exocad,项目名称:exotrac,代码行数:32,代码来源:roadmap.py

示例13: test_update_milestone_update_tickets

    def test_update_milestone_update_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.name = 'Testing'
        milestone.update()

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

示例14: test_delete_milestone_retarget_tickets

    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,代码行数:16,代码来源:model.py

示例15: _render_editor

    def _render_editor(self, req, milestone):
        data = {
            'milestone': milestone,
            'datetime_hint': get_datetime_format_hint(req.lc_time),
            'default_due': self.get_default_due(req),
            'milestone_groups': [],
        }

        if milestone.exists:
            req.perm(milestone.resource).require('MILESTONE_MODIFY')
            milestones = [m for m in Milestone.select(self.env)
                          if m.name != milestone.name
                          and 'MILESTONE_VIEW' in req.perm(m.resource)]
            data['milestone_groups'] = group_milestones(milestones,
                'TICKET_ADMIN' in req.perm)
            data['num_open_tickets'] = milestone \
                                       .get_num_tickets(exclude_closed=True)
            data['retarget_to'] = self.default_retarget_to
        else:
            req.perm(milestone.resource).require('MILESTONE_CREATE')
            if milestone.name:
                add_notice(req, _("Milestone %(name)s does not exist. You can"
                                  " create it here.", name=milestone.name))

        chrome = Chrome(self.env)
        chrome.add_jquery_ui(req)
        chrome.add_wiki_toolbars(req)
        add_stylesheet(req, 'common/css/roadmap.css')
        return 'milestone_edit.html', data, None
开发者ID:spsoft-RockWang,项目名称:project-_trac,代码行数:29,代码来源:roadmap.py


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