aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky <paul.sokolovsky@linaro.org>2015-09-03 15:55:09 +0300
committerLinaro Code Review <review@review.linaro.org>2015-09-03 14:42:09 +0000
commit154c527b7fd0dc0447b093793a9cb7e316ad85ac (patch)
tree26fa1805398633bfef2294c0d7720999de74ad9a
parent070cc39885e421e0976fdd7a207ec1ffdd3a15d9 (diff)
downloadlinaro-license-protection-154c527b7fd0dc0447b093793a9cb7e316ad85ac.tar.gz
views: group_auth_failed_response(): Fix construction of textual response.
Previous version missed a comma in case of >1 groups: "You need to be the member of one of the lmg-member-only team-android-engineering or team-qa-services groups." Change-Id: I85f381e8547b3538202341f167f56b1a1902ca69
-rw-r--r--license_protected_downloads/tests/test_views.py2
-rw-r--r--license_protected_downloads/views.py6
2 files changed, 3 insertions, 5 deletions
diff --git a/license_protected_downloads/tests/test_views.py b/license_protected_downloads/tests/test_views.py
index 3d6e872..2d10920 100644
--- a/license_protected_downloads/tests/test_views.py
+++ b/license_protected_downloads/tests/test_views.py
@@ -633,7 +633,7 @@ class ViewHelpersTests(BaseServeViewTest):
self.assertTrue(isinstance(response, HttpResponse))
self.assertContains(
response,
- "You need to be the member of one of the linaro batman, catwoman "
+ "You need to be the member of one of the linaro, batman, catwoman "
"or joker groups",
status_code=403)
diff --git a/license_protected_downloads/views.py b/license_protected_downloads/views.py
index e5a87cc..08c101b 100644
--- a/license_protected_downloads/views.py
+++ b/license_protected_downloads/views.py
@@ -98,10 +98,8 @@ def group_auth_failed_response(request, auth_groups):
"""Construct a nice response detailing list of auth groups that
will allow access to the requested file."""
if len(auth_groups) > 1:
- groups_string = "one of the " + auth_groups.pop(0) + " "
- if len(auth_groups) > 1:
- groups_string += ", ".join(auth_groups[0:-1])
-
+ groups_string = "one of the "
+ groups_string += ", ".join(auth_groups[0:-1])
groups_string += " or " + auth_groups[-1] + " groups"
else:
groups_string = "the " + auth_groups[0] + " group"