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 urls with old format to new one #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions dojopuzzles/dojopuzzles/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
urlpatterns = [
path("admin/", admin.site.urls),
path("problems/", include("problems.urls")),
path("problemas/", include("problems.old_urls")),
path("", include("core.urls")),
]
13 changes: 13 additions & 0 deletions dojopuzzles/problems/old_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# handles the old routes and match them to views that redirects to new urls format
from django.urls import path

from problems import oldurlstonew_views as views

urlpatterns = [
path("exibe/random/", views.problem_random_redirect),
path(
"exibe/select/<int:problem_id>",
views.problem_select_redirect,
),
path("exibe/<slug:slug>/", views.problem_details_redirect),
]
14 changes: 14 additions & 0 deletions dojopuzzles/problems/oldurlstonew_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# views to redirect old urls format to new ones.
from django.shortcuts import redirect


def problem_details_redirect(request, slug):
return redirect("problems:problem_details", slug=slug)


def problem_random_redirect(request):
return redirect("problems:problem_random")


def problem_select_redirect(request, problem_id):
return redirect("problems:problem_select", problem_id=problem_id)