本文整理汇总了Python中trac.ticket.model.Ticket.values["reporter"]方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket.values["reporter"]方法的具体用法?Python Ticket.values["reporter"]怎么用?Python Ticket.values["reporter"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.ticket.model.Ticket
的用法示例。
在下文中一共展示了Ticket.values["reporter"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_request
# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import values["reporter"] [as 别名]
def process_request(self, req):
req.perm.assert_permission("TICKET_VIEW")
if not self.env.config.has_option("ticket-custom", self.field_name):
raise TracError(
'Configuration error: the custom ticket field "%s" has not been defined '
"in the [ticket-custom] section of trac.ini. See the documentation "
"for more info on configuring the TaskListPlugin." % self.field_name
)
constraints = self._get_constraints(req)
if not constraints and not "order" in req.args:
# If no constraints are given in the URL, use the default ones.
if req.authname and req.authname != "anonymous":
qstring = self.default_query
user = req.authname
else:
email = req.session.get("email")
name = req.session.get("name")
qstring = self.default_anonymous_query
user = email or name or None
if user:
qstring = qstring.replace("$USER", user)
self.log.debug("TasklistPlugin: Using default query: %s", qstring)
constraints = Query.from_string(self.env, qstring).constraints
# Ensure no field constraints that depend on $USER are used
# if we have no username.
# It may be possible to just use constraints[0] here, rather than
# iterating over constraints. See th#6336.
for constraint in constraints:
for field, vals in constraint.items():
for val in vals:
if val.endswith("$USER"):
del constraint[field]
cols = req.args.get("col")
if not cols:
cols = self.default_cols
cols.append(self.field_name)
if isinstance(cols, basestring):
cols = [cols]
form_cols = copy.copy(cols)
# Since we don't show 'id' or the tasklist_field as an option
# to the user, we need to re-insert it here.
if cols and "id" not in cols:
cols.insert(0, "id")
if cols and self.field_name not in cols:
cols.insert(0, self.field_name)
rows = req.args.get("row", [])
if isinstance(rows, basestring):
rows = [rows]
q = Query(self.env, constraints=constraints, cols=cols)
query = Query(
self.env,
req.args.get("report"),
constraints,
cols,
req.args.get("order"),
"desc" in req.args,
req.args.get("group"),
"groupdesc" in req.args,
"verbose" in req.args,
rows,
req.args.get("limit"),
)
if "update" in req.args:
# Reset session vars
for var in ("query_constraints", "query_time", "query_tickets"):
if var in req.session:
del req.session[var]
req.redirect(q.get_href(req.href).replace("/query", "/tasklist"))
if "add" in req.args:
req.perm.require("TICKET_CREATE")
t = Ticket(self.env)
if req.method == "POST" and "field_owner" in req.args and "TICKET_MODIFY" not in req.perm:
del req.args["field_owner"]
self._populate(req, t)
reporter_id = req.args.get("field_reporter") or get_reporter_id(req, "author")
t.values["reporter"] = reporter_id
valid = None
valid = self._validate_ticket(req, t)
if valid:
t.insert()
# Notify
try:
tn = TicketNotifyEmail(self.env)
tn.notify(t, newticket=True)
except Exception, e:
self.log.exception("Failure sending notification on creation of " "ticket #%s: %s" % (t.id, e))
req.redirect(q.get_href(req.href).replace("/query", "/tasklist"))