本文整理汇总了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()
示例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)
示例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'])
示例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'"))
示例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)
示例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())
示例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())
示例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()
示例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
示例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)
示例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
示例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
示例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'])
示例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'])
示例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