Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
im = get_thumbnail(o_image, "300x300", quality=99, upscale=False)
except:
im = ""
if im:
bundle.data['thumbnail'] = im
bundle.data['hw'] = "%sx%s" % (im.height, im.width)
if self.cur_user:
if Likes.objects.filter(post_id=bundle.data['post_id'],
user=self.cur_user).count():
bundle.data['like_with_user'] = True
post_owner_id = bundle.data['post_owner_id']
bundle.data['post_owner_avatar'] = userdata_cache(post_owner_id, CACHE_AVATAR)
bundle.data['post_owner_user_name'] = userdata_cache(post_owner_id, CACHE_USERNAME)
actors = Notif_actors.objects.filter(notif=id).order_by('id')[:10]
ar = []
for lk in actors:
ar.append(
[
lk.actor.id,
get_username(lk.actor),
daddy_avatar.get_avatar(lk.actor, size=100)
]
)
bundle.data['actors'] = ar
return bundle
except:
im = ""
if im:
bundle.data['thumbnail'] = im
bundle.data['hw'] = "%sx%s" % (im.height, im.width)
if self.cur_user:
if Likes.objects.filter(post_id=bundle.data['post_id'],
user=self.cur_user).count():
bundle.data['like_with_user'] = True
post_owner_id = bundle.data['post_owner_id']
bundle.data['post_owner_avatar'] = userdata_cache(post_owner_id, CACHE_AVATAR)
bundle.data['post_owner_user_name'] = userdata_cache(post_owner_id, CACHE_USERNAME)
actors = Notif_actors.objects.filter(notif=id).order_by('id')[:10]
ar = []
for lk in actors:
ar.append(
[
lk.actor.id,
get_username(lk.actor),
daddy_avatar.get_avatar(lk.actor, size=100)
]
)
bundle.data['actors'] = ar
return bundle
@register.filter
def get_userdata_name(user, size=30):
return userdata_cache(user, 1)
def dehydrate(self, bundle):
user = bundle.data['user_url']
bundle.data['user_avatar'] = userdata_cache(user, CACHE_AVATAR)
bundle.data['user_name'] = userdata_cache(user, CACHE_USERNAME)
return bundle
@register.filter
def get_userdata_avatar(user, size=30):
#print "size is: ", user, size
return userdata_cache(user, 0, size=size)
def dehydrate(self, bundle):
user = bundle.data['user']
bundle.data['user_avatar'] = userdata_cache(user, CACHE_AVATAR, size=300)
return bundle
def dehydrate(self, bundle):
user = bundle.data['user_url']
bundle.data['user_avatar'] = userdata_cache(user, CACHE_AVATAR)
bundle.data['user_name'] = userdata_cache(user, CACHE_USERNAME)
return bundle