예제 #1
0
    def post(self, title):
        if PropertyModel.find_by_title(title):
            return {'message': 'a property by that title doe not exist'}
        data = self.parser.parse_args()
        new_property = PropertyModel(title, **data)
        new_property.save_to_db()

        return new_property.json()
예제 #2
0
    def put(self, title):
        data = self.parser.parse_args()
        my_property = PropertyModel.find_by_title(title)
        if my_property:
            my_property.location = data['location']
            my_property.property_type = data['property_type']
            my_property.description = data['description']
            my_property.landlord_id = data['landlord_id']
            my_property.save_to_db()
            return my_property.json()
        my_property = PropertyModel(title, **data)
        my_property.save_to_db()

        return my_property.json()
예제 #3
0
    def post(self):
        data = Properties.parser.parse_args()

        if PropertyModel.find_by_name(data["name"]):
            return {'Message': 'A property with this name already exists'}, 401

        rentalproperty = PropertyModel(**data)

        try:
            PropertyModel.save_to_db(rentalproperty)
        except:
            return {
                "Message":
                "An Internal Error has Occured. Unable to insert Property"
            }, 500

        return rentalproperty.json(), 201
예제 #4
0
    def post(self):
        #check if is_admin exist if not discontinue function
        claims = get_jwt_claims()
        if not claims['is_admin']:
            return {'Message', "Admin Access Required"}, 401

        data = Properties.parser.parse_args()

        if PropertyModel.find_by_name(data["name"]):
            return {'Message': 'A property with this name already exists'}, 401

        rentalproperty = PropertyModel(**data)

        try:
            PropertyModel.save_to_db(rentalproperty)
        except:
            return {
                "Message":
                "An Internal Error has Occured. Unable to insert Property"
            }, 500

        return rentalproperty.json(), 201