-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapstone_kv_impl.py
More file actions
170 lines (128 loc) · 4.06 KB
/
capstone_kv_impl.py
File metadata and controls
170 lines (128 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
import db
global current_user
current_user = object()
global kivy_app
kivy_app = object()
class UserData:
def __init__(self,un =""):
self.UserName=un
self.FirstName=""
self.LastName=""
self.Email=""
self.Interests=""
pass
def update(self,data):
self.UserName = data[1]
self.FirstName= data[3]
self.LastName= data[4]
self.Email= data[5]
self.Interests= data[6]
pass
pass
class SplashWindow(Screen):
pass
class LoginWindow(Screen):#
def login_released(self,usnm, passw):
print(f"user name = {usnm.text}")
print(f"password = {passw.text}")
result = db.un_login(usnm.text,passw.text)
if result == True:
# set global username
global current_user
current_user = UserData(usnm.text)
# clear text fields
usnm.text =""
passw.text =""
#set window to profile
kivy_app.root.current = "profile"
self.manager.transition.direction = "left"
pass
else:
# give users feedback that they are not able to log in due to invalid credentials
pass
pass
pass
class ProfileWindow(Screen):
def display_userdata(self, usnm, first_name, last_name, email, interests):
# get user profile
user_profiles = db.profile_get(current_user.UserName)
assert len(user_profiles) > 0 #assert if user profile does not exist
# update stored current user data
user_data = user_profiles[0]
current_user.update(user_data)
# update text on-screen
usnm.text = current_user.UserName
first_name.text = current_user.FirstName
last_name.text = current_user.LastName
email.text = current_user.Email
interests.text = current_user.Interests
pass
pass
class ProfileCreateWindow(Screen):
def create_profile_released(self,usnm,passw,first_name,last_name,email,interests):
db.profile_new(usnm.text,passw.text,first_name.text,last_name.text,email.text,interests.text)
global current_user
current_user.UserName = usnm.text
current_user.FirstName = first_name.text
current_user.LastName = last_name.text
current_user.Email = email.text
current_user.Interests = interests.text
pass
pass
class WindowManager(ScreenManager):
def get_username(self):
global current_user
return current_user.UserName
def update_username(self,newusername ):
global current_user
current_user.UserName = newusername
pass
def clear_released(self,* args):
for element in args:
element.text = ""
pass
pass
pass
current_user = UserData()
kv = Builder.load_file("my.kv")
class MyMainApp(App):
def build(self):
return kv
def main():
# # Teo: use these lines to manipulate database
# Database initialization and tests
db.init()
# db.un_exists('userNameThatDoesNotExist')
# db.profile_delete('userNameThatDoesNotExist')
# db.profile_delete('davidDelSol')
# db.profile_new(
# 'davidDelSol',
# 'encrypted?',
# 'david',
# 'aloka',
# 'test@preform.io',
# 'salsa,extended intelligence,marathon running in a full suit'
# )
# db.profile_new(
# 'Python733t',
# 'encrypted?',
# 'Doroteo ',
# 'Bonilla',
# 'doabonilla@yahoo.com',
# 'work,school,sleep,repeat'
# )
# db.un_login('davidDelSol', 'encrypted?')
# db.profile_update('davidDelSol', pw = 'definitelyNotEncripted!')
# db.un_login('davidDelSol', 'definitelyNotEncripted!')
# db.un_exists('davidDelSol')
# db.profile_print(all = True)
# db.profile_print(['Python733t'])
# db.profile_print('Python733t')
pass
if __name__ == "__main__":
kivy_app = MyMainApp()
main()
kivy_app.run()