aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Doan <andy.doan@linaro.org>2015-06-08 10:20:15 -0500
committerAndy Doan <andy.doan@linaro.org>2015-06-22 14:15:34 -0500
commit2e48aac4730d5d8907e5e81991174ce3620d72b9 (patch)
treee36a50de0c6e9d4036a1b302e2050ceba0fda361
parent334e2398d759a828c820d576975f1e1e6ab2bbdc (diff)
remove need for "url" parameter in check_file_permissions
This is already provided by the Artifact object. Change-Id: I9ce962b700976ba77416162785a4017c0895e40e
-rw-r--r--license_protected_downloads/views.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/license_protected_downloads/views.py b/license_protected_downloads/views.py
index d718fa0..17ae1da 100644
--- a/license_protected_downloads/views.py
+++ b/license_protected_downloads/views.py
@@ -300,8 +300,9 @@ def _handle_dir_list(request, url, path):
return render(request, 'dir_template.html', args)
-def _check_file_permission(request, url, artifact, internal):
- if internal or is_whitelisted(os.path.join('/', url)) or \
+def _check_file_permission(request, artifact, internal):
+ url = artifact.url()
+ if internal or is_whitelisted(url) or \
'key' in request.GET: # If user has a key, default to open
digests = 'OPEN'
else:
@@ -316,6 +317,8 @@ def _check_file_permission(request, url, artifact, internal):
for digest in digests:
if not license_accepted(request, digest):
# Make sure that user accepted each license one by one
+ assert url[0] == '/'
+ url = url[1:] # remove leading /
response = redirect('/license?lic=' + digest + '&url=' + url)
break
return response
@@ -342,7 +345,7 @@ def file_server_get(request, path):
if not file_listed(path, url):
raise Http404
- resp = _check_file_permission(request, url, artifact, internal)
+ resp = _check_file_permission(request, artifact, internal)
if resp:
return resp
return send_file(path)