Create and modify drinks function.
This commit is contained in:
@@ -72,6 +72,11 @@ class GtkUi:
|
|||||||
self.data_client.send_request('update_player', player)
|
self.data_client.send_request('update_player', player)
|
||||||
self.full_reload()
|
self.full_reload()
|
||||||
|
|
||||||
|
def update_drink(self, drink: 'models.Drink'):
|
||||||
|
with util.network_operation(self):
|
||||||
|
self.data_client.send_request('update_drink', drink)
|
||||||
|
self.full_reload()
|
||||||
|
|
||||||
def update_season(self, season: 'models.Season'):
|
def update_season(self, season: 'models.Season'):
|
||||||
with util.network_operation(self):
|
with util.network_operation(self):
|
||||||
self.data_client.send_request('update_season', season)
|
self.data_client.send_request('update_season', season)
|
||||||
|
|||||||
@@ -28,20 +28,18 @@ class BaseDataHandlers:
|
|||||||
|
|
||||||
def do_add_drink(self, entry):
|
def do_add_drink(self, entry):
|
||||||
if entry.get_text():
|
if entry.get_text():
|
||||||
sql.Drink.create(name=entry.get_text(), vol=0)
|
drink = models.Drink({'name': entry.get_text(), 'vol': 0.00})
|
||||||
|
self.app.update_drink(drink)
|
||||||
entry.set_text('')
|
entry.set_text('')
|
||||||
self.app.full_reload()
|
|
||||||
|
|
||||||
def on_drink_name_edited(self, _, index, value):
|
def on_drink_name_edited(self, _, index, value):
|
||||||
row = self.app.ui.get_object('drink_store')[index]
|
row = self.app.ui.get_object('drink_store')[index]
|
||||||
# sql.Drink.update(name=value)\
|
drink = [d for d in self.app.drinks.data if d.id == row[0]][0]
|
||||||
# .where(sql.Drink.id == row[0])\
|
drink.name = value
|
||||||
# .execute()
|
self.app.update_drink(drink)
|
||||||
self.app.full_reload()
|
|
||||||
|
|
||||||
def on_drink_vol_edited(self, _, index, value):
|
def on_drink_vol_edited(self, _, index, value):
|
||||||
row = self.app.ui.get_object('drink_store')[index]
|
row = self.app.ui.get_object('drink_store')[index]
|
||||||
# sql.Drink.update(vol=value) \
|
drink = [d for d in self.app.drinks.data if d.id == row[0]][0]
|
||||||
# .where(sql.Drink.id == row[0]) \
|
drink.vol = value
|
||||||
# .execute()
|
self.app.update_drink(drink)
|
||||||
self.app.full_reload()
|
|
||||||
@@ -2246,6 +2246,7 @@
|
|||||||
<child>
|
<child>
|
||||||
<object class="GtkTreeViewColumn">
|
<object class="GtkTreeViewColumn">
|
||||||
<property name="title" translatable="yes">Name</property>
|
<property name="title" translatable="yes">Name</property>
|
||||||
|
<property name="expand">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText">
|
<object class="GtkCellRendererText">
|
||||||
<property name="editable">True</property>
|
<property name="editable">True</property>
|
||||||
|
|||||||
@@ -24,6 +24,14 @@ class WriteFunctions:
|
|||||||
sql.Player.hex_id: player.hex_id})
|
sql.Player.hex_id: player.hex_id})
|
||||||
.execute())
|
.execute())
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def update_drink(drink: 'models.Drink', *_):
|
||||||
|
(sql.Drink
|
||||||
|
.insert(id=drink.id, name=drink.name, vol=drink.vol)
|
||||||
|
.on_conflict(update={sql.Drink.name: drink.name,
|
||||||
|
sql.Drink.vol: drink.vol})
|
||||||
|
.execute())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def update_season(season: 'models.Season', *_):
|
def update_season(season: 'models.Season', *_):
|
||||||
(sql.Season
|
(sql.Season
|
||||||
|
|||||||
Reference in New Issue
Block a user