migrator functions updated
This commit is contained in:
@@ -37,7 +37,7 @@ class UsersTokens(CrudCollection):
|
||||
token: Mapped[str] = mapped_column(String, server_default="")
|
||||
domain: Mapped[str] = mapped_column(String, server_default="")
|
||||
expires_at = mapped_column(
|
||||
TIMESTAMP, default=str(system_arrow.shift(date=system_arrow.now(),days=3))
|
||||
TIMESTAMP, default=str(system_arrow.shift(date=system_arrow.now(), days=3))
|
||||
)
|
||||
|
||||
# users = relationship("Users", back_populates="tokens", foreign_keys=[user_id])
|
||||
@@ -162,65 +162,21 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
|
||||
return created_user
|
||||
|
||||
@classmethod
|
||||
def created_creds(cls, create_creds: bool = True):
|
||||
person_object = People.find_one(id=cls.person_id)
|
||||
if create_creds:
|
||||
return {
|
||||
"created_by_id": person_object.id,
|
||||
"created_by": str(person_object.firstname)
|
||||
+ " "
|
||||
+ str(person_object.surname),
|
||||
}
|
||||
def credentials(cls):
|
||||
person_object = People.filter_by_one(system=True, id=cls.person_id).data
|
||||
if not person_object:
|
||||
raise HTTPException(
|
||||
status_code=401,
|
||||
detail="Person not found. Please contact the admin.",
|
||||
)
|
||||
return {
|
||||
"updated_by_id": person_object.id,
|
||||
"updated_by": str(person_object.firstname)
|
||||
+ " "
|
||||
+ str(person_object.surname),
|
||||
"person_id": person_object.id,
|
||||
"person_uu_id": str(person_object.uu_id),
|
||||
}
|
||||
|
||||
#
|
||||
# def prepare_employee_token_object(self, selected_duty_uu_id):
|
||||
# from database_sql_models import (
|
||||
# Companies,
|
||||
# Employees,
|
||||
# Duties,
|
||||
# Departments,
|
||||
# )
|
||||
# found_person = People.find_one(id=self.person_id)
|
||||
# found_employee = Employees.find_one(people_id=found_person.id)
|
||||
# found_duty = Duties.find_one(uu_id=selected_duty_uu_id)
|
||||
# found_department = Departments.find_one(id=found_duty.department_id)
|
||||
# found_company = Companies.find_one(id=found_department.company_id)
|
||||
# return {
|
||||
# "people": {
|
||||
# "people_id": found_person.id,
|
||||
# "people_uu_id": found_person.uu_id.__str__(),
|
||||
# },
|
||||
# "user": {
|
||||
# "user_id": self.id,
|
||||
# "user_uu_id": self.uu_id.__str__(),
|
||||
# },
|
||||
# "duty": {
|
||||
# "duty_id": found_duty.id,
|
||||
# "duty_uu_id": found_duty.uu_id.__str__()
|
||||
# },
|
||||
# "employee": {
|
||||
# "employee_id": found_employee.id,
|
||||
# "employee_uu_id": found_employee.uu_id.__str__(),
|
||||
# "people_id": found_employee.people_id,
|
||||
# },
|
||||
# "department": {
|
||||
# "department_id": found_department.id,
|
||||
# "department_uu_id": found_department.uu_id.__str__(),
|
||||
# },
|
||||
# "company": {
|
||||
# "company_id": found_company.id,
|
||||
# "company_uu_id": found_company.uu_id.__str__()
|
||||
# },
|
||||
# }
|
||||
|
||||
def get_employee_and_duty_details(self):
|
||||
from databases import Employees, Duties
|
||||
|
||||
found_person = People.find_one(id=self.person_id)
|
||||
found_employees = Employees.filter_by_active(
|
||||
people_id=found_person.id, is_confirmed=True
|
||||
@@ -383,6 +339,7 @@ class People(CrudCollection, SelectAction):
|
||||
@classmethod
|
||||
def create_action(cls, data: InsertPerson, token):
|
||||
from databases import Employees, Duties
|
||||
|
||||
token_duties_id, token_company_id = (
|
||||
token.selected_company.duty_id,
|
||||
token.selected_company.company_id,
|
||||
@@ -498,7 +455,9 @@ class Addresses(CrudCollection):
|
||||
post_code_list = RelationshipEmployee2PostCode.filter_all(
|
||||
RelationshipEmployee2PostCode.employee_id
|
||||
== token_dict.selected_company.employee_id,
|
||||
*RelationshipEmployee2PostCode.valid_record_args(RelationshipEmployee2PostCode)
|
||||
*RelationshipEmployee2PostCode.valid_record_args(
|
||||
RelationshipEmployee2PostCode
|
||||
),
|
||||
).data
|
||||
post_code_id_list = [post_code.member_id for post_code in post_code_list]
|
||||
if not post_code_id_list:
|
||||
|
||||
Reference in New Issue
Block a user