Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect /opportunity pages to /initiatives #4248

Merged
merged 18 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions network-api/networkapi/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from networkapi.views import EnvVariablesView, review_app_help_view
from networkapi.buyersguide import views as buyersguide_views
from networkapi.wagtailpages.rss import RSSFeed, AtomFeed
from networkapi.wagtailpages.views import redirect_to_initiatives
from experiments import views as experiment_views

admin.autodiscover()
Expand Down Expand Up @@ -64,6 +65,10 @@
path('blog/rss/', RSSFeed()),
path('blog/atom/', AtomFeed()),

# redirect /opportunity Wagtail pages to /initiatives
# see https://github.com/mozilla/foundation.mozilla.org/issues/2971 for context
url(r'^opportunity/(?P<rest>.*)', redirect_to_initiatives),

# wagtail-managed data
url(r'', include(wagtail_urls)),
)
Expand Down
11 changes: 10 additions & 1 deletion network-api/networkapi/wagtailpages/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.http import HttpResponseNotFound
from django.shortcuts import render
from django.shortcuts import render, redirect
from django.utils import translation


def custom404_view(request, exception):
Expand All @@ -22,3 +23,11 @@ def custom404_view(request, exception):
else:
html = render(request, '404.html')
return HttpResponseNotFound(html.content)


def redirect_to_initiatives(request, rest):
lang = request.LANGUAGE_CODE
translation.activate(lang)
request.session[translation.LANGUAGE_SESSION_KEY] = lang

return redirect(f'/initiatives/{rest}')