correct hydration of image field for project
authorymh <ymh.work@gmail.com>
Thu, 16 Oct 2014 16:14:28 +0200
changeset 1328 eeab03face47
parent 1327 23bd8fc4619a
child 1329 404fd8b88a57
correct hydration of image field for project
src/ldt/ldt/api/ldt/resources/project.py
--- a/src/ldt/ldt/api/ldt/resources/project.py	Wed Oct 15 16:41:38 2014 +0200
+++ b/src/ldt/ldt/api/ldt/resources/project.py	Thu Oct 16 16:14:28 2014 +0200
@@ -81,6 +81,11 @@
         raise BadRequest("PUT with a list of projects is forbidden.")
     
     
+    def hydrate_image(self, bundle):
+        if bundle.data['image'] and bundle.data['image'].startswith(settings.MEDIA_URL):
+            bundle.data['image'] = bundle.data['image'][len(settings.MEDIA_URL):]
+        return bundle
+    
     # Updates an existing project. Used with post_detail and with a ldt_id in the url
     def post_detail(self, request, **kwargs):
         # Inspired by put_detail but we only update an object. We can not create one.