本文整理汇总了Python中trac.ticket.web_ui.TicketModule._populate方法的典型用法代码示例。如果您正苦于以下问题:Python TicketModule._populate方法的具体用法?Python TicketModule._populate怎么用?Python TicketModule._populate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.ticket.web_ui.TicketModule
的用法示例。
在下文中一共展示了TicketModule._populate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _implementation
# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import _populate [as 别名]
def _implementation(db):
tkt = Ticket(self.env, ticket_id)
tm = TicketModule(self.env)
req.args[field] = new_value
tm._populate(req, tkt, plain_fields=True)
changes, problems = tm.get_ticket_changes(req, tkt, "btn_save")
if problems:
raise ValueError(problems)
tm._apply_ticket_changes(tkt, changes)
valid = tm._validate_ticket(req, tkt, force_collision_check=True)
if not valid:
raise ValueError(req.chrome['warnings'])
else:
tkt.save_changes(req.authname, "", when=datetime.now(utc))
示例2: do_save
# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import _populate [as 别名]
def do_save(db):
tm = TicketModule(self.env)
req.args["milestone"] = milestone
if ts:
req.args["ts"] = ts
tm._populate(req, ticket, plain_fields=True)
changes, problems = tm.get_ticket_changes(req, ticket, "btn_save")
if problems:
raise ValueError(problems)
tm._apply_ticket_changes(ticket, changes)
valid = tm._validate_ticket(req, ticket, force_collision_check=True)
if not valid:
raise ValueError(req.chrome['warnings'])
else:
ticket.save_changes(req.authname, "", when=datetime.now(utc))
示例3: _do_save
# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import _populate [as 别名]
def _do_save(self, req, db, milestone):
if milestone.exists:
req.perm(milestone.resource).require('MILESTONE_MODIFY')
else:
req.perm(milestone.resource).require('MILESTONE_CREATE')
ticket_module = TicketModule(self.env)
ticket_module._populate(req, milestone.ticket, False)
if not milestone.exists:
reporter_id = get_reporter_id(req, 'author')
milestone.ticket.values['reporter'] = reporter_id
action = req.args.get('action', 'leave')
field_changes, problems = ticket_module.get_ticket_changes(req, milestone.ticket,
action)
if problems:
for problem in problems:
add_warning(req, problem)
add_warning(req,
tag(tag.p('Please review your configuration, '
'probably starting with'),
tag.pre('[trac]\nworkflow = ...\n'),
tag.p('in your ', tag.tt('trac.ini'), '.'))
)
ticket_module._apply_ticket_changes(milestone.ticket, field_changes)
old_name = milestone.name
new_name = milestone.ticket['summary']
milestone.name = new_name
milestone.description = milestone.ticket['description']
due = req.args.get('duedate', '')
milestone.due = due and parse_date(due, tzinfo=req.tz) or None
milestone.ticket['duedate']=milestone.due and str(to_timestamp(milestone.due)) or None
completed = req.args.get('completedate', '')
retarget_to = req.args.get('target')
# Instead of raising one single error, check all the constraints and
# let the user fix them by going back to edit mode showing the warnings
warnings = []
def warn(msg):
add_warning(req, msg)
warnings.append(msg)
# -- check the name
if new_name:
if new_name != old_name:
# check that the milestone doesn't already exists
# FIXME: the whole .exists business needs to be clarified
# (#4130) and should behave like a WikiPage does in
# this respect.
try:
other_milestone = StructuredMilestone(self.env, new_name, db)
warn(_('Milestone "%(name)s" already exists, please '
'choose another name', name=new_name))
except ResourceNotFound:
pass
else:
warn(_('You must provide a name for the milestone.'))
# -- check completed date
if action in MilestoneSystem(self.env).starting_action:
milestone.ticket['started'] = str(to_timestamp(datetime.now(utc)))
if action in MilestoneSystem(self.env).completing_action:
milestone.completed = datetime.now(utc)
if warnings:
return self._render_editor(req, db, milestone)
# -- actually save changes
if milestone.exists:
cnum = req.args.get('cnum')
replyto = req.args.get('replyto')
internal_cnum = cnum
if cnum and replyto: # record parent.child relationship
internal_cnum = '%s.%s' % (replyto, cnum)
now = datetime.now(utc)
milestone.save_changes(get_reporter_id(req, 'author'),
req.args.get('comment'), when=now,
cnum=internal_cnum)
# eventually retarget opened tickets associated with the milestone
if 'retarget' in req.args and completed:
cursor = db.cursor()
cursor.execute("UPDATE ticket SET milestone=%s WHERE "
"milestone=%s and status != 'closed'",
(retarget_to, old_name))
self.env.log.info('Tickets associated with milestone %s '
'retargeted to %s' % (old_name, retarget_to))
else:
milestone.insert()
db.commit()
add_notice(req, _('Your changes have been saved.'))
jump_to = req.args.get('jump_to', 'roadmap')
if jump_to=='roadmap':
#.........这里部分代码省略.........