Exemplo n.º 1
0
def timeline_skin(user, post):
    if (not post):
        return get_unavailable_post('timeline')
    return {
        'type': 'timeline',
        'id': post.post_id,
        'background': post.background,
        'timeline_name': post.timeline_name,
        'author': {
            'name': (post.author.name) if
            (post.author.name != None) else "Default User",
            'username': post.author.username,
            'icon': post.author.icon
        },
    }
Exemplo n.º 2
0
def blog_skin(user, post):
    if (not post):
        return get_unavailable_post('blog')
    return {
        'type': 'blog',
        'id': post.post_id,
        'background': post.background,
        'blog_name': post.blog_name,
        'age': calculate_post_age(post.created_on),
        'author': {
            'name': (post.author.name) if
            (post.author.name != None) else "Default User",
            'username': post.author.username,
            'icon': post.author.icon
        },
    }
Exemplo n.º 3
0
def blog_body(user, post):
    if (not post):
        return {'blog': get_unavailable_post('blog')}
    return {
        'type':
        'blog',
        'id':
        post.post_id,
        'blog_name':
        post.blog_name,
        'background':
        post.background,
        'author': {
            'name': (post.author.name) if
            (post.author.name != None) else "Default User",
            'username': post.author.username,
            'icon': post.author.icon
        },
        'comments':
        len(post.comments),
        'likes':
        len(post.likes),
        'reshares':
        len(post.reshares),
        'content':
        post.content,
        'age':
        calculate_post_age(post.created_on),
        'isLiked':
        True if
        (post.post_id in [x.post_id for x in user.liked_posts]) else False,
        'isReshared':
        True if (post.post_id in [x.og_post_id
                                  for x in user.reshared_posts]) else False,
        'isBookmarked':
        True if (post.post_id in [x.post_id
                                  for x in user.bookmarked_posts]) else False,
        # 'isEdited': post.isEdited
    }
Exemplo n.º 4
0
def shareable(user, post):
    if (not post):
        return get_unavailable_post('shareable')
    return {
        'type':
        'shareable',
        'id':
        post.post_id,
        'author': {
            'name': (post.author.name) if
            (post.author.name != None) else "Default User",
            'username': post.author.username,
            'icon': post.author.icon
        },
        'content':
        post.content,
        'likes':
        len(post.likes),
        'reshares':
        len(post.reshares),
        'age':
        calculate_post_age(post.created_on),
        'name':
        post.name,
        'link':
        post.link,
        'isLiked':
        True if
        (post.post_id in [x.post_id for x in user.liked_posts]) else False,
        'isReshared':
        True if (post.post_id in [x.og_post_id
                                  for x in user.reshared_posts]) else False,
        'isBookmarked':
        True if (post.post_id in [x.post_id
                                  for x in user.bookmarked_posts]) else False,
        # 'isEdited': post.isEdited
    }