Пример #1
0
def update_challenge(jwt, challenge_id):
    data = request.get_json()
    error = False
    try:
        challenge = Challenge.query.get(challenge_id)
        if challenge is None:
            error = True
        else:
            if "task_id" in data and "series_id" in data:
                challenge.task_id = data["task_id"]
                challenge.series_id = data["series_id"]

            DBHelper.update()
    except:
        print(sys.exc_info())
        DBHelper.rollback()
        error = True
    finally:
        DBHelper.close()
    if error:
        abort(404)
    return jsonify({"success": True})
Пример #2
0
def update_series(jwt, series_id):
    error = False
    data = request.get_json()
    try:
        series = Series.query.get(series_id)
        if series is None:
            error = True
        else:
            if "name" in data:
                series.name = data["name"]
            if "description" in data:
                series.state = data["description"]

        DBHelper.update()
    except:
        print(sys.exc_info())
        DBHelper.rollback()
        error = True
    finally:
        DBHelper.close()
    if error:
        abort(404)
    return jsonify({"success": True})
Пример #3
0
def update_task(jwt, task_id):
    data = request.get_json()
    error = False
    try:
        task = Task.query.get(task_id)
        if task is None:
            error = True
        else:
            if "name" in data:
                task.name = data["name"]
            if "state" in data:
                task.state = data["state"]
            if "country" in data:
                task.country = data["country"]
            DBHelper.update()
    except:
        print(sys.exc_info())
        DBHelper.rollback()
        error = True
    finally:
        DBHelper.close()
    if error:
        abort(404)
    return jsonify({"success": True})