# HG changeset patch # User ymh # Date 1413468868 -7200 # Node ID eeab03face47e517596c67a5462c5c71dbe228b2 # Parent 23bd8fc4619a507c24a0de6f4605362dbe97e4f8 correct hydration of image field for project diff -r 23bd8fc4619a -r eeab03face47 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.