Beispiel #1
0
def update_dose(user_id):
    users = [dose for dose in user_set if dose['Id'] == user_id]
    if len(users) == 0 or not request.json:
        abort(404)
    user = users[0]
    update_record(user_class, request, user)
    return jsonify(make_public_user(user))
Beispiel #2
0
def update_module(module_id):
    modules = [module for module in module_set if module['Id'] == module_id]
    if len(modules) == 0 or not request.json:
        abort(404)
    module = modules[0]
    update_record(module_class, request, module)
    return jsonify(module)
def update_employee(employee_id):
    employees = [employee for employee in employee_set if employee['Id'] == employee_id]
    if len(employees) == 0 or not request.json:
        abort(404)
    employee = employees[0]
    update_record(employee_class, request, employee)
    return jsonify(employee)
def update_stakeholder(stakeholder_id):
    stakeholders = [stakeholder for stakeholder in stakeholder_set if stakeholder['Id'] == stakeholder_id]
    if len(stakeholders) == 0 or not request.json:
        abort(404)
    stakeholder = stakeholders[0]
    update_record(stakeholder_class, request, stakeholder)
    return jsonify(stakeholder)
Beispiel #5
0
def update_requirement(requirement_id):
    requirements = [requirement for requirement in requirement_set if requirement['Id'] == requirement_id]
    if len(requirements) == 0 or not request.json:
        abort(404)
    requirement = requirements[0]
    update_record(requirement_class, request, requirement)
    return jsonify( requirement)
def update_test(test_id):
    tests = [test for test in test_set if test['Id'] == test_id]
    if len(tests) == 0 or not request.json:
        abort(404)
    test = tests[0]
    update_record(test_class, request, test)
    return jsonify(test)
Beispiel #7
0
def update_record_pro():
    userId = request.form['userId']
    password = request.form['password']
    email = request.form['email']

    db.update_record(password, email, userId)

    result_data = db.view(userId)
    return render_template('view.html', result_data=result_data)
Beispiel #8
0
def update_content(content_id):
    contents = [
        content for content in content_set if content['Id'] == content_id
    ]
    if len(contents) == 0 or not request.json:
        abort(404)
    content = contents[0]
    update_record(content_class, request, content)
    return jsonify(content)
Beispiel #9
0
def update_dose(dose_id):
    doses = [dose for dose in dose_set if dose['Id'] == dose_id]
    if len(doses) == 0 or not request.json:
        abort(404)
    dose = doses[0]
    if dose['UserId'] != get_user_id(auth.username()):
        abort(404)
    update_record(dose_class, request, dose)
    return jsonify(make_public_dose(dose))
Beispiel #10
0
def update_manager(manager_id):
    managers = [
        manager for manager in manager_set if manager['Id'] == manager_id
    ]
    if len(managers) == 0 or not request.json:
        abort(404)
    manager = managers[0]
    update_record(manager_class, request, manager)
    return jsonify(manager)
Beispiel #11
0
    def test_update_record(self):
        # TODO: define behavior for when a record does not exist
        id = db.insert_record(TEST_DB, TEST_TABLE, col1=123, col2='abc')

        db.update_record(TEST_DB, TEST_TABLE, 999, col2='def')
        res = db.get_record(TEST_DB, TEST_TABLE, id)
        self.assertEqual(res, {'rowid': id, 'col1': 123, 'col2': 'abc'})

        db.update_record(TEST_DB, TEST_TABLE, id, col2='def')
        res = db.get_record(TEST_DB, TEST_TABLE, 1)
        self.assertEqual(res, {'rowid': id, 'col1': 123, 'col2': 'def'})
Beispiel #12
0
    def test_update_record(self):
        # TODO: define behavior for when a record does not exist
        id = db.insert_record(TEST_DB,TEST_TABLE,col1=123,col2='abc')

        db.update_record(TEST_DB,TEST_TABLE,999,col2='def')
        res = db.get_record(TEST_DB,TEST_TABLE,id)
        self.assertEqual(res, {'rowid':id,'col1':123,'col2':'abc'})

        db.update_record(TEST_DB,TEST_TABLE,id,col2='def')
        res = db.get_record(TEST_DB,TEST_TABLE,1)
        self.assertEqual(res, {'rowid':id,'col1':123,'col2':'def'})
Beispiel #13
0
    def post(self, database, table, rowid=None):
        """INSERT or UPDATE records"""
        # Prepare request (POST) vars. We only have to do this because
        # we get a dict of lists and our funcs want a dict of single
        # values
        kwargs = {}
        for k, v in self.request.arguments.iteritems():
            kwargs[k] = v[0]

        try:
            if rowid:
                # Perform UPDATE
                json = dumps(db.update_record(database, table, rowid, **kwargs))
                self.write(json)

            else:
                # Perform INSERT
                id = db.insert_record(database, table, **kwargs)
                self.set_status = 201  # HTTP 201 Created
                loc = "/%s/%s/%d" % (database, table, id)
                self.set_header("Location", loc)
                self.write(loc)

        except db.NoSuchDatabase:
            raise HTTPError(404)
Beispiel #14
0
    def post(self, database, table, rowid=None):
        """INSERT or UPDATE records"""
        # Prepare request (POST) vars. We only have to do this because
        # we get a dict of lists and our funcs want a dict of single
        # values
        kwargs = {}
        for k, v in self.request.arguments.iteritems():
            kwargs[k] = v[0]

        try:
            if rowid:
                # Perform UPDATE
                json = dumps(db.update_record(database, table, rowid,
                                              **kwargs))
                self.write(json)

            else:
                # Perform INSERT
                id = db.insert_record(database, table, **kwargs)
                self.set_status = 201  # HTTP 201 Created
                loc = '/%s/%s/%d' % (database, table, id)
                self.set_header('Location', loc)
                self.write(loc)

        except db.NoSuchDatabase:
            raise HTTPError(404)
Beispiel #15
0
def update_record_pro():
    c_code = request.form['c_code']
    c_name = request.form['c_name']
    c_continent = request.form['c_continent']
    c_population = request.form['c_population']
    c_gnp = request.form['c_gnp']
    # 레코드 수정 함수 호출
    db.update_record(c_name, c_continent, c_population, c_gnp, c_code)

    # 레코드 목록 호출
    # country_list = db.get_country_list()
    # return render_template('start3.html', country_list=country_list)

    # # 레코드 목록 호출
    country_list = db.view_record(c_code)
    return render_template('view_record.html', country_list=country_list)
Beispiel #16
0
def get_google_result_and_write_to_db(work,
                                      api_key=None,
                                      return_full_response=False):
    if not 'FIXED_ADDRESS' in work:
        # no address - skip
        return None

    try:
        geocode = get_google_result(work['FIXED_ADDRESS'],
                                    api_key=api_key,
                                    return_full_response=return_full_response)
        return update_record(work, geocode)
    except OverQueryLimit:
        print('Failed - Over the Query Limit. Try again later!')
    except Exception as e:
        print('Failed for some other reason: {}'.format(e.args))
Beispiel #17
0
 def put(self, id):
     data = request.get_data()
     label = request.headers.get('label')
     update_record(id, data, label)
     return data, 201