43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
from PyQt6 import uic
|
|
from PyQt6.QtWidgets import QWidget
|
|
|
|
from Desktop.events_list_dialog import EventsListDialog
|
|
from data.connect import connect, Department, Post
|
|
|
|
|
|
class EmployeeCardWidget(QWidget):
|
|
def __init__(self, user):
|
|
super().__init__()
|
|
|
|
uic.loadUi('ui/card_widget.ui', self)
|
|
|
|
if user.is_dismissed:
|
|
self.setStyleSheet('''
|
|
QWidget {
|
|
background-color: rgba(150, 150, 150, 150);
|
|
}
|
|
''')
|
|
self.pushButton.setEnabled(False)
|
|
else:
|
|
self.setStyleSheet('''
|
|
QWidget {
|
|
background-color: rgb(228, 244, 204);
|
|
}
|
|
''')
|
|
|
|
with connect() as session:
|
|
department = session.query(Department).filter(Department.id == user.department_id).first()
|
|
post = session.query(Post).filter(Post.id == user.post_id).first()
|
|
|
|
if department is not None and post is not None:
|
|
self.label.setText(f'{department.title} - {post.title}')
|
|
|
|
if user.last_name is not None and user.first_name is not None and user.patronymic is not None:
|
|
self.label_2.setText(f'{user.last_name} {user.first_name} {user.patronymic}')
|
|
|
|
if user.work_phone is not None and user.email is not None:
|
|
self.label_3.setText(f'{user.work_phone} {user.email}')
|
|
|
|
if user.office is not None:
|
|
self.label_4.setText(f'{user.office}')
|