def get_assets_json(self, story=None, featured=False): if story is None: story = self.object resource = AssetResource() to_be_serialized = {} objects = resource.obj_get_list(self.request, featured=featured, story_id=story.story_id) sorted_objects = resource.apply_sorting(objects) to_be_serialized['objects'] = sorted_objects # Dehydrate the bundles in preparation for serialization. bundles = [resource.build_bundle(obj=obj) for obj in to_be_serialized['objects']] to_be_serialized['objects'] = [resource.full_dehydrate(bundle) for bundle in bundles] to_be_serialized = resource.alter_list_data_to_serialize(request=None, data=to_be_serialized) return resource.serialize(None, to_be_serialized, 'application/json')
def get_assets_json(self, story=None, featured=False): if story is None: story = self.object resource = AssetResource() to_be_serialized = {} bundle = resource.build_bundle() # Set the resource request's user to match this view's # request's user. Otherwise authorization checks won't work bundle.request.user = self.request.user objects = resource.obj_get_list(bundle, featured=featured, story_id=story.story_id) sorted_objects = resource.apply_sorting(objects) to_be_serialized['objects'] = sorted_objects # Dehydrate the bundles in preparation for serialization. bundles = [resource.build_bundle(obj=obj) for obj in to_be_serialized['objects']] to_be_serialized['objects'] = [resource.full_dehydrate(bundle) for bundle in bundles] to_be_serialized = resource.alter_list_data_to_serialize(request=None, data=to_be_serialized) return resource.serialize(None, to_be_serialized, 'application/json')