This commit is contained in:
Андрей Дувакин 2025-01-15 23:11:55 +05:00
parent 6e857a842d
commit e522b0fb3f
8 changed files with 244 additions and 270 deletions

View File

@ -48,6 +48,7 @@ class User(base):
post = relationship('Post', back_populates='users')
comments = relationship('Comment', back_populates='user')
users_event = relationship('UserEvent', back_populates='user')
class DepartmentUser(base):
@ -131,6 +132,8 @@ class EventType(base):
id = Column(Integer, primary_key=True, autoincrement=True)
title = Column(VARCHAR(100))
events = relationship('Event', back_populates='type')
class EventStatus(base):
__tablename__ = 'event_statuses'
@ -150,6 +153,9 @@ class Event(base):
type_id = Column(Integer, ForeignKey('event_types.id'))
status_id = Column(Integer, ForeignKey('event_statuses.id'))
type = relationship('EventType', back_populates='events')
users_event = relationship('UserEvent', back_populates='event')
class DepartmentEvent(base):
__tablename__ = 'department_events'
@ -174,6 +180,9 @@ class UserEvent(base):
event_id = Column(Integer, ForeignKey('events.id'))
user_id = Column(Integer, ForeignKey('users.id'))
event = relationship('Event', back_populates='users_event')
user = relationship('User', back_populates='users_event')
class WorkingCalendar(base):
__tablename__ = 'workingcalendar'
@ -191,7 +200,7 @@ class Attendance(base):
is_attended = Column(Boolean)
reason = Column(Text)
user = Column(Integer, ForeignKey('users.id'))
user_id = Column(Integer, ForeignKey('users.id'))
class VacationTimetable(base):
@ -201,7 +210,7 @@ class VacationTimetable(base):
start_date = Column(Date)
end_date = Column(Date)
user = Column(Integer, ForeignKey('users.id'))
user_id = Column(Integer, ForeignKey('users.id'))
def init_db():

View File

@ -1,6 +1,7 @@
from PyQt6 import uic
from PyQt6.QtWidgets import QWidget
from Desktop.events_list_dialog import EventsListDialog
from data.connect import connect, Department, Post

View File

@ -10,8 +10,6 @@ class EmployeeDialogWidget(QDialog):
uic.loadUi('ui/employee_dialog_window.ui', self)
self.pushButton.clicked.connect(self.close)
self.lineEdit_5.setText(department.title)
self.user = user

View File

@ -0,0 +1,21 @@
from PyQt6 import uic
from PyQt6.QtWidgets import QDialog
from data.connect import connect, Event, UserEvent, EventType, Attendance, VacationTimetable
class EventsListDialog(QDialog):
def __init__(self, user):
super().__init__()
uic.loadUi('ui/events_dialog_window.ui', self)
with connect() as session:
self.curses = session.query(Event).join(UserEvent).join(EventType).filter(
UserEvent.user_id == user.id,
EventType.title == 'Обучение'
).all()
self.attendances = session.query(Attendance).filter(Attendance.user_id == user.id).all()
self.vacations = session.query(VacationTimetable).filter(VacationTimetable.user_id == user.id).all()

View File

@ -1,6 +1,7 @@
from PyQt6 import uic
from PyQt6.QtWidgets import QMainWindow
from Desktop.events_list_dialog import EventsListDialog
from employee_dialog_widget import EmployeeDialogWidget
from employee_card_widget import EmployeeCardWidget
from data.connect import connect, User, Department
@ -46,7 +47,10 @@ class MainWindow(QMainWindow):
button = self.sender()
employee = button.employee
self.create_employee_dialog = EmployeeDialogWidget(self.selected_department, self.department_employees, self, employee)
edit_widget = EmployeeDialogWidget(self.selected_department, self.department_employees, self,
employee)
self.create_employee_dialog = EventsListDialog(employee)
self.create_employee_dialog.gridLayout_2.addWidget(edit_widget)
self.create_employee_dialog.exec()
def search_employees(self, department_id):

View File

