本文整理汇总了Python中trac.ticket.Milestone.select方法的典型用法代码示例。如果您正苦于以下问题:Python Milestone.select方法的具体用法?Python Milestone.select怎么用?Python Milestone.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.ticket.Milestone
的用法示例。
在下文中一共展示了Milestone.select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_options
# 需要导入模块: from trac.ticket import Milestone [as 别名]
# 或者: from trac.ticket.Milestone import select [as 别名]
def _get_options(self, field_name):
"""Return a list of options for the given [dynvars] field:
[dynvars]
myfield.options = value1|value2|value3
If no [dynvars] field is found, a select field is searched
and its options returned. For the milestone field, completed
milestones are omitted. If no select field is found, then an
empty list is returned."""
# look for [dynvars] field
for key,val in self.env.config.options('dynvars'):
if key == field_name+'.options':
return val.split('|')
# handle milestone special - skip completed milestones
if field_name == 'milestone':
return [''] + [m.name for m in
Milestone.select(self.env, include_completed=False)]
# lookup select field
for field in TicketSystem(self.env).get_ticket_fields():
if field['name'] == field_name and 'options' in field:
return field['options']
return []
示例2: _render_editor
# 需要导入模块: from trac.ticket import Milestone [as 别名]
# 或者: from trac.ticket.Milestone import select [as 别名]
def _render_editor(self, req, db, milestone):
# Suggest a default due time of 18:00 in the user's timezone
default_due = datetime.now(req.tz).replace(hour=18, minute=0, second=0,
microsecond=0)
if default_due <= datetime.now(utc):
default_due += timedelta(days=1)
data = {
'milestone': milestone,
'datetime_hint': get_datetime_format_hint(),
'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, db=db)
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')
Chrome(self.env).add_wiki_toolbars(req)
return 'milestone_edit.html', data, None
示例3: _render_milestone_list
# 需要导入模块: from trac.ticket import Milestone [as 别名]
# 或者: from trac.ticket.Milestone import select [as 别名]
def _render_milestone_list(self, req):
project_id = req.data['project_id']
milestones = Milestone.select(self.env, project_id, include_completed=True)
data = {
'milestones': milestones,
}
return 'mdashboard.html', data, None
示例4: _find_milestones
# 需要导入模块: from trac.ticket import Milestone [as 别名]
# 或者: from trac.ticket.Milestone import select [as 别名]
def _find_milestones(self):
"""Return a string list of Milestone names
A smarter approach would return a dictionary of milestones:
key = name
value = tuple (name, due, completed, description)
"""
return [ "%s" % m.name for m in Milestone.select(self.env) ]
示例5: process
# 需要导入模块: from trac.ticket import Milestone [as 别名]
# 或者: from trac.ticket.Milestone import select [as 别名]
def process(self, commit, status, branch):
self.closestatus = status
milestones = [m.name for m in Milestone.select(self.env) if m.name != "unknown"]
if branch.startswith("fixes/"):
branch = branch[6:]
milestones = [m for m in milestones if m.startswith(branch)]
self.milestone = sorted(milestones)[-1]
msg = commit["message"]
self.env.log.debug("Processing Commit: %s", msg)
msg = "%s \n Branch: %s \n Changeset: %s" % (msg, branch, commit["id"])
# author = commit['author']['name']
author = "Github"
timestamp = datetime.now(utc)
cmd_groups = command_re.findall(msg)
self.env.log.debug("Function Handlers: %s" % cmd_groups)
tickets = {}
for cmd, tkts in cmd_groups:
funcname = self.__class__._supported_cmds.get(cmd.lower(), "")
self.env.log.debug("Function Handler: %s" % funcname)
if funcname:
for tkt_id in ticket_re.findall(tkts):
if (branch == "master") or branch.startswith("fixes/"):
tickets.setdefault(tkt_id, []).append(getattr(self, funcname))
# disable this stuff for now, it causes duplicates on merges
# proper implementation of this will require tracking commit hashes
# else:
# tickets.setdefault(tkt_id, []).append(self._cmdRefs)
for tkt_id, cmds in tickets.iteritems():
try:
db = self.env.get_db_cnx()
ticket = Ticket(self.env, int(tkt_id), db)
for cmd in cmds:
cmd(ticket)
# determine sequence number...
cnum = 0
tm = TicketModule(self.env)
for change in tm.grouped_changelog_entries(ticket, db):
if change["permanent"]:
cnum += 1
ticket.save_changes(author, msg, timestamp, db, cnum + 1)
db.commit()
tn = TicketNotifyEmail(self.env)
tn.notify(ticket, newticket=0, modtime=timestamp)
except Exception, e:
import traceback
traceback.print_exc(file=sys.stderr)
示例6: _get_milestone
# 需要导入模块: from trac.ticket import Milestone [as 别名]
# 或者: from trac.ticket.Milestone import select [as 别名]
def _get_milestone(self, req):
"""Extract the milestone from the referer url. If not found then
return the current milestone."""
path = req.environ.get('HTTP_REFERER','')
milestone_re = re.compile(r"/milestone/(?P<milestone>[^?]+)")
match = milestone_re.search(path)
if match:
name = urllib.unquote(match.groupdict()['milestone'])
for m in Milestone.select(self.env, include_completed=True):
if m.name == name:
return m
else:
raise Exception("Milestone %s not found" % name)
else:
# milestone not found in url, so assume current milestone
for m in Milestone.select(self.env, include_completed=False):
return m
else:
raise Exception("No provided or current milestone")
return None
示例7: _render_confirm
# 需要导入模块: from trac.ticket import Milestone [as 别名]
# 或者: from trac.ticket.Milestone import select [as 别名]
def _render_confirm(self, req, db, milestone):
req.perm.assert_permission('MILESTONE_DELETE')
req.hdf['title'] = 'Jalon %s' % milestone.name
req.hdf['milestone'] = milestone_to_hdf(self.env, db, req, milestone)
req.hdf['milestone.mode'] = 'delete'
for idx,other in enumerate(Milestone.select(self.env, False, db)):
if other.name == milestone.name:
continue
req.hdf['milestones.%d' % idx] = other.name
示例8: _render_confirm
# 需要导入模块: from trac.ticket import Milestone [as 别名]
# 或者: from trac.ticket.Milestone import select [as 别名]
def _render_confirm(self, req, db, milestone):
req.perm(milestone.resource).require('MILESTONE_DELETE')
milestones = [m for m in Milestone.select(self.env, db=db)
if m.name != milestone.name
and 'MILESTONE_VIEW' in req.perm(m.resource)]
data = {
'milestone': milestone,
'milestone_groups': group_milestones(milestones,
'TICKET_ADMIN' in req.perm)
}
return 'milestone_delete.html', data, None
示例9: execute
# 需要导入模块: from trac.ticket import Milestone [as 别名]
# 或者: from trac.ticket.Milestone import select [as 别名]
def execute(hdf, txt, env):
out = StringIO()
out.write('<ul>\n')
for milestone in Milestone.select(env, include_completed=False):
if milestone.due > 0:
date = format_date(milestone.due)
else:
date = Markup('<i>(later)</i>')
out.write(Markup('<li>%s - <a href="%s">%s</a></li>\n',
date, env.href.milestone(milestone.name),
milestone.name))
out.write('</ul>\n')
return out.getvalue()
示例10: process_request
# 需要导入模块: from trac.ticket import Milestone [as 别名]
# 或者: from trac.ticket.Milestone import select [as 别名]
def process_request(self, req):
req.perm.require('MILESTONE_VIEW')
show = req.args.getlist('show')
if 'all' in show:
show = ['completed']
db = self.env.get_db_cnx()
milestones = Milestone.select(self.env, 'completed' in show, db)
if 'noduedate' in show:
milestones = [m for m in milestones
if m.due is not None or m.completed]
milestones = [m for m in milestones
if 'MILESTONE_VIEW' in req.perm(m.resource)]
stats = []
queries = []
for milestone in milestones:
tickets = get_tickets_for_milestone(self.env, db, milestone.name,
'owner')
tickets = apply_ticket_permissions(self.env, req, tickets)
stat = get_ticket_stats(self.stats_provider, tickets)
stats.append(milestone_stats_data(self.env, req, stat,
milestone.name))
#milestone['tickets'] = tickets # for the iCalendar view
if req.args.get('format') == 'ics':
self.render_ics(req, db, milestones)
return
# FIXME should use the 'webcal:' scheme, probably
username = None
if req.authname and req.authname != 'anonymous':
username = req.authname
icshref = req.href.roadmap(show=show, user=username, format='ics')
add_link(req, 'alternate', icshref, _('iCalendar'), 'text/calendar',
'ics')
data = {
'milestones': milestones,
'milestone_stats': stats,
'queries': queries,
'show': show,
}
add_stylesheet(req, 'common/css/roadmap.css')
return 'roadmap.html', data, None
示例11: expand_macro
# 需要导入模块: from trac.ticket import Milestone [as 别名]
# 或者: from trac.ticket.Milestone import select [as 别名]
def expand_macro(self, formatter, name, content):
arg,kwarg = parse_args(content)
includepattern = kwarg.get('include', '')
#excludepattern = kwarg.get('exclude', '')
length = int(kwarg.get('max', -1))
ignorenoduedate = kwarg.get('ignore') == 'noduedate' or None
if length==-1:
length = None
out = StringIO()
include = re.compile(includepattern)
#exclude = re.compile(excludepattern)
milestones = []
for milestone in Milestone.select(self.env, include_completed=False):
if include.match(milestone.name): # and not exclude.match(milestone.name):
milestones.append(milestone)
out.write('<ul>\n')
for milestone in milestones[0:length]:
if milestone.due:
#TODO: add one day to tdelta
tdelta = (to_timestamp(milestone.due) -
to_timestamp(datetime.now(formatter.req.tz)))
if tdelta > 0:
date = format_date(milestone.due, '%Y-%m-%d',
formatter.req.tz)
else:
date = None
elif not ignorenoduedate:
date = Markup('<i>(Unspecified)</i>')
else:
date = None
if date:
out.write('<li>%s - <a href="%s">%s</a></li>\n' %
(date, self.env.href.milestone(milestone.name),
milestone.name))
out.write('</ul>\n')
return Markup(out.getvalue())
示例12: process_request
# 需要导入模块: from trac.ticket import Milestone [as 别名]
# 或者: from trac.ticket.Milestone import select [as 别名]
def process_request(self, req, chrome, projects):
milestones = []
stats = []
for project in projects:
env = project["env"]
for m in Milestone.select(env, False, env.get_db_cnx()):
req.href = env.href
milestone = milestone_to_hdf(env, env.get_db_cnx(), req, m)
milestone['project'] = project
milestones.append(milestone)
milestones.sort(milestone_cmp)
idx = 0
for m in milestones:
project = m['project']
env = project['env']
milestone_name = unescape(m['name']) # Kludge
prefix = 'roadmap.milestones.%d.' % idx
tickets = get_tickets_for_milestone(env, env.get_db_cnx(), milestone_name,
'owner')
stat = calc_ticket_stats(tickets)
stats.append({'stats': stat})
m['queries'] = {}
for k, v in get_query_links(env, milestone_name).items():
m['queries'][k] = v
m['tickets'] = tickets # for the iCalendar view
idx += 1
# make milestone names unique
m["name"] = project["name"] + " " + m["name"]
data = {
'milestones': milestones,
'milestone_stats': stats
}
data["chrome.nav.mainnav.roadmap.active"] = 1
data['title'] = _('Roadmap')
template_dir = os.path.dirname(__file__) + '/templates/'
chrome.populate_data(req, data)
output = chrome.render_template(req, template_dir + "roadmap.html", data)
req.session.save()
req.send(output, 'text/html')
示例13: _render_editor
# 需要导入模块: from trac.ticket import Milestone [as 别名]
# 或者: from trac.ticket.Milestone import select [as 别名]
def _render_editor(self, req, db, milestone):
data = {
'milestone': milestone,
'date_hint': get_date_format_hint(),
'datetime_hint': get_datetime_format_hint(),
'milestone_groups': [],
}
if milestone.exists:
req.perm(milestone.resource).require('MILESTONE_MODIFY')
milestones = [m for m in Milestone.select(self.env, db=db)
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')
return 'milestone_edit.html', data, None
示例14: _render_editor
# 需要导入模块: from trac.ticket import Milestone [as 别名]
# 或者: from trac.ticket.Milestone import select [as 别名]
def _render_editor(self, req, db, milestone):
if milestone.exists:
req.perm.assert_permission('MILESTONE_MODIFY')
req.hdf['title'] = u'Jalon %s' % milestone.name
req.hdf['milestone.mode'] = 'edit'
req.hdf['milestones'] = [m.name for m in
Milestone.select(self.env)
if m.name != milestone.name]
else:
req.perm.assert_permission('MILESTONE_CREATE')
req.hdf['title'] = u'Nouveau jalon'
req.hdf['milestone.mode'] = 'new'
from trac.util.datefmt import get_date_format_hint, \
get_datetime_format_hint
req.hdf['milestone'] = milestone_to_hdf(self.env, db, req, milestone)
req.hdf['milestone.date_hint'] = get_date_format_hint()
req.hdf['milestone.datetime_hint'] = get_datetime_format_hint()
req.hdf['milestone.datetime_now'] = format_datetime()
示例15: process_admin_request
# 需要导入模块: from trac.ticket import Milestone [as 别名]
# 或者: from trac.ticket.Milestone import select [as 别名]
def process_admin_request(self, req, cat, page, path_info):
req.perm.assert_permission('RT_ADMIN')
update = ""
for key in req.args.keys():
if key.startswith("update_"):
update = key[len("update_"):]
break
if update:
# update now
base_path = self.env.config.get('rtadmin', 'base_path')
run_burndown = "python " + os.path.join(base_path, "run_burndown.py %s" % update.encode("utf-8"))
os.system(run_burndown)
elif req.args.get('save') and req.args.get('sel'):
# empty table first
RT_Template.deleteAll(self.env)
# insert selected milestone into table
sel = req.args.get('sel')
sel = isinstance(sel, list) and sel or [sel]
db = self.env.get_db_cnx()
for milestone in sel:
RT_Template.insert(self.env, milestone)
db.commit()
req.redirect(self.env.href.admin(cat, page))
# get all enabled milestones
enabledMilestones = RT_Template.getMilestones(self.env)
ms = Milestone.select(self.env)
ms.sort(cmp=lambda x,y: cmp(x.name, y.name))
req.hdf['milestones'] = [{'name': m.name,
'href': self.env.href.admin(cat, page, m.name),
'enabled': m.name in enabledMilestones,
'update': stripMilestoneName(m.name),
} for m in ms]
return 'admin_relaticket.cs', None