Implement ticket.ref()
Returning the ticket reference string ~user/tracker#scoped_id.
This commit is contained in:
parent
be993d8a07
commit
9e051e71b7
|
@ -22,9 +22,9 @@ def test_assignment(mailbox):
|
||||||
|
|
||||||
assert len(mailbox) == 1
|
assert len(mailbox) == 1
|
||||||
assert mailbox[0].to == assignee1.email
|
assert mailbox[0].to == assignee1.email
|
||||||
assert mailbox[0].subject == "~foo/bar/#1: Hilfe!"
|
assert mailbox[0].subject == "~foo/bar#1: Hilfe!"
|
||||||
assert mailbox[0].body.startswith(
|
assert mailbox[0].body.startswith(
|
||||||
"You were assigned to ~foo/bar/#1 by ~assigner")
|
"You were assigned to ~foo/bar#1 by ~assigner")
|
||||||
|
|
||||||
# Assignment is idempotent
|
# Assignment is idempotent
|
||||||
assign(ticket, assignee1, assigner)
|
assign(ticket, assignee1, assigner)
|
||||||
|
@ -37,9 +37,9 @@ def test_assignment(mailbox):
|
||||||
|
|
||||||
assert len(mailbox) == 2
|
assert len(mailbox) == 2
|
||||||
assert mailbox[1].to == assignee2.email
|
assert mailbox[1].to == assignee2.email
|
||||||
assert mailbox[1].subject == "~foo/bar/#1: Hilfe!"
|
assert mailbox[1].subject == "~foo/bar#1: Hilfe!"
|
||||||
assert mailbox[1].body.startswith(
|
assert mailbox[1].body.startswith(
|
||||||
"You were assigned to ~foo/bar/#1 by ~assigner")
|
"You were assigned to ~foo/bar#1 by ~assigner")
|
||||||
|
|
||||||
unassign(ticket, assignee1, assigner)
|
unassign(ticket, assignee1, assigner)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{{! vim: set ft=email }}
|
{{! vim: set ft=email }}
|
||||||
You were assigned to {{ ticket_path }} by {{ assigner }}.
|
You were assigned to {{ ticket_ref }} by {{ assigner }}.
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
||||||
|
|
|
@ -69,12 +69,7 @@ def _create_event_notification(user, event):
|
||||||
return notification
|
return notification
|
||||||
|
|
||||||
def _send_comment_notification(subscription, ticket, user, comment, resolution):
|
def _send_comment_notification(subscription, ticket, user, comment, resolution):
|
||||||
subject = "Re: {}/{}/#{}: {}".format(
|
subject = "Re: {}: {}".format(ticket.ref(), ticket.title)
|
||||||
ticket.tracker.owner.canonical_name,
|
|
||||||
ticket.tracker.name,
|
|
||||||
ticket.scoped_id,
|
|
||||||
ticket.title)
|
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"From": "~{} <{}>".format(user.username, notify_from),
|
"From": "~{} <{}>".format(user.username, notify_from),
|
||||||
"Sender": smtp_user,
|
"Sender": smtp_user,
|
||||||
|
@ -180,12 +175,7 @@ def notify_assignee(subscription, ticket, assigner, assignee):
|
||||||
"""
|
"""
|
||||||
Sends a notification email to the person who was assigned to the issue.
|
Sends a notification email to the person who was assigned to the issue.
|
||||||
"""
|
"""
|
||||||
ticket_path = "{}/{}/#{}".format(
|
subject = "{}: {}".format(ticket.ref(), ticket.title)
|
||||||
ticket.tracker.owner.canonical_name,
|
|
||||||
ticket.tracker.name,
|
|
||||||
ticket.scoped_id)
|
|
||||||
subject = "{}: {}".format(ticket_path, ticket.title)
|
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"From": "~{} <{}>".format(assigner.username, notify_from),
|
"From": "~{} <{}>".format(assigner.username, notify_from),
|
||||||
"Sender": smtp_user,
|
"Sender": smtp_user,
|
||||||
|
@ -193,7 +183,7 @@ def notify_assignee(subscription, ticket, assigner, assignee):
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"assigner": assigner.canonical_name,
|
"assigner": assigner.canonical_name,
|
||||||
"ticket_path": ticket_path,
|
"ticket_ref": ticket.ref(),
|
||||||
"ticket_url": ticket_url(ticket)
|
"ticket_url": ticket_url(ticket)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,3 +61,9 @@ class Ticket(Base):
|
||||||
assigned_users = sa.orm.relationship("User",
|
assigned_users = sa.orm.relationship("User",
|
||||||
secondary="ticket_assignee",
|
secondary="ticket_assignee",
|
||||||
foreign_keys="[TicketAssignee.ticket_id,TicketAssignee.assignee_id]")
|
foreign_keys="[TicketAssignee.ticket_id,TicketAssignee.assignee_id]")
|
||||||
|
|
||||||
|
def ref(self):
|
||||||
|
return "{}/{}#{}".format(
|
||||||
|
self.tracker.owner.canonical_name,
|
||||||
|
self.tracker.name,
|
||||||
|
self.scoped_id)
|
||||||
|
|
Loading…
Reference in New Issue