def set_security_checked(lot_id): if request.type == 'PUT': Lot.set_security_checked(lot_id, True) return RestAPI.message('Lot\'s security is now checked'), 201 if request.type == 'DELETE': Lot.set_security_checked(lot_id, False) return RestAPI.message('Lot\'s security is no more checked'), 201
def set_security_checked(lot_id): if request.type == "PUT": Lot.set_security_checked(lot_id, True) return RestAPI.message("Lot's security is now checked"), 201 if request.type == "DELETE": Lot.set_security_checked(lot_id, False) return RestAPI.message("Lot's security is no more checked"), 201
def add_lot_photo(lot_id): if not Lot.can_user_edit(user.email(), lot_id): raise NoPermissionError() a = request.files resp = { filename: Lot.add_photo(request.files[filename], lot_id) for filename in request.files } return jsonify(resp), 201
def update_lot(lot_id): if not Lot.can_user_edit(user.email(), lot_id): raise NoPermissionError() if not request.json: raise NoJsonError() data_available = [ "name", "amount", "currency", "term", "return_way", "security", "percentage", "form", "commentary", ] for data in data_available: if data in request.json: Lot.update_data(lot_id, data, request.json[data]) return RestAPI.message("A lot is changed"), 201
def update_lot(lot_id): if not Lot.can_user_edit(user.email(), lot_id): raise NoPermissionError() if not request.json: raise NoJsonError() data_available = [ 'name', 'amount', 'currency', 'term', 'return_way', 'security', 'percentage', 'form', 'commentary' ] for data in data_available: if data in request.json: Lot.update_data(lot_id, data, request.json[data]) return RestAPI.message('A lot is changed'), 201
def get_unapproved_subscriptions(): return jsonify({"lots": Lot.get_unapproved_subscriptions()}), 200
def get_unapproved_lots(): return jsonify(Lot.get_all_unapproved_lots()), 200
def approve_lot(lot_id): Lot.approve(lot_id) return RestAPI.message("A lot is now approved"), 201
def remove_lot_photo(lot_id, photo_id): if not Lot.can_user_edit(user.email(), lot_id): raise NoPermissionError() return jsonify(Lot.remove_photo(lot_id, photo_id)), 201
def get_lot_photo(lot_id): return jsonify({"link": Lot.get_photos(lot_id)}), 200
def restore_lot(lot_id): if not Lot.can_user_edit(user.email(), lot_id): raise NoPermissionError() Lot.restore_lot(lot_id) return RestAPI.message("A lot is restored"), 201
def get_lot(lot_id): return jsonify(Lot.get_lot(lot_id)), 200
def get_approved_subscriptions(): return jsonify({'lots': Lot.get_approved_subscriptions()}), 200
def add_lot_photo(lot_id): if not Lot.can_user_edit(user.email(), lot_id): raise NoPermissionError() return jsonify(Lot.add_photo(request.files['file'], lot_id)), 201
def delete_lot(lot_id): if not Lot.can_user_edit(user.email(), lot_id): raise NoPermissionError() Lot.delete_lot(lot_id) return RestAPI.message('A lot is deleted'), 201