~sircmpwn/sr.ht-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 2

[PATCH todo.sr.ht 0/2] Do not allow ommission of tilde

Details
Message ID
<20200608150336.10459-1-ben@ben.gmbh>
DKIM signature
missing
Download raw message
This makes todo.sr.ht's behavior consistent with other sr.ht services
by returning a 404 if you try to omit the tilde in a tracker URL. The
second commit also fixes the "Create & configure tracker" button
redirecting you to https://todo.sr.ht/username/tracker without a tilde.
Fixes https://todo.sr.ht/~sircmpwn/todo.sr.ht/198

Benjamin Lowry (2):
  get_tracker: return None if tilde is ommitted
  redirect to correct page when creating & configuring tracker

 todosrht/access.py             | 36 +++++++++++++++++-----------------
 todosrht/blueprints/tracker.py |  2 +-
 2 files changed, 19 insertions(+), 19 deletions(-)

-- 
2.26.2

[PATCH todo.sr.ht 1/2] get_tracker: return None if tilde is ommitted

Details
Message ID
<20200608150336.10459-2-ben@ben.gmbh>
In-Reply-To
<20200608150336.10459-1-ben@ben.gmbh> (view parent)
DKIM signature
missing
Download raw message
Patch: +18 -18
This makes the behavior consistent with other sr.ht services

Signed-off-by: Benjamin Lowry <ben@ben.gmbh>
---
 todosrht/access.py | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/todosrht/access.py b/todosrht/access.py
index 3d5eadd..06e3e86 100644
--- a/todosrht/access.py
+++ b/todosrht/access.py
@@ -39,26 +39,26 @@ def get_tracker(owner, name, with_for_update=False, user=None):
    if not owner:
        return None, None

    if not isinstance(owner, User):
        if owner.startswith("~"):
            owner = owner[1:]
        owner = User.query.filter(User.username == owner).one_or_none()
        if not owner:
    if owner[0] == "~":
        owner = owner[1:]
        if not isinstance(owner, User):
            owner = User.query.filter(User.username == owner).one_or_none()
            if not owner:
                return None, None
        tracker = (Tracker.query
            .filter(Tracker.owner_id == owner.id)
            .filter(Tracker.name.ilike(name)))
        if with_for_update:
            tracker = tracker.with_for_update()
        tracker = tracker.one_or_none()
        if not tracker:
            return None, None
    tracker = (Tracker.query
        .filter(Tracker.owner_id == owner.id)
        .filter(Tracker.name.ilike(name)))
    if with_for_update:
        tracker = tracker.with_for_update()
    tracker = tracker.one_or_none()
    if not tracker:
        access = get_access(tracker, None, user=user)
        if access:
            return tracker, access
    else:
        # TODO: org trackers
        return None, None
    access = get_access(tracker, None, user=user)
    if access:
        return tracker, access

    # TODO: org trackers
    return None, None

def get_ticket(tracker, ticket_id, user=None):
    ticket = (Ticket.query
-- 
2.26.2

[PATCH todo.sr.ht 2/2] redirect to correct page when creating & configuring tracker

Details
Message ID
<20200608150336.10459-3-ben@ben.gmbh>
In-Reply-To
<20200608150336.10459-1-ben@ben.gmbh> (view parent)
DKIM signature
missing
Download raw message
Patch: +1 -1
Use canonical_name to redirect to the tracker page with
a tilde before the username.

Signed-off-by: Benjamin Lowry <ben@ben.gmbh>
---
 todosrht/blueprints/tracker.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/todosrht/blueprints/tracker.py b/todosrht/blueprints/tracker.py
index 68cde2c..4d3a5ae 100644
--- a/todosrht/blueprints/tracker.py
+++ b/todosrht/blueprints/tracker.py
@@ -53,7 +53,7 @@ def create_POST():

    if "create-configure" in valid:
        return redirect(url_for("settings.details_GET",
                owner=current_user.username,
                owner=current_user.canonical_name,
                name=tracker.name))

    return redirect(tracker_url(tracker))
-- 
2.26.2
Details
Message ID
<C3BWNNDG3ULF.HVOUNHIH5X6X@homura>
In-Reply-To
<20200608150336.10459-1-ben@ben.gmbh> (view parent)
DKIM signature
missing
Download raw message
Thanks!

To git@git.sr.ht:~sircmpwn/todo.sr.ht
   095e199..fcf5cf2  master -> master
Reply to thread Export thread (mbox)