~sircmpwn/todo.sr.ht

7643b83209297c42343dab308f6d3e4e1de42ca6 — Simon Ser 2 months ago 11cf2a5 0.62.7
Don't append duplicate term in label_search_url

Prevent duplicate "label:" criteria from being appended to the query.
1 files changed, 7 insertions(+), 3 deletions(-)

M todosrht/urls.py
M todosrht/urls.py => todosrht/urls.py +7 -3
@@ 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."""