From ad6a8a4e3cef7647b3d596b8cb88d46de4f8e81b Mon Sep 17 00:00:00 2001 From: s460932 Date: Mon, 21 Dec 2020 11:33:45 +0100 Subject: [PATCH 1/3] Intial work on projects view --- client/app.py | 80 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/client/app.py b/client/app.py index d16504d..6f712b5 100644 --- a/client/app.py +++ b/client/app.py @@ -8,7 +8,7 @@ FONT_LARGE = ("Verdana", 20) URL = "http://localhost:8000/api/authenticate" URL_REGISTER = "http://localhost:8000/api/register" URL_PROFILE = "http://localhost:8000/api/profile" - +URL_PROJECTS = "http://localhost:8000/api/projects" class SmartPicasso(tk.Tk): @@ -95,7 +95,7 @@ class MainView(tk.Frame): tk.Frame.__init__(self, parent) self.frames = {} self.token = '' - for F in (ProfileView,): + for F in (ProfileView, ProjectsView, ProjectsAddView): frame = F(parent, controller) self.frames[F] = frame @@ -105,11 +105,21 @@ class MainView(tk.Frame): label.pack(pady=10, padx=10) label_u = tk.Label(self, text="Main menu", font=FONT) label_u.pack(pady=10, padx=10) + + button_projects = tk.Button(self, text="Projects", font=FONT, + command=lambda: self.show_frame(ProjectsView)) + button_projects.pack() + + button_projects2 = tk.Button(self, text="Projects Add", font=FONT, + command=lambda: self.show_frame(ProjectsAddView)) + button_projects2.pack() + button_profile = tk.Button(self, text="My profile", font=FONT, command=lambda: self.show_frame(ProfileView)) button_profile.pack() + def show_frame(self, view): frame = self.frames[view] frame.tkraise() @@ -223,6 +233,72 @@ class ProfileView(tk.Frame): self.label_first_name['text'] = response['profile']['first_name'] self.label_last_name['text'] = response['profile']['last_name'] +class ProjectsView(tk.Frame): + + def __init__(self, parent, controller): + tk.Frame.__init__(self, parent) + self.token = '' + label = tk.Label(self, text="SmartPicasso", font=FONT_LARGE) + label.pack(pady=10, padx=10) + button_add = tk.Button(self, text="Add project", font=FONT, + command=lambda: controller.show_frame(ProjectsAddView, self.token)) + button_add.pack() + + button_back = tk.Button(self, text="Back", font=FONT, + command=lambda: controller.show_frame(MainView, self.token)) + button_back.pack() + label0 = tk.Label(self, text='Projects:', font=FONT) + label0.pack() + + def start(self): + headers = {'Authorization': 'Bearer ' + self.token} + resp = requests.get(URL_PROJECTS, headers=headers) + response = resp.json() + print(response) + for projects in response: + button_proj = tk.Button(self, text=projects['name'], font=FONT) + button_proj.pack() + +class ProjectsAddView(tk.Frame): + + def __init__(self, parent, controller): + tk.Frame.__init__(self, parent) + self.token = '' + + label0 = tk.Label(self, text='Project name:', font=FONT) + label0.pack() + + input0 = tk.Entry(self) + input0.pack() + + button_add = tk.Button(self, text="Confirm and add", font=FONT, + command=lambda: self.addproject(controller, input0.get())) + button_add.pack() + + button_back = tk.Button(self, text="Back", font=FONT, + command=lambda: controller.show_frame(ProjectsView)) + button_back.pack() + + def start(self): + print("ok") + + def addproject(self, controller, projectname): + headers = {'Authorization': 'Bearer ' + self.token} + data = { + "name": str(projectname) + } + print(data) + response = requests.post(URL_PROJECTS, json=data, headers=headers) + print(response) + if response.status_code == 201: + response = response.json() + controller.show_frame(MainView) + else: + print("sth wrong") + bad_pass_label = tk.Label(self, text='Something went wrong!', font=FONT) + bad_pass_label.pack() + return () + app = SmartPicasso() app.mainloop() -- 2.20.1 From 0aad49aaec89b5f62e4b697676b309bafbf95e53 Mon Sep 17 00:00:00 2001 From: s460930 Date: Mon, 21 Dec 2020 14:23:52 +0100 Subject: [PATCH 2/3] SMART-49 implemented add project view --- client/app.py | 54 ++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/client/app.py b/client/app.py index 6f712b5..941edb5 100644 --- a/client/app.py +++ b/client/app.py @@ -10,6 +10,7 @@ URL_REGISTER = "http://localhost:8000/api/register" URL_PROFILE = "http://localhost:8000/api/profile" URL_PROJECTS = "http://localhost:8000/api/projects" + class SmartPicasso(tk.Tk): def __init__(self, *args, **kwargs): @@ -96,7 +97,7 @@ class MainView(tk.Frame): self.frames = {} self.token = '' for F in (ProfileView, ProjectsView, ProjectsAddView): - frame = F(parent, controller) + frame = F(parent, controller, self) self.frames[F] = frame @@ -105,21 +106,15 @@ class MainView(tk.Frame): label.pack(pady=10, padx=10) label_u = tk.Label(self, text="Main menu", font=FONT) label_u.pack(pady=10, padx=10) - - button_projects = tk.Button(self, text="Projects", font=FONT, - command=lambda: self.show_frame(ProjectsView)) - button_projects.pack() - - button_projects2 = tk.Button(self, text="Projects Add", font=FONT, - command=lambda: self.show_frame(ProjectsAddView)) - button_projects2.pack() + button_projects = tk.Button(self, text="Projects", font=FONT, + command=lambda: self.show_frame(ProjectsView)) + button_projects.pack() button_profile = tk.Button(self, text="My profile", font=FONT, command=lambda: self.show_frame(ProfileView)) button_profile.pack() - def show_frame(self, view): frame = self.frames[view] frame.tkraise() @@ -202,7 +197,7 @@ class RegisterView(tk.Frame): class ProfileView(tk.Frame): - def __init__(self, parent, controller): + def __init__(self, parent, controller, main_view_controller): tk.Frame.__init__(self, parent) self.token = '' label = tk.Label(self, text="SmartPicasso", font=FONT_LARGE) @@ -233,24 +228,29 @@ class ProfileView(tk.Frame): self.label_first_name['text'] = response['profile']['first_name'] self.label_last_name['text'] = response['profile']['last_name'] + class ProjectsView(tk.Frame): - def __init__(self, parent, controller): + def __init__(self, parent, controller, main_view_controller): tk.Frame.__init__(self, parent) self.token = '' + self.projects_buttons = [] label = tk.Label(self, text="SmartPicasso", font=FONT_LARGE) label.pack(pady=10, padx=10) button_add = tk.Button(self, text="Add project", font=FONT, - command=lambda: controller.show_frame(ProjectsAddView, self.token)) + command=lambda: main_view_controller.show_frame(ProjectsAddView)) button_add.pack() - + button_back = tk.Button(self, text="Back", font=FONT, - command=lambda: controller.show_frame(MainView, self.token)) + command=lambda: controller.show_frame(MainView, self.token)) button_back.pack() label0 = tk.Label(self, text='Projects:', font=FONT) label0.pack() def start(self): + for button in self.projects_buttons: + button.destroy() + self.projects_buttons = [] headers = {'Authorization': 'Bearer ' + self.token} resp = requests.get(URL_PROJECTS, headers=headers) response = resp.json() @@ -258,41 +258,43 @@ class ProjectsView(tk.Frame): for projects in response: button_proj = tk.Button(self, text=projects['name'], font=FONT) button_proj.pack() - + self.projects_buttons.append(button_proj) + + class ProjectsAddView(tk.Frame): - def __init__(self, parent, controller): + def __init__(self, parent, controller, main_view_controller): tk.Frame.__init__(self, parent) self.token = '' - + label0 = tk.Label(self, text='Project name:', font=FONT) label0.pack() - + input0 = tk.Entry(self) input0.pack() - + button_add = tk.Button(self, text="Confirm and add", font=FONT, - command=lambda: self.addproject(controller, input0.get())) + command=lambda: self.add_project(main_view_controller, input0.get())) button_add.pack() button_back = tk.Button(self, text="Back", font=FONT, - command=lambda: controller.show_frame(ProjectsView)) + command=lambda: main_view_controller.show_frame(ProjectsView)) button_back.pack() def start(self): print("ok") - def addproject(self, controller, projectname): + def add_project(self, controller, project_name): headers = {'Authorization': 'Bearer ' + self.token} data = { - "name": str(projectname) - } + "name": str(project_name) + } print(data) response = requests.post(URL_PROJECTS, json=data, headers=headers) print(response) if response.status_code == 201: response = response.json() - controller.show_frame(MainView) + controller.show_frame(ProjectsView) else: print("sth wrong") bad_pass_label = tk.Label(self, text='Something went wrong!', font=FONT) -- 2.20.1 From 8db34d386cf2137358b885eac3518b9b5a548b1a Mon Sep 17 00:00:00 2001 From: s460930 Date: Mon, 21 Dec 2020 14:24:03 +0100 Subject: [PATCH 3/3] SMART-49 implemented add project view --- rest-app/db.sqlite3 | Bin 172032 -> 172032 bytes .../__pycache__/settings.cpython-38.pyc | Bin 3530 -> 3530 bytes .../__pycache__/urls.cpython-38.pyc | Bin 1110 -> 1110 bytes .../__pycache__/models.cpython-38.pyc | Bin 1267 -> 1267 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/rest-app/db.sqlite3 b/rest-app/db.sqlite3 index 2f940d68bfed3ed880e7eeae47ba1d9e28f1f8f0..0c273407f25adc6af25848c97f8a4658143c6f8c 100644 GIT binary patch delta 778 zcmaixze*fY6vmy=85dXQMle-`D4W*hp8Nk!Ba+5uAdm-e_ue~`5SVNTX_7{#NS&Az z`xF);VOlLx`2>2P~z4Y1oaTKzUeE%|~(exPe&) zjyg~dgJY(^%2@0GxK+8afbI1a_t^AC%qA=<+HA_euV`mzky!?jLwF_&DS8uidm zw3}R@FQ`1O&XWBn^I0(Kot<`Q))yArp;^a^+o9W`AO0_OG%okUvG?4#tsAeqsFz$d duD$1lc8L!cd1sT>^CzvR_%?{@@>BTr!C#8p%a;HE delta 123 zcmZoTz}0YoYl1Xm=tLQ3#?Z!u)&$0_2~2DGgbYm;3{9B*VnR!k^2)zn%XM|0Mq0jg7JV({t;Y Trb9&U0L7uA+jIMwCJO)nF3%?J diff --git a/rest-app/smartpicasso/__pycache__/settings.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/settings.cpython-38.pyc index 68dbbda0dc09c8e2598ab360a1610297c3dec1ae..417941631187a51499fd934d3a9a1b689839298f 100644 GIT binary patch delta 20 acmX>leM*`;l$V!_0SKHLZ*Sz@&kF!H=>>HF delta 20 acmX>leM*`;l$V!_0SHPi-Pp*zpBDf+9tHIP diff --git a/rest-app/smartpicasso/__pycache__/urls.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/urls.cpython-38.pyc index d832aea1c7fd30a3ac3b86954119100184199922..1999ea575ef3e1280a70ff428fd15c50875c8079 100644 GIT binary patch delta 20 acmcb{agBpJl$V!_0SKHLZ*S!GW&r>-6a?x3 delta 20 acmcb{agBpJl$V!_0SHPi-Pp+O%>n>8Nd;;E diff --git a/rest-app/smartpicasso/app/user_profile/__pycache__/models.cpython-38.pyc b/rest-app/smartpicasso/app/user_profile/__pycache__/models.cpython-38.pyc index 80f08c37d919f6abd102f5f7177255c375bda26f..57822434e0f3a497f9e8c62109a66d7bbaad3424 100644 GIT binary patch delta 20 acmey&`I(bDl$V!_0SKHLZ*Sy&!2$p}zy-qq delta 20 acmey&`I(bDl$V!_0SMk~zrK