Skip to content
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

arrange_contents: fix calling without the path parameter #268

Merged
merged 2 commits into from
Sep 2, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/dashboard/src/components/filesystem_ajax/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,23 @@ def contents(request):
return helpers.json_response(response)

def arrange_contents(request):
base_path = base64.b64decode(request.GET.get('path', DEFAULT_ARRANGE_PATH))

# Must indicate that base_path is a folder by ending with /
if not base_path.endswith('/'):
base_path += '/'
path = request.GET.get('path')
if path is not None:
try:
base_path = base64.b64decode(path)
except TypeError:
response = {
'success': False,
'message': 'Could not base64-decode provided path: {}'.format(path),
}
helpers.json_response(response, status_code=400)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.djangoproject.com/en/1.8/ref/request-response/#jsonresponse-objects :o Probably not for this PR but I'd like to replace helpers.json_response with JsonResponse

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, in the future let's make that change all at once.

# Must indicate that base_path is a folder by ending with /
if not base_path.endswith('/'):
base_path += '/'

if not base_path.startswith(DEFAULT_ARRANGE_PATH):
if not base_path.startswith(DEFAULT_ARRANGE_PATH):
base_path = DEFAULT_ARRANGE_PATH
else:
base_path = DEFAULT_ARRANGE_PATH

# Query SIP Arrangement for results
Expand Down