Пример #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
Пример #2
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})
Пример #3
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})
Пример #4
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})