예제 #1
0
def new_fp():
    """ function that is called when you visit /field_partner/new, creates a new FP """
    data = request.form.to_dict()
    if data is None:
        return create_response(status=400, message="No data provided for new FP")

    if "email" not in data:
        return create_response(status=400, message="No email provided for new FP")
    if "org_name" not in data:
        return create_response(
            status=400, message="No organization name provided for new FP"
        )
    if "pm_id" not in data:
        return create_response(status=400, message="No PM ID provided for new FP")
    if "app_status" not in data:
        return create_response(
            status=400, message="No application status provided for new FP"
        )

    pm_folder_id = PortfolioManager.query.get(data["pm_id"]).folder_id
    data["folder_id"] = create_folder(data["org_name"], pm_folder_id)

    data["due_date"] = time.time() * 1000
    new_fp = FieldPartner(data)
    res = new_fp.to_dict()

    db.session.add(new_fp)
    db.session.commit()

    return create_response(data={"field_partner": res})
def create_mock_document(data):
    data["folderID"] = create_folder(
        DocumentClass.query.get(data["docClassID"]).name,
        FieldPartner.query.get(data["userID"]).folder_id,
    )
    d = Document(data)

    db.session.add(d)
def create_mock_pm(email, name):
    folder_id = create_folder(name)
    pm = PortfolioManager({
        "email": email,
        "name": name,
        "folder_id": folder_id
    })
    db.session.add(pm)
    return pm.id
def create_mock_fp(email, org_name, app_status, pm_id, due_date):
    folder_id = create_folder(org_name,
                              PortfolioManager.query.get(pm_id).folder_id)
    fp = FieldPartner({
        "email": email,
        "org_name": org_name,
        "app_status": app_status,
        "pm_id": pm_id,
        "folder_id": folder_id,
        "due_date": due_date,
    })
    db.session.add(fp)
    return fp.id
예제 #5
0
def new_pm():
    """ function that is called when you visit /portfolio_manager/new, creates a new PM """

    token = request.headers.get("token")
    headers = {"Content-type": "application/x-www-form-urlencoded", "token": token}

    message, info = verify_token(token)

    if message != None:
        return create_response(status=400, message=message)

    if info == "fp":
        return create_response(
            status=400, message="You do not have permission to create new documents!"
        )

    data = request.form.to_dict()

    if data is None:
        return create_response(status=400, message="No data provided for new FP")

    if "email" not in data:
        return create_response(status=400, message="No email provided for new PM")
    if "name" not in data:
        return create_response(status=400, message="No name provided for new PM")

    data["folder_id"] = create_folder(data["name"])

    new_pm = PortfolioManager(data)

    pm_dict = new_pm.to_dict()

    db.session.add(new_pm)
    db.session.commit()

    return create_response(data={"portfolio_manager": pm_dict})