示例#1
0
 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
示例#2
0
 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
示例#3
0
    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
示例#4
0
    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
示例#5
0
    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
示例#6
0
 def get_unapproved_subscriptions():
     return jsonify({"lots": Lot.get_unapproved_subscriptions()}), 200
示例#7
0
 def get_unapproved_lots():
     return jsonify(Lot.get_all_unapproved_lots()), 200
示例#8
0
 def approve_lot(lot_id):
     Lot.approve(lot_id)
     return RestAPI.message("A lot is now approved"), 201
示例#9
0
    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
示例#10
0
 def get_lot_photo(lot_id):
     return jsonify({"link": Lot.get_photos(lot_id)}), 200
示例#11
0
    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
示例#12
0
 def get_lot(lot_id):
     return jsonify(Lot.get_lot(lot_id)), 200
示例#13
0
 def get_approved_subscriptions():
     return jsonify({'lots': Lot.get_approved_subscriptions()}), 200
示例#14
0
    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
示例#15
0
 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