Exemplo n.º 1
0
def get_comments():
    username = g.user.name if g.user else None
    if current_app.config.get('MODERATE_ENABLE', True):
        moderator = is_moderator(g.user)
    else:
        moderator = True
    node_id = request.args.get('node', '')
    data = support.get_data(node_id, username, moderator=moderator)
    return jsonify(**data)
Exemplo n.º 2
0
def get_comments():
    username = g.user.name if g.user else None
    if current_app.config.get('MODERATE_ENABLE', True):
        moderator = is_moderator(g.user)
    else:
        moderator = True
    node_id = request.args.get('node', '')
    data = support.get_data(node_id, username, moderator=moderator)
    return jsonify(**data)
Exemplo n.º 3
0
def get_comments():
    username = request.authorization.username
    is_admin = User.query.filter_by(username=username).first().is_admin
    node_id = request.args.get('node', '')
    data = support.get_data(node_id)
    comments = data.get('comments')
    if comments and not is_admin:
        # Show comments only by current user.
        data['comments'] = [comment for comment in comments if comment['username'] == username]

    return jsonify(**data)
Exemplo n.º 4
0
def get_comments():
    username = request.authorization.username
    is_admin = User.query.filter_by(username=username).first().is_admin
    node_id = request.args.get('node', '')
    data = support.get_data(node_id)
    comments = data.get('comments')
    comments = sorted(comments, key=lambda x: x['time']['iso'], reverse=True)
    if comments and not is_admin:
        # Show comments only by current user.
        comments = [comment for comment in comments if comment['username'] == username]

    data['comments'] = list(comments)
    return jsonify(**data)