Exemplo n.º 1
0
def create(rq, app, model, id=None):
	# ID attribute will be added into request payload schema, so it must be
	# removed to prevent rewrites
	if 'id' in rq.pwf.obj_data['values']:
		rq.pwf.obj_data['values'].pop('id', None)

	item = update_object(rq.pwf.model, rq.pwf.model(), rq.pwf.obj_data['values'])
	item.save()

	if rq.pwf.obj_data['update_m2m']:
		item = rq.pwf.model.objects.filter(id = item.id).get()
		item = update_object(rq.pwf.model, item, rq.pwf.obj_data['values'])
		item.save()

	return respond(rq, {'data':item.to_object()})
Exemplo n.º 2
0
def update(user_id):
    resp = helpers.get_response(request)
    has_right_abort(resp, user_id)
    user = helpers.update_object(glob.users, user_id, resp, users_path, null_fields=['password'])
    u = copy.deepcopy(user)
    del u['password']
    return jsonify({"user": u}), 200
Exemplo n.º 3
0
def update(product_id):
    resp = helpers.get_response(request) 
    product = helpers.get_by(glob.products, product_id)
    users.has_right_abort(resp, product['user_id'])
    resp = helpers.get_response(request)
    exclude_field = ['reservePrice', 'startPrice', 'id', 'user_id', 'user']
    null_fields = ['title', 'description', 'buyoutPrice', 'dateLength', 'dateStart']
    product = helpers.update_object(glob.products, product_id, resp, glob.products_path, null_fields=null_fields, exclude_fields=exclude_field)
    return show(product_id)
Exemplo n.º 4
0
def edit(rq, app, model, id):
	item = update_object(rq.pwf.model, rq.pwf.obj, rq.pwf.obj_data['values'])
	item.save()

	return respond(rq, {'data':item.to_object()})