def user_set_profile(request, comment_id): if comment_id is None: profile_comment = None else: profile_comment = get_object_or_404(Comment, id=comment_id) request.user.userinfo.profile_image = profile_comment if request.user.userinfo.profile_image is not None: request.user.userinfo.bio_text = 'DISABLED' request.user.userinfo.save() User.avatar_by_username(request.user.username).force() return {'comment_id': comment_id}
def user_set_profile(request, comment_id): if comment_id is None: profile_comment = None else: profile_comment = get_object_or_404(Comment, id=comment_id) request.user.userinfo.profile_image = profile_comment if request.user.userinfo.profile_image is not None: request.user.userinfo.bio_text = profile_comment.reply_text request.user.userinfo.save() User.avatar_by_username(request.user.username).force() return {'comment_id': comment_id}
def avatar_url(user): """ DO NOT CALL THIS FOR ANONYMOUS POSTS. """ key = 'column' avatar, = CachedCall.multicall([ User.avatar_by_username(user.username), ]) if key in avatar: url = avatar[key]['name'] else: key = user.id if user.is_authenticated() else 0 url = _default_avatar_url(key) return url
def _square_avatar(username, image_type, width, height): avatar, = CachedCall.multicall([ User.avatar_by_username(username), ]) if image_type in avatar: url = avatar[image_type]['name'] size = avatar[image_type] else: key = reduce(lambda acc, x: ord(x) + acc, username, 0) url = _default_avatar_url(key) size = {'width':width, 'height':height} return _avatar(url, size, width, height, username)