@ -32,6 +32,33 @@ background-color: #2f9836;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="8" column="1">
<widget class="QLineEdit" name="lineEdit_6">
<property name="inputMask">
<string>+7 (000) 000-00-00</string>
</property>
<property name="maxLength">
<number>18</number>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer_2">
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="21" column="1">
<widget class="QLineEdit" name="lineEdit_9">
<property name="placeholderText">
<string>Прочая информация</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit">
<property name="placeholderText">
@ -39,6 +66,20 @@ background-color: #2f9836;
</property>
</widget>
</item>
<item row="19" column="1">
<widget class="QLineEdit" name="lineEdit_7">
<property name="placeholderText">
<string>Электронная почта</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Рабочий телефон</string>
</property>
</widget>
</item>
<item row="2" column="2">
<spacer name="horizontalSpacer_2">
<property name="sizeHint" stdset="0">
@ -59,54 +100,17 @@ background-color: #2f9836;
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="1">
<widget class="QLabel" name="label_4">
<item row="5" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>Рабочий телефон</string>
<string>Мобильный телефон</string>
</property>
</widget>
</item>
<item row="23" column="1">
<spacer name="verticalSpacer">
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="19" column="1">
<widget class="QLineEdit" name="lineEdit_7">
<property name="placeholderText">
<string>Электронная почта</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QLineEdit" name="lineEdit_5">
<item row="9" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string/>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Департамент</string>
<string>Дата рождения</string>
</property>
</widget>
</item>
@ -120,10 +124,34 @@ background-color: #2f9836;
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton">
<item row="12" column="1">
<widget class="QLineEdit" name="lineEdit_5">
<property name="text">
<string>Назад</string>
<string/>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Должность</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_2">
<property name="placeholderText">
<string>Имя</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Департамент</string>
</property>
</widget>
</item>
@ -140,8 +168,8 @@ background-color: #2f9836;
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer_2">
<item row="23" column="1">
<spacer name="verticalSpacer">
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
@ -163,8 +191,15 @@ background-color: #2f9836;
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer_4">
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_3">
<property name="placeholderText">
<string>Отчество</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
@ -180,13 +215,6 @@ background-color: #2f9836;
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_2">
<property name="placeholderText">
<string>Имя</string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
@ -194,78 +222,18 @@ background-color: #2f9836;
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Должность</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_3">
<property name="placeholderText">
<string>Отчество</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="lineEdit_6">
<property name="inputMask">
<string>+7 (000) 000-00-00</string>
</property>
<property name="maxLength">
<number>18</number>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>Мобильный телефон</string>
</property>
</widget>
</item>
<item row="21" column="1">
<widget class="QLineEdit" name="lineEdit_9">
<property name="placeholderText">
<string>Прочая информация</string>
</property>
</widget>
</item>
<item row="16" column="1">
<widget class="QComboBox" name="comboBox_2"/>
</item>
<item row="9" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Дата рождения</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="minimumSize">
<item row="2" column="0">
<spacer name="horizontalSpacer_4">
<property name="sizeHint" stdset="0">
<size>
<width>80</width>
<height>80</height>
<width>40</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>../res/Logo.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</spacer>
</item>
</layout>
</widget>
@ -282,25 +250,7 @@ background-color: #2f9836;
<tabstop>lineEdit_8</tabstop>
<tabstop>lineEdit_9</tabstop>
<tabstop>pushButton_2</tabstop>
<tabstop>pushButton</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>Dialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>616</x>
<y>27</y>
</hint>
<hint type="destinationlabel">
<x>630</x>
<y>228</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>718</width>
<height>579</height>
<width>1020</width>
<height>682</height>
</rect>
</property>
<property name="minimumSize">
@ -32,50 +32,6 @@ background-color: #2f9836;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="4">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Назад</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2">
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>305</width>
<height>529</height>
</rect>
</property>
</widget>
</widget>
</item>
<item row="1" column="2" colspan="3">
<widget class="QScrollArea" name="scrollArea_2">
<property name="widgetResizable">
@ -86,8 +42,8 @@ background-color: #2f9836;
<rect>
<x>0</x>
<y>0</y>
<width>385</width>
<height>529</height>
<width>923</width>
<height>606</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
@ -126,8 +82,8 @@ background-color: #2f9836;
<rect>
<x>0</x>
<y>0</y>
<width>365</width>
<height>477</height>
<width>903</width>
<height>554</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
@ -169,8 +125,40 @@ background-color: #2f9836;
</widget>
</widget>
</item>
<item row="0" column="0">
<spacer name="horizontalSpacer_3">
<item row="1" column="0" colspan="2">
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>69</width>
<height>606</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2"/>
</item>
</layout>
</widget>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Назад</string>
</property>
</widget>
</item>
<item row="2" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
@ -179,8 +167,24 @@ background-color: #2f9836;
</property>
</spacer>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_4">
<item row="2" column="4">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="3">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>

View File

@ -25,8 +25,8 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<spacer name="horizontalSpacer_3">
<item row="3" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -38,60 +38,6 @@
</property>
</spacer>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pushButton">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>21</pointsize>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">#pushButton {
background-color: rgb(228, 244, 204);
border-radius: 25px;
border: 1px solid rgb(0, 0, 0);
}</string>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>419</width>
<height>399</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2"/>
</item>
</layout>
</widget>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QWidget" name="widget" native="true">
<property name="styleSheet">
@ -166,19 +112,6 @@ border: 1px solid rgb(0, 0, 0);
</layout>
</widget>
</item>
<item row="2" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" colspan="2">
<widget class="QScrollArea" name="scrollArea_2">
<property name="widgetResizable">
@ -201,6 +134,60 @@ border: 1px solid rgb(0, 0, 0);
</widget>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="pushButton">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>21</pointsize>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">#pushButton {
background-color: rgb(228, 244, 204);
border-radius: 25px;
border: 1px solid rgb(0, 0, 0);
}</string>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>419</width>
<height>399</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusbar"/>