Don't append duplicate term in label_search_url

Prevent duplicate "label:" criteria from being appended to the query.
This commit is contained in:
Simon Ser 2020-11-04 20:21:54 +00:00 committed by Drew DeVault
parent 11cf2a5c09
commit 7643b83209
1 changed files with 7 additions and 3 deletions

View File

@ -55,10 +55,14 @@ def label_edit_url(label):
def label_search_url(label, terms=""):
"""Return the URL to the tracker page listing all tickets which have the
label applied."""
return "{}?search=label:"{}"{}".format(
label_term = f"label:\"{label.name}\""
if not terms:
terms = label_term
elif label_term not in terms:
terms += " " + label_term
return "{}?search={}".format(
tracker_url(label.tracker),
unicode_urlencode(label.name),
f" {unicode_urlencode(terms)}" if terms else "")
unicode_urlencode(terms))
def label_add_url(ticket):
"""Return the URL to add a label to a ticket."""