diff options
author | Jessica Tallon <jessica@megworld.co.uk> | 2014-07-28 23:36:39 +0100 |
---|---|---|
committer | Jessica Tallon <jessica@megworld.co.uk> | 2014-07-30 21:53:52 +0100 |
commit | 5e5d445890c6c555dff48b1613c285da983d71c8 (patch) | |
tree | 6c04e0e8f2d455c3ebae77d3b6c65939dc388025 /mediagoblin/tools/response.py | |
parent | 138d934f014d2c9c54e247298318832e88dceadb (diff) | |
download | mediagoblin-5e5d445890c6c555dff48b1613c285da983d71c8.tar.lz mediagoblin-5e5d445890c6c555dff48b1613c285da983d71c8.tar.xz mediagoblin-5e5d445890c6c555dff48b1613c285da983d71c8.zip |
Fix #927 - Clean up federation code after Elrond's review
- Add json_error and use inplace of json_response where appropriate.
- Add garbage_collection to config spec file.
- Fix bugs in both garbage collection task and test
- Handle /api/whoami when no user logged in and a test for such a case.
- Validate ID is correct and user has comment privilege to comment.
Diffstat (limited to 'mediagoblin/tools/response.py')
-rw-r--r-- | mediagoblin/tools/response.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mediagoblin/tools/response.py b/mediagoblin/tools/response.py index cd99a230..57552963 100644 --- a/mediagoblin/tools/response.py +++ b/mediagoblin/tools/response.py @@ -157,6 +157,14 @@ def json_response(serializable, _disable_cors=False, *args, **kw): return response +def json_error(error_str, status=400, *args, **kwargs): + """ + This is like json_response but takes an error message in and formats + it in {"error": error_str}. This also sets the default HTTP status + code to 400. + """ + return json_response({"error": error_str}, status=status, *args, **kwargs) + def form_response(data, *args, **kwargs): """ Responds using application/x-www-form-urlencoded and returns a werkzeug |