--- a/src/ldt/ldt/api/ldt/resources/project.py Mon Jul 20 18:38:38 2015 +0200
+++ b/src/ldt/ldt/api/ldt/resources/project.py Mon Jul 20 19:12:18 2015 +0200
@@ -12,6 +12,7 @@
from tastypie.exceptions import BadRequest
from tastypie.resources import Bundle, ModelResource, ALL
from tastypie.utils import dict_strip_unicode_keys
+from distutils.util import strtobool
from ldt.api.ldt.authentication import (SessionAuthentication,
MultiAuthentication, ApiKeyAuthentication)
@@ -39,8 +40,7 @@
'state' : ALL,
'ldt_id' : ALL,
'title' : ALL
- },
- always_return_data = True
+ }
# In the future version :
# detail_uri_name = 'ldt_id'
@@ -81,11 +81,12 @@
try:
source_proj = Project.objects.get(ldt_id=bundle.data['source'])
except ObjectDoesNotExist:
- return http.HttpNotFound("A model instance matching the provided arguments could not be found.")
+ raise BadRequest("Source project could not be found")
+ publish_bool = False
if check_object_perm_for_user(source_proj, "change_project", request.user):
bundle.data["title"] = bundle.data.get("title", source_proj.title)
bundle.data["description"] = bundle.data.get("description", source_proj.description)
- publish_bool = {'true': True, 'false': False, "0": False, "1": True}.get(bundle.data.get('publish', 'false').lower())
+ publish_bool = bool(strtobool(bundle.data.get('publish', 'false').lower()))
else:
raise BadRequest("User has no right to change the project.")
bundle.obj = source_proj.copy_project(user=request.user, title=bundle.data["title"], description=bundle.data["description"])