-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
3602 lines (2872 loc) · 171 KB
/
main.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
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Import PyQt5's widgets to be used throughout the program
import io
import math
import os
import shutil
import sqlite3
from datetime import time
import time
import canvas as canvas
# folium v0.12.1 - Used to display geographical data
import folium
import numpy as np
from PyQt5 import QtGui, QtCore, QtWidgets, QtWebEngineWidgets, QtPrintSupport
from PyQt5.QtCore import Qt, QRunnable, pyqtSlot, QThreadPool, QUrl, QSize
from PyQt5.QtGui import QIcon, QPixmap, QFont, QDesktopServices, QPainter, QPainterPath, QTextOption
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWidgets import *
from folium.plugins import MarkerCluster
import hashlib
# import class functions
import create_widget_functions
import user_details
from create_widget_functions import VerticalTabWidget, ChatGPTWindowWidget
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
import matplotlib.backends.backend_pdf as pdf_backend
from openpyxl import Workbook
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
REDEEM_BUTTON_STYLESHEET = '''
QPushButton {
background-color: rgb(12, 96, 50);
color: white;
border-radius:10px;
font-size:10pt
}
QPushButton:hover {
background-color: gray;
}
'''
PROFILE_BUTTON_STYLESHEET = '''
QPushButton {
background-color: rgb(12, 96, 50);
color: white;
border-radius:25px;
font-size:10pt
}
QPushButton:hover {
background-color: gray;
}
'''
SEND_BUTTON_STYLESHEET = '''
QPushButton {
background-color: rgb(12, 96, 50);
color: white;
border-radius:15px;
font-size:10pt
}
QPushButton:hover {
background-color: gray;
}
'''
RESOLVED_BUTTON_STYLESHEET = '''
QPushButton {
background-color: rgb(12, 96, 50);
color: white;
border-radius:10px;
font-size:10pt
}
QPushButton:hover {
background-color: gray;
}
'''
sqliteConnection = sqlite3.connect('identifier.sqlite')
cursor = sqliteConnection.cursor()
sqlite_select_query = """SELECT * from events"""
cursor.execute(sqlite_select_query)
events = cursor.fetchall()
cursor.execute("SELECT *, RANK() OVER(ORDER BY points DESC) 'Rank' from students")
students = cursor.fetchall()
cursor.execute("SELECT FIRST_NAME, LAST_NAME, POINTS FROM students")
student_rows = cursor.fetchall()
first_name = ""
last_name = ""
output_file = 'output_file.xlsx'
if os.path.exists(output_file):
os.remove(output_file)
print(f"Deleted existing file: {output_file}")
cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
tables = cursor.fetchall()
workbook = Workbook()
for table in tables:
table_name = table[0]
query = f"SELECT * FROM {table_name}"
cursor.execute(query)
results = cursor.fetchall()
# Create a new sheet for each table
sheet = workbook.create_sheet(title=table_name)
# Write the headers
headers = [description[0] for description in cursor.description]
sheet.append(headers)
# Write the data rows
for row in results:
sheet.append(row)
# Save the workbook to an Excel file
workbook.save('output_file.xlsx')
# Create a new excel file the day before presenting !!!!VERY IMPORTANT!!!!!
def sort_key(student_rows):
return student_rows[2]
student_rows.sort(key=sort_key, reverse=True)
cursor.close()
event_combobox_selection = ""
rating_combobox_selection = ""
description_box = ""
name_annoucement_text_stuff = ""
details_annoucement_text_stuff = ""
"""
Class that sets up the main window for the entire application.
The entire frame with all it's elements are implemented in this class."""
class ResolvePopup(QDialog):
def __init__(self):
super().__init__()
self.setWindowTitle("Enter Resolution")
layout = QVBoxLayout(self)
self.text_field = QLineEdit(self)
layout.addWidget(self.text_field)
submit_button = QPushButton("Submit", self)
layout.addWidget(submit_button)
submit_button.clicked.connect(self.handle_resolution)
def handle_resolution(self):
resolution = self.text_field.text()
first_name = "Wallace"
last_name = "McCarthy"
points = 0
status = "N/A"
sqliteConnection = sqlite3.connect('identifier.sqlite')
cursor = sqliteConnection.cursor()
query = "INSERT INTO main.NOTIFICATIONS (points, description, first_name, last_name, status) VALUES (?, ?, ?, ?, ?)"
cursor.execute(query, (points, resolution, first_name, last_name, status))
print("Inserted into notifications")
sqliteConnection.commit()
cursor.close()
self.accept()
class Main(object):
"""
Main Method that sets up the main window for the entire application, and takes
the user to the actual program.
"""
def setup_window(self, main_window):
main_window.setWindowTitle("Spirit Quest")
main_window.setObjectName("main_window")
icon = QIcon("Application Pictures and Icons/gold-medal.png")
main_window.setWindowIcon(icon)
main_window.setFixedSize(800, 500)
self.setup_login_screen(main_window)
# Sets up the initial login screen
"""
This method sets up the login screen of the program, and all physical
characteristics of the frame are made here.
"""
def setup_login_screen(self, main_window):
self.login_central_widget = QtWidgets.QWidget(main_window)
self.login_central_widget.resize(800, 500)
self.login_screen_background = QtWidgets.QLabel(self.login_central_widget)
self.login_screen_background.setFixedSize(810, 500)
self.login_screen_background.setPixmap(QtGui.QPixmap(r"Application Pictures and Icons/Login Screen Background.png"))
self.login_screen_background.setScaledContents(True)
self.login_screen_background.show()
self.login_widget_container = QtWidgets.QGroupBox(self.login_central_widget)
self.login_widget_container.resize(800, 500)
# Application Logo
self.login_screen_logo = QtWidgets.QLabel(self.login_widget_container)
self.login_screen_logo.setFixedSize(200, 200)
self.login_screen_logo.move(-20, -75)
self.login_screen_logo.setScaledContents(True)
self.login_screen_logo.show()
# Student Login
self.student_login_title = self.create_QLabel("login_widget_container", "login_titles", "Student Login", 105,
80, 300, 50)
self.student_login_title.setStyleSheet("font-size: 30px; font-weight: bold;")
self.student_username_label = self.create_QLabel("login_widget_container", "login_screen_labels", "Email ID",
80, 122, 200, 50)
self.student_username = self.create_QLineEdit("login_widget_container", "login_screen_text_fields", False, 80,
160, 240, 30)
self.student_password_label = self.create_QLabel("login_widget_container", "login_screen_labels", "Password",
80, 187, 200, 50)
# Student Password
self.student_password = PasswordLineEdit(self.login_widget_container)
self.student_password.setObjectName("login_screen_text_fields")
self.student_password.setEchoMode(QtWidgets.QLineEdit.Password)
self.student_password.setGeometry(QtCore.QRect(80, 225, 240, 30))
student_password = self.student_password.text() # Get the student password
hashed_student_password = hashlib.sha256(student_password.encode()).hexdigest() # Hash the password
# end eye try
self.student_forgot_password = self.create_QPushButton("login_widget_container", "login_screen_forgot_password",
"Forgot password?", "None", 65, 255, 140, 30)
self.student_forgot_password.clicked.connect(self.setup_forgot_password)
self.student_incorrect_login = self.create_QLabel("login_widget_container", "incorrect_login",
"Email ID and/or Password Icorrect. Please enter correct credentials.",
82, 275, 240, 50)
self.student_incorrect_login.setWordWrap(True)
self.student_incorrect_login.hide()
self.student_login_button = self.create_QPushButton("login_widget_container", "student_login_button", "Login",
"None", 80, 290, 240, 30)
self.student_login_button.clicked.connect(self.setup_portal)
self.student_login_button.setStyleSheet("QPushButton {border-radius: 15px;}")
self.student_or_label = self.create_QLabel("login_widget_container", "login_screen_labels", "or", 190, 310, 40,
50)
self.student_create_account = self.create_QPushButton("login_widget_container", "student_login_button",
"Create a Student Account", "None", 80, 350, 240, 30)
self.student_create_account.clicked.connect(self.setup_student_account_creation)
self.student_create_account.setStyleSheet("QPushButton {border-radius: 15px;}")
# Line divider between logins
self.login_divider_line = self.create_QFrame("login_widget_container", "login_screen_elements", "VLine", 399,
40, 1, 410)
# Administrator Login
self.administrator_login_title = self.create_QLabel("login_widget_container", "login_titles",
"Administrator Login", 460, 80, 350, 50)
self.administrator_login_title.setStyleSheet("font-size: 30px; font-weight: bold;")
self.administrator_username_label = self.create_QLabel("login_widget_container", "login_screen_labels",
"Email ID", 480, 122, 200, 50)
self.administrator_username = self.create_QLineEdit("login_widget_container", "login_screen_text_fields", False,
480, 160, 240, 30)
self.administrator_password_label = self.create_QLabel("login_widget_container", "login_screen_labels",
"Password", 480, 187, 200, 50)
# Administrator Password eye stuff
self.administrator_password = PasswordLineEdit(self.login_widget_container)
self.administrator_password.setObjectName("login_screen_text_fields")
self.administrator_password.setEchoMode(QtWidgets.QLineEdit.Password)
self.administrator_password.setGeometry(QtCore.QRect(480, 225, 240, 30))
admin_password = self.administrator_password.text() # Get the admin password
hashed_admin_password = hashlib.sha256(admin_password.encode()).hexdigest()
self.administrator_forgot_password = self.create_QPushButton("login_widget_container",
"login_screen_forgot_password", "Forgot password?",
"None", 465, 255, 140, 30)
self.administrator_forgot_password.clicked.connect(self.admin_forgot_password_page)
self.administrator_incorrect_login = self.create_QLabel("login_widget_container", "incorrect_login",
"Email ID and/or Password Icorrect. Please enter correct credentials.",
482, 275, 240, 50)
self.administrator_incorrect_login.setWordWrap(True)
self.administrator_incorrect_login.hide()
self.administrator_login_button = self.create_QPushButton("login_widget_container",
"administrator_login_button", "Login", "None", 480,
290, 240, 30)
self.administrator_login_button.clicked.connect(self.setup_portal)
self.administrator_login_button.setStyleSheet("QPushButton {border-radius: 15px;}")
self.administrator_or_label = self.create_QLabel("login_widget_container", "login_screen_labels", "or", 590,
310, 40, 50)
self.administrator_create_account = self.create_QPushButton("login_widget_container",
"administrator_login_button",
"Create an Administrator Account", "None", 480, 350,
240, 30)
self.administrator_create_account.clicked.connect(self.setup_administrator_account_creation)
self.administrator_create_account.setStyleSheet("QPushButton {border-radius: 15px;}")
main_window.setStatusBar(None)
def setup_student_account_creation(self):
self.student_account_frame = QtWidgets.QLabel()
self.student_account_frame.setWindowTitle("Create Student Account")
self.student_account_frame.setFixedSize(1200, 500)
self.student_account_frame.move(100, 20)
self.student_account_frame.setPixmap(QtGui.QPixmap(r"Application Pictures and Icons/Login Screen Background.png").scaledToWidth(1200))
self.student_account_label = self.create_QLabel("student_account_frame", "student_account_label",
"Create Student Account", 20, 20, 600, 50)
self.student_account_line = self.create_QFrame("student_account_frame", "student_account_line", "HLine", 10, 65,
600, 0)
self.first_name_label = self.create_QLabel("student_account_frame", "first_name_label",
"First Name", 50, 120, 300, 30)
self.first_name_entry = QtWidgets.QLineEdit(self.student_account_frame)
self.first_name_entry.setGeometry(QtCore.QRect(150, 120, 200, 30))
self.first_name_entry.setPlaceholderText("First Name")
self.last_name_label = self.create_QLabel("student_account_frame", "last_name_label",
"Last Name", 55, 200, 300, 30)
self.username_entry = QtWidgets.QLineEdit(self.student_account_frame)
self.username_entry.setGeometry(QtCore.QRect(150, 200, 200, 30))
self.username_entry.setPlaceholderText("Last Name")
self.create_email_label = self.create_QLabel("student_account_frame", "create_email_label",
"Email Address", 40, 280, 300, 30)
self.create_email_entry = QtWidgets.QLineEdit(self.student_account_frame)
self.create_email_entry.setGeometry(QtCore.QRect(150, 280, 200, 30))
self.create_email_entry.setPlaceholderText("Email Address")
self.create_password_label = self.create_QLabel("student_account_frame", "create_password_label",
"Password", 55, 360, 300, 30)
self.create_password_entry = QtWidgets.QLineEdit(self.student_account_frame)
self.create_password_entry.setGeometry(QtCore.QRect(150, 360, 200, 30))
self.create_password_entry.setPlaceholderText("Password")
self.birthday_label = self.create_QLabel("student_account_frame", "birthday_label",
"Birthday (MM/DD/YY)", 370, 120, 300, 30)
self.birthday_entry = QtWidgets.QLineEdit(self.student_account_frame)
self.birthday_entry.setGeometry(QtCore.QRect(550, 120, 200, 30))
self.birthday_entry.setPlaceholderText("Birthday (MM/DD/YY)")
self.school_label = self.create_QLabel("student_account_frame", "school_label",
"School", 370, 200, 300, 30)
self.school_entry = QtWidgets.QLineEdit(self.student_account_frame)
self.school_entry.setGeometry(QtCore.QRect(430, 200, 200, 30))
self.school_entry.setPlaceholderText("School")
self.grade_combobox = QComboBox(self.student_account_frame)
self.grade_combobox.setGeometry(640, 200, 110, 30)
self.grade_combobox.addItem("Choose Grade")
self.grade_combobox.addItem("9")
self.grade_combobox.addItem("10")
self.grade_combobox.addItem("11")
self.grade_combobox.addItem("12")
self.grade_combobox.setCurrentIndex(0)
self.security_combobox_label = self.create_QLabel("student_account_frame", "security_combobox_label",
"Security Question", 370, 280, 300, 30)
self.security_combobox = QComboBox(self.student_account_frame)
self.security_combobox.setGeometry(550, 280, 200, 30)
self.security_combobox.addItem("Choose Security Question")
self.security_combobox.addItem("What is your favorite color?")
self.security_combobox.addItem("What is your favorite sports team?")
self.security_combobox.addItem("What year was your first rock climbing nationals?")
self.security_combobox.addItem("What is your mother's maiden name?")
self.security_combobox.setCurrentIndex(0)
self.create_answer_label = self.create_QLabel("student_account_frame", "create_answer_label",
"Answer", 370, 360, 300, 30)
self.create_answer_entry = QtWidgets.QLineEdit(self.student_account_frame)
self.create_answer_entry.setGeometry(QtCore.QRect(550, 360, 200, 30))
self.create_answer_entry.setPlaceholderText("Answer")
self.emergency_name_label = self.create_QLabel("student_account_frame", "emergency_name_label",
"Emergency Name", 800, 120, 300, 30)
self.emergency_name_entry = QtWidgets.QLineEdit(self.student_account_frame)
self.emergency_name_entry.setGeometry(QtCore.QRect(960, 120, 200, 30))
self.emergency_name_entry.setPlaceholderText("Emergency Name")
self.emergency_phone_label = self.create_QLabel("student_account_frame", "emergency_phone_label",
"Emergency Phone", 800, 200, 300, 30)
self.emergency_phone_entry = QtWidgets.QLineEdit(self.student_account_frame)
self.emergency_phone_entry.setGeometry(QtCore.QRect(960, 200, 200, 30))
self.emergency_phone_entry.setPlaceholderText("Emergency Phone")
self.emergency_email_label = self.create_QLabel("student_account_frame", "emergency_email_label",
"Emergency Email", 800, 280, 300, 30)
self.emergency_email_entry = QtWidgets.QLineEdit(self.student_account_frame)
self.emergency_email_entry.setGeometry(QtCore.QRect(960, 280, 200, 30))
self.emergency_email_entry.setPlaceholderText("Emergency Email")
self.gender_label = self.create_QLabel("student_account_frame", "gender_label",
"Gender", 800, 360, 300, 30)
self.gender_combobox = QComboBox(self.student_account_frame)
self.gender_combobox.setGeometry(960, 360, 200, 30)
self.gender_combobox.addItem("Select Gender")
self.gender_combobox.addItem("Male")
self.gender_combobox.addItem("Female")
self.gender_combobox.addItem("Prefer not to say")
self.gender_combobox.addItem("Other")
self.gender_combobox.setCurrentIndex(0)
self.create_account_button = QtWidgets.QPushButton("Create Account", self.student_account_frame)
self.create_account_button.setGeometry(QtCore.QRect(460, 430, 260, 30))
self.create_account_button.clicked.connect(self.create_student_account)
#self.create_account_button.setStyleSheet(SEND_BUTTON_STYLESHEET)
self.create_account_button.setObjectName("student_login_button")
self.student_account_frame.show()
def create_student_account(self):
first_name = self.first_name_entry.text()
last_name = self.username_entry.text()
email = self.create_email_entry.text()
password = self.create_password_entry.text()
birthday = self.birthday_entry.text()
school = self.school_entry.text()
grade = self.grade_combobox.currentText()
security_question = self.security_combobox.currentText()
answer = self.create_answer_entry.text()
emergency_name = self.emergency_name_entry.text()
emergency_phone = self.emergency_phone_entry.text()
emergency_email = self.emergency_email_entry.text()
gender = self.gender_combobox.currentText()
try:
sqliteConnection = sqlite3.connect('identifier.sqlite')
cursor = sqliteConnection.cursor()
query = "INSERT INTO students (FIRST_NAME, LAST_NAME, EMAIL_ADDRESS, PASSWORD, BIRTHDAY, SCHOOL, GRADE, SECURITY_QUESTION, SECURITY_ANSWER, EMERGENCY_CONTACT_NAME, EMERCENCY_CONTACT_PHONE_NUMBER, EMERGENCY_CONTACT_EMAIL, GENDER) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
cursor.execute(query,
(first_name, last_name, email, password, birthday, school, grade, security_question, answer,
emergency_name, emergency_phone, emergency_email, gender))
sqliteConnection.commit()
self.student_account_frame.close()
registration = QMessageBox()
registration.setText("Thanks for registration")
registration.setIcon(QMessageBox.Information)
registration.exec_()
except sqlite3.Error as error:
print("Error while connecting to SQLite database:", error)
finally:
if sqliteConnection:
sqliteConnection.close()
def setup_forgot_password(self):
self.forgot_password_frame = QtWidgets.QLabel()
self.forgot_password_frame.setWindowTitle("Forgot Password")
self.forgot_password_frame.setFixedSize(800, 500)
self.forgot_password_frame.move(108, 24)
self.forgot_password_frame.setPixmap(QPixmap(r"Application Pictures and Icons/Login Screen Background.png").scaledToWidth(800))
self.forgot_password_label = self.create_QLabel("forgot_password_frame", "forgot_password_label",
"Forgot Password", 20, 70, 600, 50)
# self.forgot_password_line = self.create_QFrame("forgot_password_frame", "forgot_password_line", "HLine", 10, 65,
# 600, 6)
self.email_label = self.create_QLabel("forgot_password_frame", "email_label", "Email", 20, 150, 80, 30)
self.email_entry = QtWidgets.QLineEdit(self.forgot_password_frame)
self.email_entry.setGeometry(QtCore.QRect(200, 150, 170, 30))
self.email_search_button = QtWidgets.QPushButton(" Search", self.forgot_password_frame)
self.email_search_button.setGeometry(QtCore.QRect(400, 150, 150, 30))
self.email_search_button.clicked.connect(self.search_security_question)
self.email_search_button.setIcon(QIcon(r"Application Pictures and Icons/search-12-filled.svg"))
self.security_question_label = self.create_QLabel("forgot_password_frame", "security_question_label",
"Security Question", 20, 220, 200, 30)
self.security_question_entry = QtWidgets.QLineEdit(self.forgot_password_frame)
self.security_question_entry.setGeometry(QtCore.QRect(200, 220, 350, 30))
self.answer_label = self.create_QLabel("forgot_password_frame", "answer_label", "Answer", 20, 290, 90, 30)
self.security_answer_entry = QtWidgets.QLineEdit(self.forgot_password_frame)
self.security_answer_entry.setGeometry(QtCore.QRect(200, 290, 350, 30))
self.new_password_label = self.create_QLabel("forgot_password_frame", "new_password_label", "New Password", 20,
360, 150, 30)
self.new_password_entry = QtWidgets.QLineEdit(self.forgot_password_frame)
self.new_password_entry.setGeometry(QtCore.QRect(200, 360, 350, 30))
self.change_password_button = QtWidgets.QPushButton("Change Password", self.forgot_password_frame)
self.change_password_button.setGeometry(QtCore.QRect(300, 420, 200, 30))
self.change_password_button.clicked.connect(self.change_password)
self.change_password_button.setObjectName("student_login_button")
self.forgot_password_frame.show()
def search_security_question(self):
email_string = self.email_entry.text()
sqliteConnection = sqlite3.connect('identifier.sqlite')
cursor = sqliteConnection.cursor()
cursor.execute("SELECT SECURITY_QUESTION FROM students WHERE EMAIL_ADDRESS = ?", (email_string,))
data = cursor.fetchone()
if data:
security_question = data[0]
self.security_question_entry.setText(security_question)
else:
no_security_question = QMessageBox()
no_security_question.setText("Email not found")
no_security_question.setIcon(QMessageBox.Warning)
no_security_question.exec_()
self.email_entry.clear()
def change_password(self):
email_string = self.email_entry.text()
new_password_string = self.new_password_entry.text()
answer_string = self.security_answer_entry.text()
sqliteConnection = sqlite3.connect('identifier.sqlite')
cursor = sqliteConnection.cursor()
cursor.execute("SELECT SECURITY_ANSWER FROM students WHERE EMAIL_ADDRESS = ?", (email_string,))
answer = cursor.fetchone()
if answer:
if (answer[0] == answer_string):
cursor.execute("UPDATE students SET PASSWORD = ? WHERE EMAIL_ADDRESS = ? AND SECURITY_ANSWER = ?",
(new_password_string, email_string, answer_string))
sqliteConnection.commit()
updated_password = QMessageBox()
updated_password.setText("Your Password has been updated!")
updated_password.setIcon(QMessageBox.Information)
updated_password.exec_()
else:
wrong_answer = QMessageBox()
wrong_answer.setText("Incorrect information provided")
wrong_answer.setIcon(QMessageBox.Warning)
wrong_answer.exec_()
def setup_administrator_account_creation(self):
self.admin_account_frame = QtWidgets.QLabel()
self.admin_account_frame.setWindowTitle("Create Administrator Account")
self.admin_account_frame.setFixedSize(800, 500)
self.admin_account_frame.setPixmap(QPixmap(r"Application Pictures and Icons/Login Screen Background.png").scaledToWidth(800))
self.admin_account_frame.move(100, 20)
self.student_account_label = self.create_QLabel("admin_account_frame", "student_account_label",
"Create Administrator Account", 160, 20, 600, 50)
self.student_account_line = self.create_QFrame("admin_account_frame", "student_account_line", "HLine", 10, 65,
600, 0)
#self.student_account_label.setStyleSheet("font-family:Roboto; color: white")
self.first_name_label = self.create_QLabel("admin_account_frame", "first_name_label",
"First Name", 50, 120, 300, 30)
self.login_screen_logo = QtWidgets.QLabel(self.admin_account_frame)
self.login_screen_logo.setFixedSize(200, 200)
self.login_screen_logo.move(-20, -75)
self.login_screen_logo.setScaledContents(True)
self.login_screen_logo.show()
self.first_name_entry = QtWidgets.QLineEdit(self.admin_account_frame)
self.first_name_entry.setGeometry(QtCore.QRect(150, 120, 200, 30))
self.first_name_entry.setPlaceholderText("First Name")
self.last_name_label = self.create_QLabel("admin_account_frame", "last_name_label",
"Last Name", 55, 200, 300, 30)
self.username_entry = QtWidgets.QLineEdit(self.admin_account_frame)
self.username_entry.setGeometry(QtCore.QRect(150, 200, 200, 30))
self.username_entry.setPlaceholderText("Last Name")
self.create_email_label = self.create_QLabel("admin_account_frame", "create_email_label",
"Email Address", 40, 280, 300, 30)
self.create_email_entry = QtWidgets.QLineEdit(self.admin_account_frame)
self.create_email_entry.setGeometry(QtCore.QRect(150, 280, 200, 30))
self.create_email_entry.setPlaceholderText("Email Address")
self.create_password_label = self.create_QLabel("admin_account_frame", "create_password_label",
"Password", 55, 360, 300, 30)
self.create_password_entry = QtWidgets.QLineEdit(self.admin_account_frame)
self.create_password_entry.setGeometry(QtCore.QRect(150, 360, 200, 30))
self.create_password_entry.setPlaceholderText("Password")
self.birthday_label = self.create_QLabel("admin_account_frame", "birthday_label",
"Birthday (MM/DD/YY)", 370, 120, 300, 30)
self.birthday_entry = QtWidgets.QLineEdit(self.admin_account_frame)
self.birthday_entry.setGeometry(QtCore.QRect(550, 120, 200, 30))
self.birthday_entry.setPlaceholderText("Birthday (MM/DD/YY)")
self.school_label = self.create_QLabel("admin_account_frame", "school_label",
"School", 470, 200, 300, 30)
self.school_entry = QtWidgets.QLineEdit(self.admin_account_frame)
self.school_entry.setGeometry(QtCore.QRect(550, 200, 200, 30))
self.school_entry.setPlaceholderText("School")
self.security_combobox_label = self.create_QLabel("admin_account_frame", "security_combobox_label",
"Security Question", 400, 280, 300, 30)
self.security_combobox = QComboBox(self.admin_account_frame)
self.security_combobox.setGeometry(550, 280, 200, 30)
self.security_combobox.addItem("Choose Security Question")
self.security_combobox.addItem("What is your favorite color?")
self.security_combobox.addItem("What is your favorite sports team?")
self.security_combobox.addItem("What year was your first rock climbing nationals?")
self.security_combobox.addItem("What is your mother's maiden name?")
self.security_combobox.setCurrentIndex(0)
self.create_answer_label = self.create_QLabel("admin_account_frame", "create_answer_label",
"Answer", 450, 360, 300, 30)
self.create_answer_entry = QtWidgets.QLineEdit(self.admin_account_frame)
self.create_answer_entry.setGeometry(QtCore.QRect(550, 360, 200, 30))
self.create_answer_entry.setPlaceholderText("Answer")
self.create_account_button = QtWidgets.QPushButton("Create Account", self.admin_account_frame)
self.create_account_button.setGeometry(QtCore.QRect(320, 430, 260, 30))
self.create_account_button.clicked.connect(self.create_admin_account)
#self.create_account_button.setStyleSheet(SEND_BUTTON_STYLESHEET)
self.create_account_button.setObjectName("student_login_button")
self.admin_account_frame.show()
def create_admin_account(self):
first_name = self.first_name_entry.text()
last_name = self.username_entry.text()
email = self.create_email_entry.text()
password = self.create_password_entry.text()
birthday = self.birthday_entry.text()
school = self.school_entry.text()
security_question = self.security_combobox.currentText()
answer = self.create_answer_entry.text()
print("hello")
try:
sqliteConnection = sqlite3.connect('identifier.sqlite')
cursor = sqliteConnection.cursor()
query = "INSERT INTO administrators (FIRST_NAME, LAST_NAME, EMAIL_ADDRESS, PASSWORD, BIRTHDAY, SCHOOL, SECURITY_QUESTION, SECURITY_ANSWER) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
cursor.execute(query,
(first_name, last_name, email, password, birthday, school, security_question, answer))
sqliteConnection.commit()
print("hello")
self.admin_account_frame.close()
registration = QMessageBox()
registration.setText("Thanks for registration")
registration.setIcon(QMessageBox.Information)
registration.exec_()
except sqlite3.Error as error:
print("Error while connecting to SQLite database:", error)
finally:
if sqliteConnection:
sqliteConnection.close()
def admin_forgot_password_page(self):
self.forgot_password_frame = QtWidgets.QLabel()
self.forgot_password_frame.setWindowTitle("Forgot Password")
self.forgot_password_frame.setFixedSize(800, 500)
self.forgot_password_frame.move(108, 24)
self.forgot_password_frame.setPixmap(QPixmap(r"Application Pictures and Icons/Login Screen Background.png").scaledToWidth(800))
self.forgot_password_label = self.create_QLabel("forgot_password_frame", "forgot_password_label",
"Forgot Password", 20, 70, 600, 50)
# self.forgot_password_line = self.create_QFrame("forgot_password_frame", "forgot_password_line", "HLine", 10, 65,
# 600, 6)
self.email_label = self.create_QLabel("forgot_password_frame", "email_label", "Email", 20, 150, 80, 30)
self.email_entry = QtWidgets.QLineEdit(self.forgot_password_frame)
self.email_entry.setGeometry(QtCore.QRect(200, 150, 170, 30))
self.email_search_button = QtWidgets.QPushButton(" Search", self.forgot_password_frame)
self.email_search_button.setGeometry(QtCore.QRect(400, 150, 150, 30))
self.email_search_button.clicked.connect(self.admin_security_question)
self.email_search_button.setIcon(QIcon(r"Application Pictures and Icons/search-12-filled.svg"))
self.security_question_label = self.create_QLabel("forgot_password_frame", "security_question_label",
"Security Question", 20, 220, 200, 30)
self.security_question_entry = QtWidgets.QLineEdit(self.forgot_password_frame)
self.security_question_entry.setGeometry(QtCore.QRect(200, 220, 350, 30))
self.answer_label = self.create_QLabel("forgot_password_frame", "answer_label", "Answer", 20, 290, 90, 30)
self.security_answer_entry = QtWidgets.QLineEdit(self.forgot_password_frame)
self.security_answer_entry.setGeometry(QtCore.QRect(200, 290, 350, 30))
self.new_password_label = self.create_QLabel("forgot_password_frame", "new_password_label", "New Password", 20,
360, 150, 30)
self.new_password_entry = QtWidgets.QLineEdit(self.forgot_password_frame)
self.new_password_entry.setGeometry(QtCore.QRect(200, 360, 350, 30))
self.change_password_button = QtWidgets.QPushButton("Change Password", self.forgot_password_frame)
self.change_password_button.setGeometry(QtCore.QRect(300, 420, 200, 30))
self.change_password_button.clicked.connect(self.change_admin_password)
self.change_password_button.setObjectName("student_login_button")
self.forgot_password_frame.show()
"""
Gets the security question if the user ID is enter properly (Administrator side)
"""
def admin_security_question(self):
# Gets the email string
email_string = self.admin_email_entry.text()
# Connects to the database
sqliteConnection = sqlite3.connect('identifier.sqlite')
cursor = sqliteConnection.cursor()
# Executes the cursor
cursor.execute("SELECT SECURITY_QUESTION FROM administrators WHERE EMAIL_ADDRESS = ?", (email_string,))
data = cursor.fetchone()
# If data is there, then add the security question and set the text
if data:
security_question = data[0]
self.admin_security_question_entry.setText(security_question)
# If it is not there, then we know they entered the wrong info
else:
no_security_question = QMessageBox()
no_security_question.setText("Email not found")
no_security_question.setIcon(QMessageBox.Warning)
no_security_question.exec_()
self.email_entry.clear()
"""
Method that changes the admin password (similar to the student side)
"""
def change_admin_password(self):
# Retrieve the email, new password, and security answer entered by the user
email_string = self.admin_email_entry.text()
new_password_string = self.new_password_entry.text()
answer_string = self.security_answer_entry.text()
# Connect to the 'identifier.sqlite' database
sqliteConnection = sqlite3.connect('identifier.sqlite')
cursor = sqliteConnection.cursor()
# Execute a SELECT query to retrieve the security answer from the administrators table for the given email address
cursor.execute("SELECT SECURITY_ANSWER FROM administrators WHERE EMAIL_ADDRESS = ?", (email_string,))
answer = cursor.fetchone()
# Check if a valid security answer was retrieved
if answer:
# Compare the retrieved security answer with the answer provided by the user
if answer[0] == answer_string:
# Update the password in the administrators table for the given email address and security answer
cursor.execute("UPDATE administrators SET PASSWORD = ? WHERE EMAIL_ADDRESS = ? AND SECURITY_ANSWER = ?",
(new_password_string, email_string, answer_string))
sqliteConnection.commit()
# Show a message box indicating that the password has been updated successfully
updated_password = QMessageBox()
updated_password.setText("Your Password has been updated!")
updated_password.setIcon(QMessageBox.Information)
updated_password.exec_()
else:
# Show a message box indicating that the provided information is incorrect
wrong_answer = QMessageBox()
wrong_answer.setText("Incorrect information provided")
wrong_answer.setIcon(QMessageBox.Warning)
wrong_answer.exec_()
"""
This method sets up the main frame of the system once the login verification has been passed
"""
def setup_portal(self):
global username # Global variable to store the username
global password # Global variable to store the password
global user # Global variable to store user information
sending_button = self.login_widget_container.sender().objectName()
# Get the object name of the sender from the login_widget_container
if sending_button == "student_login_button":
# Check if the sending_button is the student login button
sqliteConnection = sqlite3.connect('identifier.sqlite')
# Connect to the 'identifier.sqlite' database
cursor = sqliteConnection.cursor()
cursor.execute("SELECT EMAIL_ADDRESS, PASSWORD, FIRST_NAME, LAST_NAME FROM students")
# Execute a SELECT query to retrieve data from the 'students' table
student_rows = cursor.fetchall()
# Fetch all the rows returned by the query
cursor.close()
for user in student_rows:
# Iterate through the student rows
if self.student_username.text() == user[0] and self.student_password.text() == user[1]:
# Check if the entered username and password match the current student row
self.initialize_student_page()
# Call the initialize_student_page method to set up the student page
break
self.student_login_button.move(80, 320)
# Adjust the position of the student login button
self.student_or_label.move(190, 340)
# Adjust the position of the student "or" label
self.student_create_account.move(80, 380)
# Adjust the position of the student create account button
self.student_incorrect_login.show()
# Show the student incorrect login message
elif sending_button == "administrator_login_button":
# Check if the sending_button is the administrator login button
sqliteConnection = sqlite3.connect('identifier.sqlite')
# Connect to the 'identifier.sqlite' database
cursor = sqliteConnection.cursor()
cursor.execute("SELECT EMAIL_ADDRESS, PASSWORD FROM administrators")
# Execute a SELECT query to retrieve data from the 'administrators' table
admin_rows = cursor.fetchall()
# Fetch all the rows returned by the query
cursor.close()
for user in admin_rows:
# Iterate through the administrator rows
if self.administrator_username.text() == user[0] and self.administrator_password.text() == user[1]:
# Check if the entered username and password match the current administrator row
self.initialize_administrator_page()
# Call the initialize_administrator_page method to set up the administrator page
break
self.administrator_login_button.move(480, 320)
# Adjust the position of the administrator login button
self.administrator_or_label.move(590, 340)
# Adjust the position of the administrator "or" label
self.administrator_create_account.move(480, 380)
# Adjust the position of the administrator create account button
self.administrator_incorrect_login.show()
# Show the administrator incorrect login message
"""
Initializes the student page when users log in properly
"""
def initialize_student_page(self):
# Delete the login_central_widget
self.login_central_widget.deleteLater()
# Set the fixed size of the main_window
main_window.setFixedSize(1150, 650)
# Center the main_window on the screen
qtRectangle = main_window.frameGeometry()
centerPoint = QDesktopWidget().availableGeometry().center()
qtRectangle.moveCenter(centerPoint)
main_window.move(qtRectangle.topLeft())
# Create and set up the central_widget with a background image
self.central_widget = QtWidgets.QLabel(main_window)
self.central_widget.setObjectName("central_widget")
self.central_widget.resize(1150, 650)
self.central_widget.setPixmap(QtGui.QPixmap("Application Pictures and Icons/589.jpg"))
# Create and position the tab_widget_panel
self.tab_widget_panel = QtWidgets.QLabel(self.central_widget)
self.tab_widget_panel.resize(178, 650)
self.tab_widget_panel.move(0, 0)
self.tab_widget_panel.setStyleSheet("background-color:#202020")
# Create and position the app_logo
self.app_logo = QtWidgets.QLabel(self.central_widget)
self.app_logo.setFixedSize(140, 140)
self.app_logo.move(20, 10)
self.app_logo.setPixmap(QtGui.QPixmap("Application Pictures and Icons/Time_Track_Icon-removebg-preview.png"))
self.app_logo.setScaledContents(True)
self.app_logo.show()
# Create and position the log_out_button
self.log_out_button = self.create_QPushButton("central_widget", "log_out", "None",
"Application Pictures and Icons/Log Out.png", 980, -50, 160, 160)
self.log_out_button.setIconSize(QtCore.QSize(150, 150))
self.log_out_button.setFlat(True)
self.log_out_button.clicked.connect(self.return_to_login_screen)
# Connect to the 'identifier.sqlite' database and retrieve user details
sqliteConnection = sqlite3.connect('identifier.sqlite')
cursor = sqliteConnection.cursor()
# Setting the values to the database values
username = user[0]
password = user[1]
first_name = user[2]
last_name = user[3]
# Execute the cursor
cursor.execute(
"SELECT * FROM students WHERE EMAIL_ADDRESS = ? AND PASSWORD = ? AND FIRST_NAME = ? AND LAST_NAME = ?",
(username, password, first_name, last_name))
self.logged_in_user_details = cursor.fetchall()
cursor.close()
# Set up the student page with the retrieved user details
self.setup_student_page(first_name, last_name)
main_window.setCentralWidget(self.central_widget)
# self.status_bar = QtWidgets.QStatusBar(main_window)
# main_window.setStatusBar(self.status_bar)
"""
Initializes the administrator page when users log in properly
"""
def initialize_administrator_page(self):
# Delete the login central widget
self.login_central_widget.deleteLater()
# Set the size of the main window
main_window.setFixedSize(1150, 650)
# Create and set up the central widget
self.central_widget = QtWidgets.QLabel(main_window)
self.central_widget.setObjectName("central_widget")
self.central_widget.resize(1150, 650)
self.central_widget.setPixmap(QtGui.QPixmap("Application Pictures and Icons/589.jpg"))
# Create and set up the tab widget panel
self.tab_widget_panel = QtWidgets.QLabel(self.central_widget)
self.tab_widget_panel.resize(178, 650)
self.tab_widget_panel.move(0, 0)
self.tab_widget_panel.setStyleSheet("background-color:#202020")
# Create and set up the application logo
self.app_logo = QtWidgets.QLabel(self.central_widget)
self.app_logo.setFixedSize(140, 140)
self.app_logo.move(20, 10)
self.app_logo.setPixmap(QtGui.QPixmap("Application Pictures and Icons/Time_Track_Icon-removebg-preview.png"))
self.app_logo.setScaledContents(True)
self.app_logo.show()
# Create and set up the log out button
self.log_out_button = self.create_QPushButton("central_widget", "log_out", "None",
"Application Pictures and Icons/Log Out.png", 980, -50, 160, 160)
self.log_out_button.setIconSize(QtCore.QSize(150, 150))
self.log_out_button.setFlat(True)
self.log_out_button.clicked.connect(self.return_to_login_screen)
# Set up the admin page
self.setup_admin_page()
# Set the central widget for the main window
main_window.setCentralWidget(self.central_widget)
# Uncomment the following lines if you want to create a status bar
# Create and set up the status bar
# self.status_bar = QtWidgets.QStatusBar(main_window)
# main_window.setStatusBar(self.status_bar)
def setup_student_page(self, first_name, last_name):
global dashboard_slideshow
global slideshow_title
global slideshow_description
global kill_thread_boolean
global threadpool
global map
user_details.get_user_details.__init__(self)
self.tab_widget = VerticalTabWidget(self.central_widget)
self.tab_widget.setObjectName("tab_widget")
self.tab_widget.resize(1150, 650)
self.tab_widget.move(0, 55)
self.dashboard_tab = QtWidgets.QLabel()
self.upcoming_events_tab = QtWidgets.QWidget()
self.maps_tab = QtWidgets.QWidget()