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

Fix HATEOAS tags when creating class objects #511

Merged
merged 1 commit into from May 10, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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