Skip to content

Instantly share code, notes, and snippets.

@mathjazz
Last active March 28, 2018 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathjazz/e191e7136a37c6dd89696a9840a53c22 to your computer and use it in GitHub Desktop.
Save mathjazz/e191e7136a37c6dd89696a9840a53c22 to your computer and use it in GitHub Desktop.
Redirect all-projects
diff --git a/pontoon/base/views.py b/pontoon/base/views.py
index a9c1076..066ba19 100755
--- a/pontoon/base/views.py
+++ b/pontoon/base/views.py
@@ -113,15 +113,21 @@ def translate(request, locale, slug, part):
def translate_locale_agnostic(request, slug, part):
"""Locale Agnostic Translate view."""
user = request.user
- project = get_object_or_404(Project.objects.available(), slug=slug)
+
+ if slug.lower() == 'all-projects':
+ project_locales = Locale.objects.available()
+ else:
+ project = get_object_or_404(Project.objects.available(), slug=slug)
+ project_locales = project.locales
if user.is_authenticated():
locale = user.profile.custom_homepage
- if locale and project.locales.filter(code=locale).exists():
+ if locale and project_locales.filter(code=locale).exists():
return redirect('pontoon.translate', slug=slug, locale=locale, part=part)
- locale = utils.get_project_locale_from_request(request, project.locales)
+ locale = utils.get_project_locale_from_request(request, project_locales)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment