From 31809eab773133a9de4e6759296372da197142d9 Mon Sep 17 00:00:00 2001 From: Grecia Cortes Date: Fri, 18 Feb 2022 11:51:17 -0600 Subject: [PATCH 1/2] fix(opinion): Fix URL redirects when a reporter is not found --- .gitignore | 5 +++++ cl/opinion_page/views.py | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b4a79c2e0e..d2fad4d64c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,11 @@ *.egg-info .dmypy.json +# pyenv +# For a library or package, you might want to ignore these files since the +# code is intended to run in multiple environments; otherwise, check them in: +.python-version + # no compiled files! *.class *.pyc diff --git a/cl/opinion_page/views.py b/cl/opinion_page/views.py index ed9d744a9c..dafcdff569 100644 --- a/cl/opinion_page/views.py +++ b/cl/opinion_page/views.py @@ -818,12 +818,14 @@ def citation_redirector( This uses the same infrastructure as the thing that identifies citations in the text of opinions. """ - if request.method == "POST": form = CitationRedirectorForm(request.POST) if form.is_valid(): # Redirect to the page as a GET instead of a POST cd = form.cleaned_data + ### debug + print(f"[DEBUG - 2.1] reporter: {cd['reporter']}") + ### debug return HttpResponseRedirect( reverse("citation_redirector", kwargs=cd) ) @@ -868,7 +870,10 @@ def citation_redirector( slug_edition = {slugify(item): item for item in EDITIONS.keys()} proper_reporter = slug_edition.get(SafeText(reporter), None) if not proper_reporter: - return HttpResponse(status=404) + return throw_404( + request, + {"no_reporters": True, "reporter": reporter, "private": False}, + ) # We have a reporter (show volumes in it), a volume (show cases in # it), or a citation (show matching citation(s)) if proper_reporter and volume and page: From aaa56d5ae61480e9e8e79f1982e5c6d187c715e1 Mon Sep 17 00:00:00 2001 From: Grecia Cortes Date: Fri, 18 Feb 2022 12:51:18 -0600 Subject: [PATCH 2/2] fix(opinion): Remove debugging comments --- cl/opinion_page/views.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/cl/opinion_page/views.py b/cl/opinion_page/views.py index dafcdff569..abf393788e 100644 --- a/cl/opinion_page/views.py +++ b/cl/opinion_page/views.py @@ -823,9 +823,6 @@ def citation_redirector( if form.is_valid(): # Redirect to the page as a GET instead of a POST cd = form.cleaned_data - ### debug - print(f"[DEBUG - 2.1] reporter: {cd['reporter']}") - ### debug return HttpResponseRedirect( reverse("citation_redirector", kwargs=cd) )