Skip to content

Commit

Permalink
Merge pull request #511 from PyBossa/issue-hateoas-breaks-api
Browse files Browse the repository at this point in the history
Fix HATEOAS tags when creating class objects
  • Loading branch information
teleyinex committed May 10, 2013
2 parents 26b2b8d + f5e57b0 commit 0479df7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pybossa/api.py
Expand Up @@ -125,6 +125,11 @@ def post(self):
:returns: The JSON item stored in the DB
"""
data = json.loads(request.data)
# Clean HATEOAS args
if data.get('link'):
data.pop('link')
if data.get('links'):
data.pop('links')
inst = self.__class__(**data)
getattr(require, self.__class__.__name__.lower()).create(inst)
self._update_object(inst)
Expand Down Expand Up @@ -172,6 +177,11 @@ def put(self, id):
data = json.loads(request.data)
# may be missing the id as we allow partial updates
data['id'] = id
# Clean HATEOAS args
if data.get('link'):
data.pop('link')
if data.get('links'):
data.pop('links')
inst = self.__class__(**data)
if (existing is None):
abort(404)
Expand Down

0 comments on commit 0479df7

Please sign in to comment.