Example #1
0
def edit_verdict(verdict_id):

    check_has_role(current_user, 'EDITOR')

    verdict = load_or_404(Verdict, verdict_id)
    verdict.modify(request.json)
    ApiHandler.save(verdict)
    return jsonify(as_dict(verdict, includes=VERDICT_INCLUDES)), 201
Example #2
0
def delete_role(role_id):
    check_has_role(current_user, 'admin')

    role = load_or_404(Role, role_id)

    ApiHandler.delete(role)

    db.session.commit()

    return jsonify({"id": role_id}), 201
Example #3
0
def soft_delete_article(article_id):

    check_has_role(current_user, 'editor')

    article = load_or_404(Article, article_id)
    article.soft_delete()

    ApiHandler.save(article)

    return jsonify(as_dict(article)), 201
Example #4
0
def modify_content(content_id):

    check_has_role(current_user, 'EDITOR')

    content = load_or_404(Content, content_id)
    content.modify(request.json)

    ApiHandler.save(content)

    return jsonify(as_dict(content, includes=CONTENT_INCLUDES)), 201
Example #5
0
def soft_delete_content(content_id):

    check_has_role(current_user, 'EDITOR')

    content = load_or_404(Content, content_id)
    content.soft_delete()

    ApiHandler.save(content)

    return jsonify(as_dict(content)), 201
Example #6
0
def modify_article(article_id):

    check_has_role(current_user, 'editor')

    article = load_or_404(Article, article_id)
    article.modify(request.json)

    ApiHandler.save(article)

    return jsonify(as_dict(article, includes=ARTICLE_INCLUDES)), 201
Example #7
0
def post_role():
    check_has_role(current_user, 'admin')

    user = load_or_404(User, request.json['userId'])

    role = Role()
    role.type = request.json['type']
    role.user = user

    ApiHandler.save(role)

    return jsonify(as_dict(role)), 200
def edit_review(review_id):

    check_has_role(current_user, 'reviewer')

    review = load_or_404(Review, review_id)
    review.populate_from_dict(request.json)

    ApiHandler.save(review)

    save_tags(review, request.json.get('tagIds', []))

    return jsonify(as_dict(review, includes=REVIEW_INCLUDES)), 201
Example #9
0
def modify_review(review_id):

    check_has_role(current_user, 'REVIEWER')

    review = load_or_404(Review, review_id)
    review.modify(request.json)

    ApiHandler.save(review)

    save_tags(review, request.json.get('tagIds', []))

    return jsonify(as_dict(review, includes=REVIEW_INCLUDES)), 201
def get_user(user_id):
    check_has_role(current_user, 'admin')

    user = load_or_404(User, user_id)
    return jsonify(as_dict(user, includes=USER_INCLUDES)), 200
Example #11
0
def get_appearance(appearance_id):
    appearance = load_or_404(Appearance, appearance_id)
    return jsonify(as_dict(appearance)), 200
Example #12
0
def get_verdict_appearances(verdict_id):
    verdict = load_or_404(Verdict, verdict_id)
    return jsonify(as_dict(verdict, includes=VERDICT_INCLUDES)), 200
Example #13
0
def get_article(article_id):
    article = load_or_404(Article, article_id)
    return jsonify(as_dict(article, includes=ARTICLE_INCLUDES)), 200
Example #14
0
def get_claim(claim_id):
    claim = load_or_404(Claim, claim_id)
    return jsonify(as_dict(claim)), 200
Example #15
0
def get_review(review_id):
    review = load_or_404(Review, review_id)
    return jsonify(as_dict(review, includes=REVIEW_INCLUDES))
Example #16
0
def get_graph(collection_name, entity_id):
    table_name = inflect.engine().singular_noun(collection_name)
    model = ApiHandler.model_from_table_name(table_name)
    entity = load_or_404(model, entity_id)
    graph = graph_from_entity(entity, shortcutted_types=SHORTCUTTED_TYPES)
    return jsonify(graph), 200
Example #17
0
def get_content(content_id):
    content = load_or_404(Content, content_id)
    return jsonify(as_dict(content, includes=CONTENT_INCLUDES)), 200