Skip to content

Commit

Permalink
API: slugify page slugs, fixes #1401
Browse files Browse the repository at this point in the history
* Apply the slugify function on all API page endpoint slugs.

Co-authored-by: Timo Ludwig <ludwig@integreat-app.de>
  • Loading branch information
svenseeberg and timobrembeck committed May 15, 2022
1 parent e518c93 commit a870052
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ UNRELEASED
* [ [#1408](https://github.com/digitalfabrik/integreat-cms/issues/1408) ] Remove duplication of push API tokens for pages during duplication process
* [ [#1404](https://github.com/digitalfabrik/integreat-cms/issues/1404) ] Fix performance issue for select all on huge page trees
* [ [#1403](https://github.com/digitalfabrik/integreat-cms/issues/1403) ] Fix problem with cache when removing language in a region
* [ [#1401](https://github.com/digitalfabrik/integreat-cms/issues/1401) ] Support WordPress slugs by applying slugify on API parameters


2022.5.0
Expand Down
3 changes: 2 additions & 1 deletion integreat_cms/api/v3/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.shortcuts import get_object_or_404
from django.views.decorators.csrf import csrf_exempt
from django.utils.html import strip_tags
from django.utils.text import slugify

from ...cms.models import Page
from ...cms.forms import PageTranslationForm
Expand Down Expand Up @@ -142,7 +143,7 @@ def get_single_page(request, language_slug):
# Strip leading and trailing slashes to avoid ambiguous urls
url = request.GET.get("url").strip("/")
# The last path component of the url is the page translation slug
page_translation_slug = url.split("/")[-1]
page_translation_slug = slugify(url.split("/")[-1], allow_unicode=True)
# Get page by filtering for translation slug and translation language slug
filtered_pages = region.pages.filter(
translations__slug=page_translation_slug,
Expand Down

0 comments on commit a870052

Please sign in to comment.