Implemented most of the api placeholders #23

Merged
LazIvanS merged 7 commits from feat_9.functional_api into develop 2021-04-28 23:02:43 +03:00
3 changed files with 49 additions and 23 deletions
Showing only changes of commit 3d779590e9 - Show all commits

View File

@@ -11,7 +11,7 @@ if "win" in sys.platform.lower():
else:
DEFAULT_URL = "http://0.0.0.0:8000"
BASE_W = 580
BASE_W = 600
BASE_H = 400
TITLE_APP = "ToDo Application"

View File

@@ -57,7 +57,7 @@ class ToDoList(object):
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
def remove(self, index):
"""
Remove item at index from db
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
Remove item AT INDEX from db
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
"""
item = self.items_[index]
self.items_.remove(item)
@@ -85,10 +85,10 @@ class ToDoList(object):
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
def dispose(self):
print(f"To-do list id '{self.id}' is being disposed of...")
if "DEBUG" in os.environ:
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
return
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
for item in self.items_:
item.dispose()
if "DEBUG" in os.environ:
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
return
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
self.user.lists_delete(self.id)
def sync(self):
@@ -229,11 +229,11 @@ class User(UserApi):
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
def removeUserList(self, id):
"""
Remove existing user to-do list from the serverreturns:
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
Remove existing user to-do list BY ID from the serverreturns:
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
"""
to_remove = [item for item in self.lists_ if item.id == id][0]
self.lists_.remove(to_remove)
if not ("DEBUG" in os.environ):
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
# if not ("DEBUG" in os.environ):
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
to_remove.dispose()
return self.lists_
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:54:31 +03:00 (Migrated from github.com)
Review
            created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```suggestion created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user) ```
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print
AlekseyLobanov commented 2021-04-26 23:55:12 +03:00 (Migrated from github.com)
Review

Кажется, лишний print

Кажется, лишний print

View File

@@ -82,7 +82,7 @@ class ToDoListWidget(tk.Frame):
add = tk.Button(self, text="Добавить заметку", command=self.add_command)
add.pack(side="top")
delete = tk.Button(self, text="Удалить лист", command=placeholder)
delete = tk.Button(self, text="Удалить лист", command=self.master.delete_list)
delete.pack(side="top")
def update(self, itemList=None):
@@ -106,6 +106,17 @@ class ToDoListWidget(tk.Frame):
class WorkSpaceFrame(tk.Frame):
def delete_list(self, *args):
selection = self.listBox.curselection()
cur = selection[0]
self.user.removeUserList(self.lists[cur].id)
self.lists = self.user.fetchUserLists()
self.update_lists()
if len(self.lists) > 1:
self.listBox.selection_set(first=cur - 1)
elif len(self.lists) > 0:
self.listBox.selection_set(first=0)
def __init__(self, user, master=None, url=None) -> None:
"""
Функция инициаизации класса
@@ -154,16 +165,36 @@ class WorkSpaceFrame(tk.Frame):
# add scroll bar to list box
self.listBox.config(yscrollcommand=scrollbar.set)
# fill list box
# init list view
self.update_lists()
# canvas for todo lists
# canvas = tk.Canvas(self)
# canvas.pack(side="left", fill="both", expand=1)
# scrollbar = tk.Scrollbar(self, orient="vertical")
# scrollbar.config(command=canvas.yview)
# scrollbar.pack(side="left", fill="y")
# canvas.configure(yscrollcommand=scrollbar.set)
# todo lists
self.toDoList = ToDoListWidget(self)
# self.toDoList = ToDoListWidget(canvas)
self.toDoList.pack(side="left", fill="y")
# canvas.bind('<Configure>', lambda *argv: print(self.toDoList.winfo_height()))
# canvas.create_window((0,0), window=self.toDoList, anchor='nw')
# select list!
if len(self.lists) > 0:
self.listBox.selection_set(first=0)
self.listBox_selected()
def update_lists(self):
self.listBox.delete(0, "end")
for item in self.lists:
s = f"{str(item)}: {item.created_at.strftime('%Y-%m-%d %H:%M:%S')}"
self.listBox.insert(tk.END, s)
self.listBox.pack()
len(self.lists) > 0 and self.listBox.selection_set(first=0)
# todo lists
self.toToList = ToDoListWidget(self)
self.toToList.pack(side="left", fill="both", expand=1)
return len(self.lists)
def add_list(self, *args):
text = self.add_list_text.get(1.0, "end").strip()
@@ -174,18 +205,13 @@ class WorkSpaceFrame(tk.Frame):
self.lists = self.user.fetchUserLists()
# fill list box
self.listBox.delete(0, "end")
for item in self.lists:
s = f"{str(item)}: {item.created_at.strftime('%Y-%m-%d %H:%M:%S')}"
self.listBox.insert(tk.END, s)
self.listBox.pack()
len(self.lists) > 0 and self.listBox.selection_set(first=0)
self.update_lists()
len(self.lists) > 0 and self.listBox.selection_set(first=len(self.lists) - 1)
def listBox_selected(self, *args):
self.toToList.clear()
self.toDoList.clear()
selection = self.listBox.curselection()
cur = selection[0]
self.toToList.fill(self.lists[cur])
self.toDoList.fill(self.lists[cur])