本文整理汇总了Python中trac.ticket.web_ui.TicketModule._validate_ticket方法的典型用法代码示例。如果您正苦于以下问题:Python TicketModule._validate_ticket方法的具体用法?Python TicketModule._validate_ticket怎么用?Python TicketModule._validate_ticket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.ticket.web_ui.TicketModule
的用法示例。
在下文中一共展示了TicketModule._validate_ticket方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _implementation
# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import _validate_ticket [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 _validate_ticket [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: update
# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import _validate_ticket [as 别名]
def update(self, req, id, comment, attributes={}, notify=False, author='', when=None):
""" Update a ticket, returning the new ticket in the same form as
get(). 'New-style' call requires two additional items in attributes:
(1) 'action' for workflow support (including any supporting fields
as retrieved by getActions()),
(2) '_ts' changetime token for detecting update collisions (as received
from get() or update() calls).
''Calling update without 'action' and '_ts' changetime token is
deprecated, and will raise errors in a future version.'' """
t = model.Ticket(self.env, id)
# custom author?
if author and not (req.authname == 'anonymous' \
or 'TICKET_ADMIN' in req.perm(t.resource)):
# only allow custom author if anonymous is permitted or user is admin
self.log.warn("RPC ticket.update: %r not allowed to change author "
"to %r for comment on #%d", req.authname, author, id)
author = ''
author = author or req.authname
# custom change timestamp?
if when and not 'TICKET_ADMIN' in req.perm(t.resource):
self.log.warn("RPC ticket.update: %r not allowed to update #%d with "
"non-current timestamp (%r)", author, id, when)
when = None
when = when or to_datetime(None, utc)
# and action...
if not 'action' in attributes:
# FIXME: Old, non-restricted update - remove soon!
self.log.warning("Rpc ticket.update for ticket %d by user %s " \
"has no workflow 'action'." % (id, req.authname))
req.perm(t.resource).require('TICKET_MODIFY')
time_changed = attributes.pop('_ts', None)
if time_changed and \
str(time_changed) != str(to_utimestamp(t.time_changed)):
raise TracError("Ticket has been updated since last get().")
for k, v in attributes.iteritems():
t[k] = v
t.save_changes(author, comment, when=when)
else:
ts = TicketSystem(self.env)
tm = TicketModule(self.env)
# TODO: Deprecate update without time_changed timestamp
time_changed = attributes.pop('_ts', to_utimestamp(t.time_changed))
try:
time_changed = int(time_changed)
except ValueError:
raise TracError("RPC ticket.update: Wrong '_ts' token " \
"in attributes (%r)." % time_changed)
action = attributes.get('action')
avail_actions = ts.get_available_actions(req, t)
if not action in avail_actions:
raise TracError("Rpc: Ticket %d by %s " \
"invalid action '%s'" % (id, req.authname, action))
controllers = list(tm._get_action_controllers(req, t, action))
all_fields = [field['name'] for field in ts.get_ticket_fields()]
for k, v in attributes.iteritems():
if k in all_fields and k != 'status':
t[k] = v
# TicketModule reads req.args - need to move things there...
req.args.update(attributes)
req.args['comment'] = comment
# Collision detection: 0.11+0.12 timestamp
req.args['ts'] = str(from_utimestamp(time_changed))
# Collision detection: 0.13/1.0+ timestamp
req.args['view_time'] = str(time_changed)
changes, problems = tm.get_ticket_changes(req, t, action)
for warning in problems:
add_warning(req, "Rpc ticket.update: %s" % warning)
valid = problems and False or tm._validate_ticket(req, t)
if not valid:
raise TracError(
" ".join([warning for warning in req.chrome['warnings']]))
else:
tm._apply_ticket_changes(t, changes)
self.log.debug("Rpc ticket.update save: %s" % repr(t.values))
t.save_changes(author, comment, when=when)
# Apply workflow side-effects
for controller in controllers:
controller.apply_action_side_effects(req, t, action)
if notify:
try:
tn = TicketNotifyEmail(self.env)
tn.notify(t, newticket=False, modtime=when)
except Exception, e:
self.log.exception("Failure sending notification on change of "
"ticket #%s: %s" % (t.id, e))
示例4: invoke
# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import _validate_ticket [as 别名]
def invoke(self, message, warnings):
"""reply to a ticket"""
ticket = self.ticket
reporter = self._reporter(message)
# get the mailBody and attachments
mailBody, attachments = get_body_and_attachments(message)
if not mailBody:
warnings.append("Seems to be a reply to %s but I couldn't find a comment")
return message
#go throught work
ts = TicketSystem(self.env)
tm = TicketModule(self.env)
perm = PermissionSystem(self.env)
# TODO: Deprecate update without time_changed timestamp
mockReq = self._MockReq(perm.get_user_permissions(reporter), reporter)
avail_actions = ts.get_available_actions(mockReq, ticket)
mailBody, inBodyFields, actions = self._get_in_body_fields(mailBody, avail_actions, reporter)
if inBodyFields or actions :
# check permissions
perm = PermissionSystem(self.env)
#we have properties movement, cheking user permission to do so
if not perm.check_permission('MAIL2TICKET_PROPERTIES', reporter) : # None -> 'anoymous'
raise ("%s does not have MAIL2TICKET_PROPERTIES permissions" % (user or 'anonymous'))
action = None
if actions :
action = actions.keys()[0]
controllers = list(tm._get_action_controllers(mockReq, ticket, action))
all_fields = [field['name'] for field in ts.get_ticket_fields()]
#impact changes find in inBodyFields
for field in inBodyFields :
ticket._old[field] = ticket[field]
ticket.values[field] = inBodyFields[field]
mockReq.args[field] = inBodyFields[field]
if action :
mockReq.args['action_%s_reassign_owner' % action] = ticket['owner']
mockReq.args['comment'] = mailBody
mockReq.args['ts'] = datetime.now()#to_datetime(None, utc)
mockReq.args['ts'] = str(ticket.time_changed)
changes, problems = tm.get_ticket_changes(mockReq, ticket, action)
valid = problems and False or tm._validate_ticket(mockReq, ticket)
tm._apply_ticket_changes(ticket, changes)
# add attachments to the ticket
add_attachments(self.env, ticket, attachments)
ticket.save_changes(reporter, mailBody)
for controller in controllers:
controller.apply_action_side_effects(mockReq, ticket, action)
# Call ticket change listeners
for listener in ts.change_listeners:
listener.ticket_changed(ticket, mailBody, reporter, ticket._old)
tn = TicketNotifyEmail(self.env)
tn.notify(ticket, newticket=0, modtime=ticket.time_changed)