Exemple #1
0
def delete_skill_by_id(skill_id):
    response = User.check_token(request)
    if response == 200 \
            and User.query.filter_by(token=request.headers.get('Authorization')).first().email == Config.ADMIN_EMAIL:
        skill_to_be_deleted = Skill.query.filter_by(id_skill=skill_id).first()
        if skill_to_be_deleted is None:
            return bad_request(ErrorMessages.API_DELETE_SKILL_FAILURE)
        if Skill.delete_skill(skill_to_be_deleted.skill_name):
            response = jsonify(Config.API_DELETION_SUCCESS)
            response.status_code = 200
            return response
        else:
            return bad_request(ErrorMessages.API_DELETE_SKILL_FAILURE)
    return error_response(response if response != 200 else 401)
Exemple #2
0
def delete():
    if request.method == 'POST':
        Skill.delete_skill(list(request.form.keys())[0])
    return redirect(url_for('content.index'))