예제 #1
0
 def full_dehydrate(self, bundle, for_list=False):
     bundle = ModelResource.full_dehydrate(self, bundle, for_list=for_list)
     bundle.related_obj = self
     if for_list is True:
         fk = fields.ForeignKey(I4pProjectListResource, attribute="master", full=True)
         bundle.data["project"] = fk.dehydrate(bundle)
     return bundle
예제 #2
0
 def full_dehydrate(self, bundle, for_list=False):
     bundle = ModelResource.full_dehydrate(self, bundle, for_list)
     if bundle.obj.picture:
         thumbnailer = get_thumbnailer(bundle.obj.picture)
         thumbnail_options = {
             'size': (ResizeThumbApi.width, ResizeThumbApi.height)
         }
         bundle.data["thumb"] = thumbnailer.get_thumbnail(
             thumbnail_options).url
     else:
         bundle.data["thumb"] = None
     if for_list is False:
         bundle.data["tags"] = [
             tag.name for tag in Tag.objects.get_for_object(bundle.obj)
         ]
         if (bundle.obj.picture):
             thumbnail_options = {
                 'size': (ResizeDisplay.width, ResizeDisplay.width)
             }
             bundle.data["image"] = thumbnailer.get_thumbnail(
                 thumbnail_options).url
         else:
             bundle.data["image"] = None
         try:
             bundle.data["article"] = Article.get_for_object(
                 bundle.obj).render()
         except ArticleForObject.DoesNotExist:
             bundle.data["article"] = None
     return bundle
예제 #3
0
def bundleItemCollection(modelResource, request, items):
    item_list = []
    for item in items:
        bundle = ModelResource.build_bundle(modelResource, obj=item, request=request)
        bundle = ModelResource.full_dehydrate(modelResource, bundle)
        item_list.append(bundle)
    return item_list;
예제 #4
0
 def full_dehydrate(self, bundle, for_list=False):
     bundle = ModelResource.full_dehydrate(self, bundle, for_list=for_list)
     bundle.related_obj = self
     if for_list is True:
         fk = fields.ForeignKey(I4pProjectListResource,
                                attribute='master',
                                full=True)
         bundle.data['project'] = fk.dehydrate(bundle)
     return bundle
 def full_dehydrate(self, bundle, for_list=False):
     bundle = ModelResource.full_dehydrate(self, bundle, for_list)
     if bundle.obj.picture:
         thumbnailer = get_thumbnailer(bundle.obj.picture)
         thumbnail_options = {'size': (ResizeThumbApi.width, ResizeThumbApi.height)}
         bundle.data["thumb"] = thumbnailer.get_thumbnail(thumbnail_options).url
     else:
         bundle.data["thumb"] = None
     if for_list is False:
         bundle.data["tags"] = [tag.name for tag in Tag.objects.get_for_object(bundle.obj)]
         if(bundle.obj.picture):
             thumbnail_options = {'size': (ResizeDisplay.width, ResizeDisplay.width)}
             bundle.data["image"] = thumbnailer.get_thumbnail(thumbnail_options).url
         else:
             bundle.data["image"] = None
         try:
             bundle.data["article"] = Article.get_for_object(bundle.obj).render()
         except ArticleForObject.DoesNotExist:
             bundle.data["article"] = None
     return bundle
예제 #6
0
 def full_dehydrate(self, bundle, for_list=False):
     if len(bundle.obj.all()) > 0:
         bundle.obj = bundle.obj.all()[0]
     return ModelResource.full_dehydrate(self, bundle, for_list=for_list)
예제 #7
0
 def full_dehydrate(self, bundle, for_list=False):
     if len(bundle.obj.all()) > 0:
         bundle.obj = bundle.obj.all()[0]
     return ModelResource.full_dehydrate(self, bundle, for_list=for_list)