-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrole_access.py
427 lines (404 loc) · 20 KB
/
role_access.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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
"""this module is for each role's access"""
import sys
import datetime
import project_manage
from csv_extract import CSV
login_data = CSV('login.csv')
login_data_list_temp = CSV.csv_list(login_data)
_login_data_dict = CSV.csv_dict(login_data)
persons_data = CSV("persons.csv")
_persons_data_dict = CSV.csv_dict(persons_data)
project_data = CSV('project.csv')
_project_data_dict = CSV.csv_dict(project_data)
member_pending_request = CSV('member_pending_request.csv')
_member_pending_request_dict = CSV.csv_dict(member_pending_request)
advisor_pending_request = CSV('advisor_pending_request.csv')
_advisor_pending_request_dict = CSV.csv_dict(advisor_pending_request)
class Admin:
"""Object for admin"""
def __init__(self, login_data_sys, login_data_dict=_login_data_dict,
project_data_dict=_project_data_dict
, member_pending_request_dict=_member_pending_request_dict,
advisor_pending_request_dict=_advisor_pending_request_dict,
person_data_dict=_project_data_dict):
self.login_data = login_data_sys
self.login_data_dict = login_data_dict
self.person_data_dict = person_data_dict
self.project_data_dict = project_data_dict
self.member_pending_request_dict = member_pending_request_dict
self.advisor_pending_request_dict = advisor_pending_request_dict
@property
def login_data_x(self):
"""getter"""
return self.login_data_dict
@login_data_x.setter
def login_data_x(self, new_data):
"""setter"""
self.login_data_dict = new_data
@property
def person_data(self):
"""getter"""
return self.person_data_dict
@person_data.setter
def person_data(self, new_data):
"""setter"""
self.project_data_dict = new_data
@property
def project_data(self):
"""getter"""
return _project_data_dict
@project_data.setter
def project_data(self, new_data):
"""setter"""
self.project_data_dict = new_data
@property
def member_invite_data(self):
"""getter"""
return self.member_pending_request_dict
@member_invite_data.setter
def member_invite_data(self, new_data):
"""setter"""
self.member_pending_request_dict = new_data
@property
def advisor_invite_data(self):
"""getter"""
return self.advisor_pending_request_dict
@advisor_invite_data.setter
def advisor_invite_data(self, new_data):
"""setter"""
self.advisor_pending_request_dict = new_data
def page_admin(self):
"""method for Admin use"""
print("1.check all login data:")
print("2.check all persons data:")
print("3.check all project data:")
print("4.check all member invite data:")
print("5.check all advisor invite data:")
print("6.Exit:")
admin_input_1 = input("input enter input here: ")
if admin_input_1 == "6":
sys.exit()
if admin_input_1 == "1":
print("what would you like to change?")
print("1.Read all files:")
print("2. Add a File")
print("3. Delete a File")
fl_temp_val1 = input("what would you like to do?")
if fl_temp_val1 == "1":
print()
print()
print(self.login_data_x)
print()
print()
if fl_temp_val1 == "2":
print("type data you would like to add:")
temp_val1 = input("input a 7 digit ID (example.1234567)")
while True:
if temp_val1 in self.login_data_dict["ID"]:
print("this ID already exists")
print("please type a new ID")
temp_val1 = input("input a 7 digit ID (example. Neon)")
else:
break
temp_val2 = input("input a username (example.1234567)")
while True:
if temp_val2 in self.login_data_dict["username"]:
print("this username already exists")
print("please type a new username")
temp_val2 = input("input a new username (example. Neon1)")
else:
break
temp_val3 = input("input a password (example.123456789)")
print("roles available right now (admin, student, faculty): ")
temp_val4 = input("what role would you like this user to have?: ")
temp_login_data = project_manage.AddLogin(temp_val1, temp_val2, temp_val3,
temp_val4)
temp_login_data.create_data()
if fl_temp_val1 == "3":
print("what data would you like to delete:")
delete_login = input("enter the ID you would like to delete")
login_del = project_manage.AddLogin(delete_login)
login_del.delete_data()
if admin_input_1 == "2":
print()
print()
print(self.person_data)
print()
print()
if admin_input_1 == "3":
print("what would you like to change?")
print("1.Read all files:")
print("2. Add a File")
print("3. Delete a File")
fl_temp_val1 = input("what would you like to do?")
if fl_temp_val1 == "1":
print()
print()
print(self.project_data_dict)
print()
print()
if fl_temp_val1 == "2":
print("enter a valid ProjectID (ex.PJ69), also dont make duplicate ProjectIDs:")
temp_val1 = input("enter PJ: ")
while True:
if temp_val1 in self.project_data_dict["ProjectID"]:
print("this ProjectID already exists")
print("please type a new ID")
temp_val1 = input("enter a valid ProjectID "
"(ex.PJ69), also dont make duplicate ProjectIDs:")
else:
break
temp_val2 = input("input a Title: ")
temp_val3 = input("input Lead: ")
temp_val4 = input("input Member1: ")
temp_val5 = input("input Member2: ")
temp_val6 = input("input Advisor: ")
temp_val7 = input("input status: ")
temp_val8 = input("input information: ")
temp_project_data = project_manage.AddProject(temp_val1, temp_val2, temp_val3,
temp_val4, temp_val5, temp_val6,
temp_val7, temp_val8)
temp_project_data.create_data()
if fl_temp_val1 == "3":
print("what data would you like to delete:")
delete_project = input("enter the ID you would like to delete")
project_del = project_manage.AddProject(delete_project, "", "",
"",
"", "", "",
"")
project_del.delete_data()
if admin_input_1 == "4":
print()
print()
print(self.member_pending_request_dict)
print()
print()
if admin_input_1 == "5":
print()
print()
print(self.advisor_pending_request_dict)
print()
print()
class Student:
"""Student object class"""
def __init__(self, login_data_sys, login_data_dict=_login_data_dict,
project_data_dict=_project_data_dict
,member_pending_request_dict=_member_pending_request_dict,
advisor_pending_request_dict=_advisor_pending_request_dict):
self.login_data = login_data_sys
self.login_data_dict = login_data_dict
self.project_data_dict = project_data_dict
self.member_pending_request_dict = member_pending_request_dict
self.advisor_pending_request_dict = advisor_pending_request_dict
def page1(self):
"""method for student page1"""
run = True
page1_1 = True
page1_2 = False
page1_2_2 = False
main_choose = 0
while run:
status_student = ""
while page1_1:
print("--------------------------")
print("current projects:")
for i in self.project_data_dict:
if self.login_data["ID"] in [i["Lead"], i["Member1"], i["Member2"]]:
print("ProjectID:" + " " + i["ProjectID"] + " " +
"Title:" + " " + i["Title"] + " " +
"Status" + " " + i["Status"])
print("Project Proposal information: " + i["information"])
if self.login_data["ID"] == i["Lead"]:
status_student = "lead"
if self.login_data["ID"] in [i["Member1"], i["Member2"]]:
status_student = "member"
print("--------------------------")
print("what would you like to do?")
print("1.create new project")
print("2.check current project status")
print("3.check invites")
print("4.exit")
print("--------------------------")
main_choose = int(input("input: "))
page1_2 = True
page1_1 = False
while page1_2:
if main_choose == 4:
sys.exit()
if main_choose == 3:
temp_invite_val = 0
for member_dict in self.member_pending_request_dict:
if (self.login_data["ID"] == member_dict["to_be_member"]
and member_dict["Response"] == "pending"):
temp_invite_val += 1
print("invite for project:" + " " + member_dict["ProjectID"]
+ " " + "by: "
+ member_dict["Inviter"])
page1_2_3 = True
while page1_2_3:
if temp_invite_val != 0:
edit_invite = input("which project would you like to accept?: ")
temp_com = project_manage.ConfirmInvite(edit_invite)
temp_com.respond_invite_member()
else:
print()
print("no invites")
print()
page1_2_3 = False
if main_choose == 2:
access_project = input("enter code (ex.(PJ0)): ")
for project_dict in self.project_data_dict:
if project_dict["ProjectID"] == access_project:
temp_val1 = 0
temp_val2 = 0
temp_val3 = 0
print("ProjectID: " + project_dict["ProjectID"])
print("Project Title: " + project_dict["Title"])
for i in _persons_data_dict:
if i["ID"] == project_dict["Lead"]:
print("Lead Member: " + i["first"] + " " + i["last"])
temp_val1 = 1
if temp_val1 == 0:
print("Lead Member: None")
for i in _persons_data_dict:
if i["ID"] == project_dict["Member1"]:
print("Member1: " + i["first"] + " " + i["last"])
temp_val2 = 1
if temp_val2 == 0:
print("Member1: None")
for i in _persons_data_dict:
if i["ID"] == project_dict["Member2"]:
print("Member2: " + i["first"] + " " + i["last"])
temp_val3 = 1
if temp_val3 == 0:
print("Member2: None")
print("Advisor: " + project_dict["Advisor"])
print("Project info: " + project_dict["information"])
print("Project Status: " + project_dict["Status"])
page1_2_2 = True
while page1_2_2:
if status_student == "lead":
print()
print("Your Role is: " + self.login_data["role"])
print("------------------------------")
print("Type 1 to invite Member:")
print("Type 2 to invite Advisor:")
print("Type 3 to change information:")
print("Type 4 to exit:")
print("------------------------------")
change_page_1_2_2 = input("input:")
if change_page_1_2_2 == "1":
member_code = input("member ID: ")
member1_invite = project_manage.Invite(access_project,
self.login_data["ID"],
member_code,
"pending",
datetime.date.today())
member1_invite.create_invite_member()
if change_page_1_2_2 == "2":
advisor_code = input("Advisor ID: ")
advisor_invite = project_manage.Invite(access_project,
self.login_data["ID"],
advisor_code,
"pending",
datetime.date.today())
advisor_invite.create_invite_advisor()
if change_page_1_2_2 == "3":
new_info = input("what would you like to rewrite: ")
info = project_manage.NewInformation(access_project, new_info)
info.change_info()
if change_page_1_2_2 == "4":
sys.exit()
page1_2_2 = False
if status_student == "member":
print()
print("Your Role is: " + self.login_data["role"])
print("------------------------------")
print("Type 1 to change information:")
print("Type 2 to exit:")
print("------------------------------")
change_page_1_2_2 = input("input:")
if change_page_1_2_2 == "1":
new_info = input("what would you like to rewrite: ")
info = project_manage.NewInformation(access_project, new_info)
info.change_info()
if change_page_1_2_2 == "1":
sys.exit()
if main_choose == 1:
project_id_num = f"PJ{len(self.project_data_dict) + 1}"
title = input("Project title: ")
basic_info = input("what will this project be about: ")
lead_member = self.login_data["ID"]
member1 = "None"
member2 = "None"
advisor = "None"
print("creation successful, pls restart program to access :)")
new_project_create = project_manage.Project(project_id_num, title,
lead_member,
member1, member2,
advisor, basic_info)
new_project_create.create_project()
return False
# project = project_manage.Project(project_id_num, title, lead_member,
# member1, member2, advisor)
# project.create_project()
else:
return True
class Faculty:
"""Faculty class"""
def __init__(self, login_data_sys, login_data_dict=_login_data_dict,
project_data_dict=_project_data_dict
, member_pending_request_dict=_member_pending_request_dict,
advisor_pending_request_dict=_advisor_pending_request_dict,
person_data_dict=_persons_data_dict):
self.login_data = login_data_sys
self.login_data_dict = login_data_dict
self.project_data_dict = project_data_dict
self.member_pending_request_dict = member_pending_request_dict
self.advisor_pending_request_dict = advisor_pending_request_dict
self.person_data_dict = person_data_dict
def page_faculty(self):
"""faculty UI"""
print("--------------------------")
print("what would you like to do?")
print("1.check invites")
print("2.view advising project")
print("3.exit")
print("--------------------------")
main_choose = int(input("input: "))
if main_choose == 1:
for advisor_dict in self.advisor_pending_request_dict:
if (self.login_data["ID"] == advisor_dict["to_be_advisor"] and
advisor_dict["Response"] == "pending"):
print(
"invite for project: " + advisor_dict["ProjectID"] + " " + "by:" + " "
+ advisor_dict["Inviter"])
page1_2_3 = True
while page1_2_3:
edit_invite = input("which project would you like to accept? (Example.PJ0)): ")
temp_com = project_manage.ConfirmInvite(edit_invite)
temp_com.respond_invite_advisor()
page1_2_3 = False
if main_choose == 2:
project_data_dict_size = len(self.project_data_dict)
for j in range(project_data_dict_size):
if self.login_data["ID"] == self.project_data_dict[j]["Advisor"]:
print("ProjectID: " + self.project_data_dict[j]["ProjectID"])
print("Title: " + self.project_data_dict[j]["Title"])
for i in self.person_data_dict:
if i["ID"] == self.project_data_dict[j]["Lead"]:
print("Lead Member: " + i["first"] + " " + i["last"])
if i["ID"] == self.project_data_dict[j]["Member1"]:
print("Member1: " + i["first"] + " " + i["last"])
if i["ID"] == self.project_data_dict[j]["Member2"]:
print("Member2: " + i["first"] + " " + i["last"])
print()
allow = input("Write opinion: ")
allow_edit = project_manage.ConfirmInvite(self.project_data_dict[j]["ProjectID"]
, allow)
allow_edit.respond_status()
if main_choose == 3:
sys.exit()
def read_person(self):
"""return person dict"""
return self.person_data_dict