jpulgarin/django-tokenapi — pull request #10 by matheussl (2013-06-07 23:15:02+00:00)
Title: Add friendly HTTP responses

Add following HTTP Responses:

* JSONResponseForbidden
* JSONResponseBadRequest
* JSONResponseUnauthorized
* JSONResponseNotAcceptable

Add optional "status" param to response.

```python
def JsonResponse(data, dump=True, status=200):
try:
data['errors']
except KeyError:
data['success'] = True
except TypeError:
pass

return HttpResponse(
json.dumps(data) if dump else data,
mimetype='application/json',
status=status,
)

def JsonError(error_string, status=400):
data = {
'success': False,
'errors': error_string,
}
return JSONResponse(data, status=status)