Beispiel #1
0
 def createEntity(self, entity):
     result = {}
     try:
         DBHelper.insert(entity, True)
         result = {"id": entity.id}
     except:
         DBHelper.rollback()
         print(sys.exc_info())
     finally:
         DBHelper.close()
     return result
Beispiel #2
0
def delete_challenge(jwt, challenge_id):
    error = False
    try:
        challenge = Challenge.query.get(challenge_id)
        if challenge is None:
            error = True
        else:
            DBHelper.delete(challenge)
    except:
        DBHelper.rollback()
        error = True
    finally:
        DBHelper.close()
    if error:
        abort(404)
    return jsonify({"success": True})
Beispiel #3
0
def delete_series(jwt, series_id):
    error = False
    try:
        series = Series.query.get(series_id)
        if series is None:
            error = True
        else:
            DBHelper.delete(series)
    except:
        DBHelper.rollback()
        error = True
    finally:
        DBHelper.close()
    if error:
        abort(404)
    return jsonify({"success": True})
Beispiel #4
0
def delete_task(jwt, task_id):
    error = False
    try:
        task = Task.query.get(task_id)
        if task is None:
            error = True
        else:
            DBHelper.delete(task)
    except:
        DBHelper.rollback()
        erro = True
    finally:
        DBHelper.close()
    if error:
        abort(404)
    return jsonify({"success": True})
Beispiel #5
0
def create_series(jwt):
    data = request.get_json()
    error = False
    try:
        series = Series(name=data["name"], description=data["description"])
        isTest = False
        if "isTest" in data:
            isTest = data["isTest"]
        DBHelper.insert(series)
    except:
        DBHelper.rollback()
        error = True
    finally:
        DBHelper.close()
    if error:
        abort(404)
    return jsonify({"success": True})
Beispiel #6
0
def create_challenge(jwt):
    data = request.get_json()
    error = False
    try:
        challenge = Challenge(task_id=data["task_id"],
                              series_id=data["series_id"])
        isTest = False
        if "isTest" in data:
            isTest = data["isTest"]
        DBHelper.insert(challenge)
    except:
        DBHelper.rollback()
        error = True
    finally:
        DBHelper.close()
    if error:
        abort(404)
    return jsonify({"success": True})
Beispiel #7
0
def create_task(jwt):
    data = request.get_json()
    error = False
    try:
        task = Task(name=data["name"],
                    state=data["state"],
                    country=data["country"])

        isTest = False
        if "isTest" in data:
            isTest = data["isTest"]

        DBHelper.insert(task, isTest)
    except:
        DBHelper.rollback()
        error = True
    finally:
        DBHelper.close()

    if error:
        abort(404)
    return jsonify({"success": True})
Beispiel #8
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})
Beispiel #9
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})
Beispiel #10
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})