Example #1
0
 def update_user_alert(email, currency, rate_exchange, price):
     Database.update(collection="all_alert",
                     query={
                         "email": email,
                         "currency": currency,
                         "rate_exchange": rate_exchange
                     },
                     data={"$set": {
                         "price": price
                     }})
Example #2
0
class Animals(BoxLayout):
    def __init__(self, *args, **kwargs):
        super(Animals, self).__init__(orientation="vertical")
        global app
        app = App.get_running_app()
        scrollview = ScrollView()
        self.list = MDList()
        self.database = Database(dbtype='sqlite', dbname='animals.db')
        self.rewrite_list()
        scrollview.add_widget(self.list)
        self.add_widget(scrollview)
        button_box = BoxLayout(orientation='horizontal', size_hint_y=0.1)

        #button 1
        btn_animal = MDFlatButton()
        btn_animal.text = "Add new animal"
        btn_animal.font_style = "Button"
        btn_animal.on_release = self.on_create_animal

        # button 2
        btn_type = MDFlatButton()
        btn_type.text = "Add new animal type"
        btn_type.font_style = "Button"
        btn_type.on_release = self.on_create_type

        button_box.add_widget(btn_animal)
        button_box.add_widget(btn_type)
        self.add_widget(button_box)

    def rewrite_list(self):
        self.list.clear_widgets()

        animals = self.database.read_all()

        for animal in animals:
            print(vars(animal))
            self.list.add_widget(MyItem(item=vars(animal)))

    def on_create_animal(self, *args):

        self.dialog = AnimalDialog(id=None)
        self.dialog.open()

    def on_create_type(self, *args):

        self.dialog = TypeDialog()
        self.dialog.open()

    def create(self, animal):

        cr_animal = Animal()
        cr_animal.name = animal['name']
        cr_animal.typee = animal['typee']
        # cr_animal.info = animal['info']
        # cr_animal.photoo = animal['photoo']
        self.database.create_animal(cr_animal)
        self.rewrite_list()

    def update(self, animal):

        up_animal = self.database.read_animal_by_id(animal['id'])
        up_animal.name = animal['name']
        up_animal.typee = animal['typee']
        # up_animal.info = animal['info']
        # up_animal.photoo = animal['photoo']
        self.database.update()
        self.rewrite_list()

    def delete(self, id):

        self.database.delete_animal(id)
        self.rewrite_list()
Example #3
0
 def update_user_email(old_email, email):
     return Database.update(collection="users",
                            query={"email": old_email},
                            data={"$set": {
                                "email": email
                            }})
Example #4
0
 def update_user_email(old_email, email):
     Database.update(collection="users", query={"email": old_email}, data={"$set": {"email": email}})
 def update_user_alert(email, currency, rate_exchange, price):
     Database.update(collection="all_alert",
                     query={"email": email, "currency": currency, "rate_exchange": rate_exchange},
                     data={"$set": {"price": price}})