update events via wrapper routers

This commit is contained in:
2025-01-16 19:32:59 +03:00
parent 049a7c1e11
commit 426b69b33c
42 changed files with 2344 additions and 460 deletions

View File

@@ -1,5 +1,5 @@
# SQL Models
from Schemas.account.account import (
from .account.account import (
AccountBooks,
AccountCodeParser,
AccountRecords,
@@ -8,18 +8,18 @@ from Schemas.account.account import (
AccountMaster,
AccountRecordExchanges,
)
from Schemas.building.budget import (
from .building.budget import (
DecisionBookBudgetBooks,
DecisionBookBudgetCodes,
DecisionBookBudgetMaster,
DecisionBookBudgets,
)
from Schemas.account.iban import (
from .account.iban import (
BuildIbans,
BuildIbanDescription,
)
from Schemas.api.encrypter import CrypterEngine
from Schemas.building.build import (
from .api.encrypter import CrypterEngine
from .building.build import (
Build,
BuildTypes,
BuildParts,
@@ -30,7 +30,7 @@ from Schemas.building.build import (
BuildCompaniesProviding,
RelationshipEmployee2Build,
)
from Schemas.building.decision_book import (
from .building.decision_book import (
BuildDecisionBook,
BuildDecisionBookItems,
BuildDecisionBookPerson,
@@ -43,22 +43,22 @@ from Schemas.building.decision_book import (
BuildDecisionBookPersonOccupants,
BuildDecisionBookProjectItems,
)
from Schemas.company.company import (
from .company.company import (
Companies,
RelationshipDutyCompany,
)
from Schemas.company.employee import (
from .company.employee import (
Employees,
EmployeesSalaries,
EmployeeHistory,
Staff,
)
from Schemas.company.department import (
from .company.department import (
Duty,
Duties,
Departments,
)
from Schemas.event.event import (
from .event.event import (
Modules,
Services,
Service2Events,
@@ -68,7 +68,7 @@ from Schemas.event.event import (
Event2OccupantExtra,
Event2EmployeeExtra,
)
from Schemas.identity.identity import (
from .identity.identity import (
Addresses,
AddressCity,
AddressStreet,
@@ -87,10 +87,10 @@ from Schemas.identity.identity import (
RelationshipEmployee2PostCode,
Contracts,
)
from Schemas.others.enums import (
from .others.enums import (
ApiEnumDropdown,
)
from Schemas.rules.rules import (
from .rules.rules import (
EndpointRestriction,
)

View File

@@ -138,6 +138,10 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
def is_occupant(self):
return not str(self.email).split("@")[1] == Auth.ACCESS_EMAIL_EXT
@property
def is_employee(self):
return str(self.email).split("@")[1] == Auth.ACCESS_EMAIL_EXT
@property
def password_expiry_ends(self):
"""Calculates the expiry end date based on expiry begins and expires day"""
@@ -165,8 +169,10 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
@classmethod
def create_action(cls, create_user: InsertUsers, token_dict):
db_session = cls.new_session()
found_person = People.filter_one(
People.uu_id == create_user.people_uu_id,
db=db_session,
).data
if not found_person:
@@ -192,7 +198,10 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
@classmethod
def credentials(cls):
person_object = People.filter_by_one(system=True, id=cls.person_id).data
db_session = cls.new_session()
person_object = People.filter_by_one(
db=db_session, system=True, id=cls.person_id
).data
if person_object:
return {
"person_id": person_object.id,
@@ -206,17 +215,20 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
def get_employee_and_duty_details(self):
from Schemas import Employees, Duties
db_session = self.new_session()
found_person = People.filter_one(
People.id == self.person_id,
db=db_session,
)
found_employees = Employees.filter_by_active(
people_id=found_person.id, is_confirmed=True
people_id=found_person.id, is_confirmed=True, db=db_session
)
found_duties = Duties.filter_all(
Duties.is_confirmed == True,
Duties.id.in_(
list(found_employee.duty_id for found_employee in found_employees.data)
),
db=db_session,
)
if not found_employees.count:
raise HTTPException(