Skip to content

Commit 78bb202

Browse files
committed
Fix redirects to login page when sorting by yourself
Broken by #51
1 parent 9dff8fc commit 78bb202

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

pgcommitfest/commitfest/views.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def home(request):
6464
patch_list = patchlist(request, cf)
6565

6666
if patch_list.redirect:
67-
return HttpResponseRedirect("/")
67+
return patch_list.redirect
6868

6969
return render(
7070
request,
@@ -222,8 +222,13 @@ def patchlist(request, cf, personalized=False):
222222
elif request.GET["author"] == "-3":
223223
# Checking for "yourself" requires the user to be logged in!
224224
if not request.user.is_authenticated:
225-
return HttpResponseRedirect(
226-
"%s?next=%s" % (settings.LOGIN_URL, request.path)
225+
return PatchList(
226+
patches=[],
227+
has_filter=False,
228+
sortkey=0,
229+
redirect=HttpResponseRedirect(
230+
"%s?next=%s" % (settings.LOGIN_URL, request.path)
231+
),
227232
)
228233
whereclauses.append(
229234
"EXISTS (SELECT 1 FROM commitfest_patch_authors cpa WHERE cpa.patch_id=p.id AND cpa.user_id=%(self)s)"
@@ -247,8 +252,13 @@ def patchlist(request, cf, personalized=False):
247252
elif request.GET["reviewer"] == "-3":
248253
# Checking for "yourself" requires the user to be logged in!
249254
if not request.user.is_authenticated:
250-
return HttpResponseRedirect(
251-
"%s?next=%s" % (settings.LOGIN_URL, request.path)
255+
return PatchList(
256+
patches=[],
257+
has_filter=False,
258+
sortkey=0,
259+
redirect=HttpResponseRedirect(
260+
"%s?next=%s" % (settings.LOGIN_URL, request.path)
261+
),
252262
)
253263
whereclauses.append(
254264
"EXISTS (SELECT 1 FROM commitfest_patch_reviewers cpr WHERE cpr.patch_id=p.id AND cpr.user_id=%(self)s)"
@@ -401,7 +411,12 @@ def patchlist(request, cf, personalized=False):
401411

402412
if not has_filter and sortkey == 0 and request.GET:
403413
# Redirect to get rid of the ugly url
404-
return PatchList(patches=[], has_filter=False, sortkey=0, redirect=True)
414+
return PatchList(
415+
patches=[],
416+
has_filter=False,
417+
sortkey=0,
418+
redirect=HttpResponseRedirect(request.path),
419+
)
405420

406421
if whereclauses:
407422
where_str = "({0})".format(") AND (".join(whereclauses))
@@ -474,7 +489,7 @@ def commitfest(request, cfid):
474489

475490
patch_list = patchlist(request, cf)
476491
if patch_list.redirect:
477-
return HttpResponseRedirect(f"/{cf.id}/")
492+
return patch_list.redirect
478493

479494
# Generate patch status summary.
480495
curs = connection.cursor()

0 commit comments

Comments
 (0)