def update_data(self, data):
        apartment = Apartment.objects(name=data['name']).first()

        if not apartment:
            apartment = Apartment()

        apartment.name = data['name']
        apartment.description = data['description']
        apartment.price = float(data['price'])
        apartment.save()
    def add_apartment(self):
        print("Add Apartment")

        apartment = Apartment()
        apartment.name = get_string("Please, enter apt name: ")
        apartment.description = get_string("Please, enter apt description: ")
        apartment.price = get_price("Please, enter apt price: ")

        apartment.save()

        print("Apartment saved")
Пример #3
0
    def apartments_add(self):
        print(Fore.RED, " Add Apartment ".center(30, "*"), Fore.RESET)

        apartment = Apartment()
        apartment.name = get_string("Please, enter apartment name: ")
        apartment.description = get_string(
            "Please, enter apartment descrintion: ")
        apartment.price = get_price("Please, enter apartment price: ")

        apartment.save()
        print(Fore.RED, " Apartment Saved".center(30, "*"), Fore.RESET)