Skip to content

Instantly share code, notes, and snippets.

@mathjazz
Created November 20, 2023 17:55
Show Gist options
  • Save mathjazz/476284bf9cae6918aed2ac58c2e90caf to your computer and use it in GitHub Desktop.
Save mathjazz/476284bf9cae6918aed2ac58c2e90caf to your computer and use it in GitHub Desktop.
Fix for the 404 error
diff --git a/pontoon/contributors/views.py b/pontoon/contributors/views.py
index f47656815..ffea38cff 100644
--- a/pontoon/contributors/views.py
+++ b/pontoon/contributors/views.py
@@ -312,24 +312,29 @@ def settings(request):
all_locales.insert(0, default_homepage_locale)
# Set custom homepage selector value
- custom_homepage_code = profile.custom_homepage
- custom_homepage_locale = get_locale_or_redirect(
- custom_homepage_code, "pontoon.contributors.views.settings", "locale"
- )
- if isinstance(custom_homepage_locale, HttpResponseRedirect):
- return custom_homepage_locale
+ if profile.custom_homepage:
+ custom_homepage_locale = get_locale_or_redirect(
+ profile.custom_homepage, "pontoon.contributors.views.settings", "locale"
+ )
+ if isinstance(custom_homepage_locale, HttpResponseRedirect):
+ return custom_homepage_locale
+ else:
+ custom_homepage_locale = default_homepage_locale
+
default_preferred_source_locale = Locale(name="Default project locale", code="")
preferred_locales = list(Locale.objects.all())
preferred_locales.insert(0, default_preferred_source_locale)
# Set preferred source locale
- preferred_source_code = profile.preferred_source_locale
- preferred_source_locale = get_locale_or_redirect(
- preferred_source_code, "pontoon.contributors.views.settings", "locale"
- )
- if isinstance(preferred_source_locale, HttpResponseRedirect):
- return preferred_source_locale
+ if profile.preferred_source_locale:
+ preferred_source_locale = get_locale_or_redirect(
+ profile.preferred_source_locale, "pontoon.contributors.views.settings", "locale"
+ )
+ if isinstance(preferred_source_locale, HttpResponseRedirect):
+ return preferred_source_locale
+ else:
+ preferred_source_locale = default_preferred_source_locale
return render(
request,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment