remove simplejson in favor of built-in json

api-v2-docs
Nik Nyby 2015-10-08 15:28:17 -04:00
parent 40b72a5edd
commit b7c6f921f8
2 changed files with 14 additions and 15 deletions

View File

@ -8,7 +8,7 @@ from django.template import RequestContext
from django.utils.decorators import method_decorator
from django.core.exceptions import ObjectDoesNotExist
from django.views.decorators.csrf import csrf_exempt
import simplejson
import json
from readthedocs.bookmarks.models import Bookmark
from readthedocs.projects.models import Project
@ -27,7 +27,7 @@ class BookmarkExistsView(View):
def get(self, request):
return HttpResponse(
content=simplejson.dumps(
content=json.dumps(
{'error': 'You must POST!'}
),
content_type='application/json',
@ -41,14 +41,14 @@ class BookmarkExistsView(View):
404 with exists = False in json if no matching bookmark is found.
400 if json data is missing any one of: project, version, page.
"""
post_json = simplejson.loads(request.body)
post_json = json.loads(request.body)
try:
project = post_json['project']
version = post_json['version']
page = post_json['page']
except KeyError:
return HttpResponseBadRequest(
content=simplejson.dumps({'error': 'Invalid parameters'})
content=json.dumps({'error': 'Invalid parameters'})
)
try:
Bookmark.objects.get(
@ -58,13 +58,13 @@ class BookmarkExistsView(View):
)
except ObjectDoesNotExist:
return HttpResponse(
content=simplejson.dumps({'exists': False}),
content=json.dumps({'exists': False}),
status=404,
content_type="application/json"
)
return HttpResponse(
content=simplejson.dumps({'exists': True}),
content=json.dumps({'exists': True}),
status=200,
content_type="application/json"
)
@ -92,7 +92,7 @@ class BookmarkAddView(View):
def get(self, request):
return HttpResponse(
content=simplejson.dumps(
content=json.dumps(
{'error': 'You must POST!'}
),
content_type='application/json',
@ -103,7 +103,7 @@ class BookmarkAddView(View):
"""Add a new bookmark for the current user to point at
``project``, ``version``, ``page``, and ``url``.
"""
post_json = simplejson.loads(request.body)
post_json = json.loads(request.body)
try:
project_slug = post_json['project']
version_slug = post_json['version']
@ -111,7 +111,7 @@ class BookmarkAddView(View):
url = post_json['url']
except KeyError:
return HttpResponseBadRequest(
content=simplejson.dumps({'error': "Invalid parameters"})
content=json.dumps({'error': "Invalid parameters"})
)
try:
@ -119,7 +119,7 @@ class BookmarkAddView(View):
version = project.versions.get(slug=version_slug)
except ObjectDoesNotExist:
return HttpResponseBadRequest(
content=simplejson.dumps(
content=json.dumps(
{'error': "Project or Version does not exist"}
)
)
@ -132,7 +132,7 @@ class BookmarkAddView(View):
page=page_slug,
)
return HttpResponse(
simplejson.dumps({'added': True}),
json.dumps({'added': True}),
status=201,
content_type='application/json'
)
@ -166,14 +166,14 @@ class BookmarkRemoveView(View):
return HttpResponseRedirect(reverse('bookmark_list'))
else:
try:
post_json = simplejson.loads(request.body)
post_json = json.loads(request.body)
project = Project.objects.get(slug=post_json['project'])
version = project.versions.get(slug=post_json['version'])
url = post_json['url']
page = post_json['page']
except KeyError:
return HttpResponseBadRequest(
simplejson.dumps({'error': "Invalid parameters"})
json.dumps({'error': "Invalid parameters"})
)
bookmark = get_object_or_404(
@ -187,7 +187,7 @@ class BookmarkRemoveView(View):
bookmark.delete()
return HttpResponse(
simplejson.dumps({'removed': True}),
json.dumps({'removed': True}),
status=200,
content_type="application/json"
)

View File

@ -48,7 +48,6 @@ django-kombu==0.9.4
django-secure==0.1.2
mimeparse==0.1.3
mock==1.0.1
simplejson==2.3.0
stripe==1.20.2
django-copyright==1.0.0
django-formtools==1.0