ref: a10b980692778cbc92fcad88d8ce5b2d2f0ad1e8 todo.sr.ht/todosrht/urls.py -rw-r--r-- 2.1 KiB View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from flask import url_for
from jinja2.utils import unicode_urlencode

def tracker_url(tracker):
    return url_for("tracker.tracker_GET",
        owner=tracker.owner.canonical_name,
        name=tracker.name)

def tracker_labels_url(tracker):
    return url_for("tracker.tracker_labels_GET",
        owner=tracker.owner.canonical_name,
        name=tracker.name)

def ticket_url(ticket, comment=None):
    ticket_url = url_for("ticket.ticket_GET",
            owner=ticket.tracker.owner.canonical_name,
            name=ticket.tracker.name,
            ticket_id=ticket.scoped_id)

    if comment:
        ticket_url += "#comment-" + str(comment.id)

    return ticket_url

def ticket_edit_url(ticket):
    return url_for("ticket.ticket_edit_GET",
        owner=ticket.tracker.owner.canonical_name,
        name=ticket.tracker.name,
        ticket_id=ticket.scoped_id)

def ticket_assign_url(ticket):
    return url_for("ticket.ticket_assign",
        owner=ticket.tracker.owner.canonical_name,
        name=ticket.tracker.name,
        ticket_id=ticket.scoped_id)

def ticket_unassign_url(ticket):
    return url_for("ticket.ticket_unassign",
        owner=ticket.tracker.owner.canonical_name,
        name=ticket.tracker.name,
        ticket_id=ticket.scoped_id)

def label_search_url(label):
    """Return the URL to the tracker page listing all tickets which have the
    label applied."""
    return "{}?search=label:"{}"".format(
        tracker_url(label.tracker),
        unicode_urlencode(label.name))

def label_add_url(label, ticket):
    """Return the URL to remove a label from a ticket."""
    return url_for("ticket.ticket_add_label",
            owner=ticket.tracker.owner.canonical_name,
            name=ticket.tracker.name,
            ticket_id=ticket.scoped_id)

def label_remove_url(label, ticket):
    """Return the URL to add a label to a ticket."""
    return url_for("ticket.ticket_remove_label",
            owner=ticket.tracker.owner.canonical_name,
            name=ticket.tracker.name,
            ticket_id=ticket.scoped_id,
            label_id=label.id)

def user_url(user):
    return url_for("html.user_GET", username=user.username)