コード例 #1
0
def create_design_request_post(req: Request):
    if req.method != 'POST':
        return HTTPMethodNotAllowed("This route only valid for POST request")

    is_logged_in = verify_user_token(req)
    user = DBSession.query(
        m.DoctorUser).filter_by(username=req.session.get('uname')).first()
    if not is_logged_in or not user:
        return HTTPUnauthorized("You must be logged in to view this page")
    data = req.POST
    title = data['title']
    body = data['body']
    files_list = data.getall('files')

    # file_path_list = []
    # if files_list:
    #     file_path_list = store_file_view(files_list)

    if data and title and body:
        new_design_request = m.DesignPost(title, body, [], user,
                                          datetime.datetime.now())

        DBSession.add(new_design_request)
        transaction.manager.commit()

        return HTTPFound(req.params.get('return', '/'))
    else:
        return HTTPBadRequest("Malformed request")
コード例 #2
0
def create_print_request_post(req: Request):
    if req.method != 'POST':
        return HTTPMethodNotAllowed("This route only valid for POST request")
    is_logged_in = verify_user_token(req)
    user = DBSession.query(
        m.DoctorUser).filter_by(username=req.session.get('uname')).first()
    if not is_logged_in or not user:
        return HTTPUnauthorized("You must be logged in to view this page")

    data = req.POST
    title = data.get('title')
    # body = data.get('print-notes')
    num_parts = data.get('num-items')
    date_needed = datetime.datetime.strptime(data.get('completion-date'),
                                             '%Y-%m-%d')
    files_list = data.getall('files')

    file_path_list = []
    if files_list:
        file_path_list = store_file_view(files_list)

    if title and num_parts and date_needed:
        new_print_request = m.PrintPost(title, "", file_path_list, user,
                                        date_needed, num_parts)

        DBSession.add(new_print_request)
        transaction.manager.commit()

        return HTTPFound(req.params.get('return', '/'))
    else:
        return HTTPBadRequest("Malformed request")
コード例 #3
0
def submit_design_response_post(req: Request):
    if req.method != 'POST':
        return HTTPMethodNotAllowed("This route only valid for POST request")

    post = DBSession.query(
        m.DesignPost).filter_by(post_id=req.matchdict['post_id']).first()
    data = req.POST
    body = data.get('print-notes')
    files_list = data.getall('files')

    file_path_list = []
    if files_list:
        file_path_list = store_file_view(files_list)

    if body and file_path_list:
        new_design_submission = m.DesignResponse(body, file_path_list,
                                                 req.session.get('uname'),
                                                 post)

        DBSession.add(new_design_submission)
        transaction.manager.commit()

        return HTTPFound(req.params.get('return', '/'))
    else:
        return HTTPBadRequest("Malformed request")
コード例 #4
0
def register_fab_post(req: Request):
    if req.method != 'POST':
        return HTTPMethodNotAllowed("This route only valid for POST request")

    data = req.POST
    uname = data.get('uname')
    passwd = data.get('password')
    email = data.get('email')
    fname = data.get('fname')
    lname = data.get('lname')
    country = data.get('country')
    state = data.get('state')
    city = data.get('city')
    printer_model = data.get('printer model')
    print_quality = data.get('print quality')

    if uname and passwd and email and fname and lname and country and state and city and printer_model and print_quality:
        new_fab = m.FabUser(uname, passwd, email, fname, lname, country, state,
                            city, printer_model, print_quality)
        dbs = DBSession()
        dbs.add(new_fab)
        new_token = new_fab.refresh_session()
        transaction.manager.commit()

        req.session['uname'] = uname
        req.session['session_token'] = new_token

        return HTTPFound(req.params.get('return', '/'))
    else:
        return HTTPBadRequest("Malformed request")
コード例 #5
0
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)

    with transaction.manager:
        user = FabUser("testuser", "test", "*****@*****.**", "Bob", "Bobson", "I am a human doing human things",
                       "USA", "California", "Los Angeles", "ender3", "excellent", "/static/human.png")
        DBSession.add(user)
        transaction.manager.commit()

        doc = DoctorUser("doccroc", "test", "*****@*****.**", "Doc", "Croc", "I really like reptiles", "USA", "Florida", "Orlando",
                         "Orlando Reptile Hospital", "University of Tampa", "Tail Repairs",
                         "/static/imgs/doctor.jpg")
        DBSession.add(doc)
        transaction.manager.commit()

        print_post = PrintPost("hello make me a tail", "pls make tail thx", ["tail.stl"], doc, datetime.now(),
                               100)
        DBSession.add(print_post)
        transaction.manager.commit()

        print_commitment = PrintCommitment("hello yes i have made tail", 75, 10, ["tail_print.png"], user, print_post)
        DBSession.add(print_commitment)
        transaction.manager.commit()
コード例 #6
0
def submit_print(req: Request):
    if req.method != 'POST':
        return HTTPMethodNotAllowed("This route only valid for POST request")

    post = DBSession.query(
        m.PrintPost).filter_by(post_id=req.matchdict['post_id']).first()
    data = req.POST
    num_parts = data.get('num_items')
    date_completed = datetime.datetime.strptime(data.get('completion-date'),
                                                '%Y-%m-%d')

    if num_parts and date_completed:
        new_print_submission = m.PrintCommitment("", num_parts, date_completed,
                                                 req.session['uname'], post)
        dbs = DBSession()
        dbs.add(new_print_submission)
        transaction.manager.commit()

        return HTTPFound(req.params.get('return', '/'))
    else:
        return HTTPBadRequest("Malformed request")
コード例 #7
0
def register_doctor_post(req: Request):
    dbs = DBSession()
    if req.method != 'POST':
        return HTTPMethodNotAllowed("This route only valid for POST request")

    print("are we in boys?")
    data = req.POST
    uname = data.get('uname')
    passwd = data.get('passwd')
    email = data.get('email')
    fname = data.get('fname')
    lname = data.get('lname')
    country = data.get('country')
    state = data.get('state')
    city = data.get('city')
    hospital = data.get('hospital')
    alma_mater = data.get('alma_mater')
    spec = data.get('specialization')
    bio = data.get('bio')
    print("we in boys")

    if uname and passwd and email and fname and lname and country and state and city and hospital and alma_mater \
            and spec and bio:
        new_doctor = m.DoctorUser(uname, passwd, email, fname, lname, bio,
                                  country, state, city, hospital, alma_mater,
                                  spec, '/static/profile_default.png')
        dbs.add(new_doctor)
        new_token = new_doctor.refresh_session()
        transaction.manager.commit()

        req.session['uname'] = uname
        req.session['session_token'] = new_token

        return HTTPFound(req.params.get('return', '/'))
    else:
        print("gosh darn it")
        return HTTPBadRequest("Malformed request")