._.
This commit is contained in:
parent
f6cc0558c8
commit
68b858be84
@ -3,7 +3,7 @@ import datetime
|
||||
from PyQt6 import uic
|
||||
from PyQt6.QtWidgets import QDialog, QWidget, QHBoxLayout, QLabel, QDateEdit, QMessageBox
|
||||
|
||||
from data.connect import connect, Event, UserEvent, EventType, Attendance, VacationTimetable
|
||||
from data.connect import connect, Event, UserEvent, EventType, Attendance, VacationTimetable, WorkingCalendar
|
||||
|
||||
|
||||
class EventsListDialog(QDialog):
|
||||
@ -57,6 +57,16 @@ class EventsListDialog(QDialog):
|
||||
type_id=type_edu_event.id,
|
||||
datetime_event=self.dateEdit.date().toPyDate()
|
||||
)
|
||||
|
||||
for attendance in self.attendances:
|
||||
if self.dateEdit.date().toPyDate() == attendance.date:
|
||||
QMessageBox.warning(
|
||||
self,
|
||||
'Внимание',
|
||||
'Обучение и отгул не могут быть в одни и те же даты'
|
||||
)
|
||||
return
|
||||
|
||||
session.add(new_event)
|
||||
session.flush()
|
||||
|
||||
@ -73,6 +83,37 @@ class EventsListDialog(QDialog):
|
||||
reason=self.lineEdit.text() if self.lineEdit.text() else None,
|
||||
user_id=self.user.id,
|
||||
)
|
||||
|
||||
for vacation in self.vacations:
|
||||
if vacation.start_date <= new_attendance.date <= vacation.end_date:
|
||||
QMessageBox.warning(
|
||||
self,
|
||||
'Внимание',
|
||||
'Отпуск и отгул не могут быть в одни и те же даты'
|
||||
)
|
||||
return
|
||||
|
||||
for curse in self.curses:
|
||||
if curse.datetime_event.date() == vacation.date:
|
||||
QMessageBox.warning(
|
||||
self,
|
||||
'Внимание',
|
||||
'Обучение и отгул не могут быть в одни и те же даты'
|
||||
)
|
||||
return
|
||||
|
||||
with connect() as session:
|
||||
calendars = session.query(WorkingCalendar).all()
|
||||
|
||||
for calendar in calendars:
|
||||
if not calendar.isworkingday and calendar.exceptiondate == vacation.date:
|
||||
QMessageBox.warning(
|
||||
self,
|
||||
'Внимание',
|
||||
'Отгул не может быть взят на выходной день'
|
||||
)
|
||||
return
|
||||
|
||||
with connect() as session:
|
||||
session.add(new_attendance)
|
||||
session.commit()
|
||||
@ -83,6 +124,16 @@ class EventsListDialog(QDialog):
|
||||
start_date=self.dateEdit.date().toPyDate(),
|
||||
end_date=self.dateEdit_2.date().toPyDate()
|
||||
)
|
||||
|
||||
for attendance in self.attendances:
|
||||
if new_vacation.start_date <= attendance.date <= new_vacation.end_date:
|
||||
QMessageBox.warning(
|
||||
self,
|
||||
'Внимание',
|
||||
'Отпуск и отгул не могут быть в одни и те же даты'
|
||||
)
|
||||
return
|
||||
|
||||
with connect() as session:
|
||||
session.add(new_vacation)
|
||||
session.commit()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user