コード例 #1
0
ファイル: products.py プロジェクト: Erowlin/Ubid
def destroy(product_id):
    resp = helpers.get_response(request) 
    product = helpers.get_by(glob.products, product_id)
    if product is None:
        return 'No such product', 400
    users.has_right_abort(resp, product['user_id'])
    helpers.delete_object(glob.products, product_id, products_path)
    return 'Delete ok', 200
コード例 #2
0
ファイル: products.py プロジェクト: Erowlin/Ubid
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)