Beispiel #1
0
def delete_contribution_api(contribution_id):
    if 'Authorization' not in request.headers:
        return jsonify('Unauthorized'), 401
    username = decode_auth_token(request.headers['Authorization'])
    if username is None:
        return jsonify('Unauthorized'), 401
    if not Contribution.exists_contribution(repository, contribution_id):
        return jsonify('Not Found'), 404
    contribution = Contribution.get_contribution(repository, contribution_id)
    if contribution.username != username:
        return jsonify('Forbidden'), 403
    Comment.delete_comments_from_contribution(repository, contribution_id)
    Contribution.delete_contribution(repository, contribution_id)
    return jsonify('Successful delete'), 204
Beispiel #2
0
def delete_contribution():
    contribution_id = request.form['con_id']
    Comment.delete_comments_from_contribution(repository, contribution_id)
    Contribution.delete_contribution(repository, contribution_id)
    return redirect('')