60 lines
1.4 KiB
Python
60 lines
1.4 KiB
Python
import datetime
|
|
import asyncio
|
|
import toga
|
|
from toga.sources import ListSource
|
|
|
|
class ListsData():
|
|
def __init__(self, app):
|
|
self.app = app
|
|
self.data_widget = None
|
|
|
|
def reload(self):
|
|
curent_userid = self.app.configuration.get_userid()
|
|
if curent_userid > 0:
|
|
parameters = {}
|
|
parameters['userid'] = curent_userid
|
|
result = self.app.backend.postwait('load_lists', parameters)
|
|
for item in result['data']:
|
|
self.data_widget.append(item)
|
|
|
|
|
|
|
|
|
|
class List():
|
|
id = 0
|
|
updated_at = None
|
|
owner_user_id = 0
|
|
name = ''
|
|
is_active = True
|
|
|
|
|
|
class Item():
|
|
id = 0
|
|
updated_at = None
|
|
listofitems_id = 0
|
|
label = ''
|
|
quantity = 0
|
|
unit = ''
|
|
label_alt1 = ''
|
|
label_alt2 = ''
|
|
is_checked = False
|
|
is_suggestion = False
|
|
category = ''
|
|
|
|
class LocalData():
|
|
def __init__(self, app):
|
|
self.app = app
|
|
self.curent_userid = 0
|
|
self.current_listid = 0
|
|
self.lists = ListsData(app)
|
|
|
|
def set_user(self, userid):
|
|
if userid != self.curent_userid:
|
|
self.lists.clear()
|
|
self.curent_userid = userid
|
|
|
|
def reload_list(self):
|
|
self.curent_userid = self.app.configuration.get_userid()
|
|
if self.curent_userid > 0:
|
|
return self.lists.reload(self.curent_userid)
|
|
|