66 lines
1.5 KiB
Python
66 lines
1.5 KiB
Python
import datetime
|
|||
|
|
import asyncio
|
||
|
|
|
||
|
|
class ListOfLists():
|
||
|
|
def __init__(self, app):
|
||
|
|
self.app = app
|
||
|
|
# self.listento = widget_to_listen_to
|
||
|
|
self.data = []
|
||
|
|
# self.widget_data = list_source_object
|
||
|
|
# self.reload()
|
||
|
|
|
||
|
|
# self.widget_data.append({"name": "ToDo", "id": 3, "owner_user_id": 3, "is_active": True, "updated_at": datetime.datetime.now() })
|
||
|
|
|
||
|
|
def reload(self, userid):
|
||
|
|
parameters = {}
|
||
|
|
parameters['userid'] = userid
|
||
|
|
result = self.app.backend.postwait('load_lists', parameters)
|
||
|
|
return result['data']
|
||
|
|
|
||
|
|
|
||
|
|
def on_reloaded(self, bla):
|
||
|
|
print("reloaded")
|
||
|
|
|
||
|
|
def clear(self):
|
||
|
|
self.data = []
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
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 = ListOfLists(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)
|
||
|
|
|