-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
92 lines (79 loc) · 3.42 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
from PyQt5.QtWidgets import QMainWindow, QLineEdit
from PyQt5.QtGui import QIcon
import hashlib
from data.all_models import *
from main_window import MainWindow
from PyQt5 import uic
from utitlities import *
from data.config import *
class Enter(QMainWindow):
def __init__(self):
super().__init__()
uic.loadUi(ENTER_UI, self)
self.setWindowTitle('Авторизация')
self.setWindowIcon(QIcon(ICON))
# подключаем кнопки
self.admin_push_button.clicked.connect(self.set_admin_user)
self.doctor_push_button.clicked.connect(self.set_doctor_user)
self.enter_push_button.clicked.connect(self.enter)
self.exit_push_button.clicked.connect(self.exit)
self.password_line_edit.setEchoMode(QLineEdit.Password)
self.exit_push_button.setStyleSheet("QPushButton"
"{"
"background-color : lightgrey;"
"}")
self.admin_push_button.setStyleSheet("QPushButton"
"{"
"background-color : lightgrey;"
"}")
# объявление переменных
self.user_names = ADMINS
self.set_usernames()
def set_admin_user(self):
self.admin_push_button.setStyleSheet("QPushButton"
"{"
"background-color : lightgrey;"
"}")
self.doctor_push_button.setStyleSheet("QPushButton"
"{"
"background-color : white;"
"}")
self.user_names = ADMINS
self.set_usernames()
def set_doctor_user(self):
self.doctor_push_button.setStyleSheet("QPushButton"
"{"
"background-color : lightgrey;"
"}")
self.admin_push_button.setStyleSheet("QPushButton"
"{"
"background-color : white;"
"}"
)
self.user_names = DOCTORS
self.set_usernames()
def set_usernames(self):
self.users_combo_box.clear()
self.users_combo_box.addItems(self.user_names)
def enter(self):
if self.check_password():
self.main_window = MainWindow(self.users_combo_box.currentText(), self.user_names)
self.main_window.show()
self.hide()
else:
self.password_label.setText('Пароль не подходит')
def check_password(self):
name = self.users_combo_box.currentText()
if self.user_names == ADMINS:
member = Admin.get(Admin.current_name == name)
else:
member = Doctor.get(Doctor.current_name == name)
salt = '123'.encode('utf-8')
key = hashlib.pbkdf2_hmac(
'sha256',
self.password_line_edit.text().encode('utf-8'),
salt,
100000)
return member.password == key
def exit(self):
quit()