-
Notifications
You must be signed in to change notification settings - Fork 0
/
sign_in_page.py
54 lines (41 loc) · 1.82 KB
/
sign_in_page.py
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
#Shows what the user can have access to when they sign in
from account import Account
from search_image import Search_Image
import json
class Sign_In_Page:
def __init__(self, account, account_list):
self.account = account
self.account_list = account_list
def save(self):
with open("accounts.json", "w") as accounts_json:
serilizated_data = self.serilization()
json.dump(serilizated_data, accounts_json,sort_keys=True, indent=4)
def serilization(self):
exeList=[]
for i in range(len(self.accountList)):
serilizated = {}
serilizated["username"] = self.accountList[i].username
serilizated["password"] = self.accountList[i].password
serilizated["email"] = self.accountList[i].email
serilizated["gallery"] = self.accountList[i].gallery
exeList.append(serilizated)
return exeList
def search_photo(self, search):
image = Search_Image(search)
return image.image_links
def update_account(self, old_username, old_password, old_email, new_username, new_password, new_email):
for acc in self.account_list:
if (acc.username == new_username and self.account.username != new_username) or (acc.email == new_email and self.account.email != new_email):
return (True, None)
else:
self.account.username = new_username
self.account.password = new_password
self.account.email = new_email
return (False, self.account)
def delete_account(self):
for i in range(len(self.account_list)):
if self.account_list[i].username == self.account.username:
self.account_list.pop(i)
return True
else:
return False