-
Notifications
You must be signed in to change notification settings - Fork 750
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
Ensure view gets a locale #6503
Conversation
kitsune/wiki/views.py
Outdated
@@ -1697,10 +1697,10 @@ def recent_revisions(request): | |||
form.is_valid() | |||
|
|||
filters = {} | |||
locale = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? It's never set to anything else other than None
and then ignored below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correcting.
kitsune/wiki/views.py
Outdated
@@ -1717,7 +1717,7 @@ def recent_revisions(request): | |||
c = { | |||
"revisions": revs, | |||
"form": form, | |||
"locale": request.GET.get("locale", request.LANGUAGE_CODE), | |||
"locale": locale or request.LANGUAGE_CODE, # Ensure locale is always set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this change as well. Why are you no longer getting the locale from the URL's query parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What basically this does is equivalent to "locale": request.LANGUAGE_CODE
. You are setting locale=None
which will force the short circuit operation to evaluate always to request.LANGUAGE_CODE
The problem here is the get() method. It defaults to request.LANGUAGE_CODE
if the "locale" dictionary key is not present. It doesn't check the value of the key which is the empty string.
This should be:
"locale": request.GET.get("locale") or request.LANGUAGE_CODE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right of course; correcting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please merge after the release.
In the case of leaving the revision page, then returning via the browser back button, the locale wasn't being set in any way. This change ensures the locale is set.
This should resolve mozilla/sumo#2018