Skip to content

Locale switch from parent non-default locale document should 404 #6708

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

Merged

Conversation

smithellis
Copy link
Contributor

This covers a case where the user is on a document that is not in the default locale (in our case en-US) and is not a translation.
If the user tries to use the locale switcher to go to English, since there is no parent as we are not on a translation, the user should get a 404.

not in the default locale

This covers a case where the user is on a document that
is not in the default locale (in our case en-US) and
is not a translation.
If the user tries to use the locale switcher to go to
English, since there is no parent as we are not on a
translation, the user should get a 404.
@smithellis smithellis force-pushed the locale-switcher-non-default-language-doc branch from 6f52ab9 to c54ccbd Compare June 5, 2025 20:08
parent = get_object_or_404(Document.objects.visible(user, **kwargs))
try:
parent = Document.objects.get_visible(user, **kwargs)
except Document.DoesNotExist:
raise Http404

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change does the exact same thing as what it replaces, so I guess you're making the case that the change is more readable, and I can buy that.

@escattone escattone merged commit db0a2c0 into mozilla:main Jun 6, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants