From f5e57b09440419806b12b0073dce431ac072ac67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Lombra=C3=B1a=20Gonz=C3=A1lez?= Date: Fri, 10 May 2013 14:16:37 +0200 Subject: [PATCH] Fix HATEOAS tags when creating class objects --- pybossa/api.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pybossa/api.py b/pybossa/api.py index 95a9594735..0e6d0cab69 100644 --- a/pybossa/api.py +++ b/pybossa/api.py @@ -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) @@ -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)