auth service up running
This commit is contained in:
@@ -1,35 +1,45 @@
|
||||
import typing
|
||||
from operator import or_
|
||||
from datetime import datetime, timedelta
|
||||
from platform import system
|
||||
from typing import List
|
||||
from typing import List, Optional, Union
|
||||
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
from sqlalchemy.orm import mapped_column, relationship, Mapped
|
||||
from sqlalchemy import (
|
||||
String,
|
||||
Integer,
|
||||
Boolean,
|
||||
ForeignKey,
|
||||
Index,
|
||||
SmallInteger,
|
||||
Boolean,
|
||||
TIMESTAMP,
|
||||
func,
|
||||
Text,
|
||||
Numeric,
|
||||
or_,
|
||||
)
|
||||
|
||||
from api_library.date_time_actions.date_functions import system_arrow
|
||||
from databases.sql_models.core_mixin import CrudCollection
|
||||
|
||||
from databases.extensions.selector_classes import SelectActionWithEmployee
|
||||
from api_validations.validations_request import (
|
||||
InsertBuildParts,
|
||||
InsertBuild,
|
||||
InsertBuildParts,
|
||||
InsertBuildLivingSpace,
|
||||
UpdateBuild,
|
||||
)
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
|
||||
from databases.language_models.building.build import (
|
||||
BuildTypesLanguageModel,
|
||||
Part2EmployeeLanguageModel,
|
||||
BuildPartsLanguageModel,
|
||||
BuildSitesLanguageModel,
|
||||
RelationshipEmployee2BuildLanguageModel,
|
||||
BuildLanguageModel,
|
||||
BuildPartsLanguageModel,
|
||||
BuildLivingSpaceLanguageModel,
|
||||
BuildManagementLanguageModel,
|
||||
BuildAreaLanguageModel,
|
||||
BuildCompaniesProvidingLanguageModel,
|
||||
BuildPersonProvidingLanguageModel,
|
||||
)
|
||||
|
||||
class BuildTypes(CrudCollection):
|
||||
"""
|
||||
@@ -39,6 +49,7 @@ class BuildTypes(CrudCollection):
|
||||
|
||||
__tablename__ = "build_types"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildTypesLanguageModel
|
||||
__include__fields__ = []
|
||||
|
||||
function_code: Mapped[str] = mapped_column(
|
||||
@@ -68,6 +79,7 @@ class Part2Employee(CrudCollection):
|
||||
|
||||
__tablename__ = "part2employee"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = Part2EmployeeLanguageModel
|
||||
__include__fields__ = []
|
||||
|
||||
build_id: Mapped[int] = mapped_column(Integer, comment="Building ID")
|
||||
@@ -93,6 +105,7 @@ class RelationshipEmployee2Build(CrudCollection):
|
||||
|
||||
__tablename__ = "relationship_employee2build"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = RelationshipEmployee2BuildLanguageModel
|
||||
|
||||
company_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("companies.id"), nullable=False
|
||||
@@ -129,6 +142,7 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||
|
||||
__tablename__ = "build"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildLanguageModel
|
||||
__include__fields__ = []
|
||||
__access_by__ = []
|
||||
__many__table__ = RelationshipEmployee2Build
|
||||
@@ -145,10 +159,10 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||
)
|
||||
|
||||
max_floor: Mapped[int] = mapped_column(
|
||||
SmallInteger, server_default="1", nullable=False, comment="Max Floor"
|
||||
Integer, server_default="1", nullable=False, comment="Max Floor"
|
||||
)
|
||||
underground_floor: Mapped[int] = mapped_column(
|
||||
SmallInteger, server_default="0", nullable=False, comment="Underground Floor"
|
||||
Integer, server_default="0", nullable=False, comment="Underground Floor"
|
||||
)
|
||||
build_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP(timezone=True), server_default="1900-01-01"
|
||||
@@ -159,18 +173,18 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||
comment="Building annual ordinary meeting period",
|
||||
)
|
||||
tax_no: Mapped[str] = mapped_column(String(24), server_default="")
|
||||
lift_count: Mapped[int] = mapped_column(SmallInteger, server_default="0")
|
||||
lift_count: Mapped[int] = mapped_column(Integer, server_default="0")
|
||||
heating_system: Mapped[bool] = mapped_column(Boolean, server_default="True")
|
||||
cooling_system: Mapped[bool] = mapped_column(Boolean, server_default="False")
|
||||
hot_water_system: Mapped[bool] = mapped_column(Boolean, server_default="False")
|
||||
block_service_man_count: Mapped[int] = mapped_column(
|
||||
SmallInteger, server_default="0"
|
||||
Integer, server_default="0"
|
||||
)
|
||||
security_service_man_count: Mapped[int] = mapped_column(
|
||||
SmallInteger, server_default="0"
|
||||
Integer, server_default="0"
|
||||
)
|
||||
garage_count: Mapped[int] = mapped_column(
|
||||
SmallInteger, server_default="0", comment="Garage Count"
|
||||
Integer, server_default="0", comment="Garage Count"
|
||||
)
|
||||
management_room_id: Mapped[int] = mapped_column(
|
||||
Integer, nullable=True, comment="Management Room ID"
|
||||
@@ -290,7 +304,7 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||
def top_flat(self):
|
||||
max_flat_no = 0
|
||||
for part in self.parts:
|
||||
if part.part_no > self.max_flat_no:
|
||||
if part.part_no > self.max_floor:
|
||||
max_flat_no = part.part_no
|
||||
return max_flat_no
|
||||
|
||||
@@ -298,7 +312,7 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||
def bottom_flat(self):
|
||||
min_flat_no = 0
|
||||
for part in self.parts:
|
||||
if part.part_no < self.max_flat_no:
|
||||
if part.part_no < self.max_floor:
|
||||
min_flat_no = part.part_no
|
||||
return min_flat_no
|
||||
|
||||
@@ -352,6 +366,7 @@ class BuildParts(CrudCollection):
|
||||
|
||||
__tablename__ = "build_parts"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildPartsLanguageModel
|
||||
__include__fields__ = []
|
||||
__enum_list__ = [("part_direction", "Directions", "NN")]
|
||||
|
||||
@@ -361,10 +376,10 @@ class BuildParts(CrudCollection):
|
||||
)
|
||||
# part_name: Mapped[str] = mapped_column(String(24), server_default="", nullable=False, comment="Part Name")
|
||||
part_no: Mapped[int] = mapped_column(
|
||||
SmallInteger, server_default="0", nullable=False, comment="Part Number"
|
||||
Integer, server_default="0", nullable=False, comment="Part Number"
|
||||
)
|
||||
part_level: Mapped[int] = mapped_column(
|
||||
SmallInteger, server_default="0", comment="Building Part Level"
|
||||
Integer, server_default="0", comment="Building Part Level"
|
||||
)
|
||||
part_code: Mapped[str] = mapped_column(
|
||||
String, server_default="", nullable=False, comment="Part Code"
|
||||
@@ -496,6 +511,7 @@ class BuildLivingSpace(CrudCollection):
|
||||
|
||||
__tablename__ = "build_living_space"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildLivingSpaceLanguageModel
|
||||
__include__fields__ = []
|
||||
|
||||
fix_value: Mapped[float] = mapped_column(
|
||||
@@ -513,7 +529,7 @@ class BuildLivingSpace(CrudCollection):
|
||||
String, server_default="", comment="Agreement No"
|
||||
)
|
||||
marketing_process: Mapped[bool] = mapped_column(Boolean, server_default="False")
|
||||
marketing_layer: Mapped[int] = mapped_column(SmallInteger, server_default="0")
|
||||
marketing_layer: Mapped[int] = mapped_column(Integer, server_default="0")
|
||||
|
||||
build_parts_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_parts.id"),
|
||||
@@ -550,7 +566,7 @@ class BuildLivingSpace(CrudCollection):
|
||||
def create_action(
|
||||
cls,
|
||||
data: dict,
|
||||
token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
from databases import Services, OccupantTypes
|
||||
from api_events.events.events.events_bind_modules import (
|
||||
@@ -601,6 +617,7 @@ class BuildManagement(CrudCollection):
|
||||
|
||||
__tablename__ = "build_management"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildManagementLanguageModel
|
||||
|
||||
discounted_percentage: Mapped[float] = mapped_column(
|
||||
Numeric(6, 2), server_default="0.00"
|
||||
@@ -655,6 +672,7 @@ class BuildArea(CrudCollection):
|
||||
|
||||
__tablename__ = "build_area"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildAreaLanguageModel
|
||||
|
||||
area_name: Mapped[str] = mapped_column(String, server_default="")
|
||||
area_code: Mapped[str] = mapped_column(String, server_default="")
|
||||
@@ -690,6 +708,7 @@ class BuildSites(CrudCollection):
|
||||
|
||||
__tablename__ = "build_sites"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildSitesLanguageModel
|
||||
__include__fields__ = []
|
||||
|
||||
site_name: Mapped[str] = mapped_column(String(24), nullable=False)
|
||||
@@ -716,6 +735,7 @@ class BuildCompaniesProviding(CrudCollection):
|
||||
|
||||
__tablename__ = "build_companies_providing"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildCompaniesProvidingLanguageModel
|
||||
__include__fields__ = []
|
||||
|
||||
build_id = mapped_column(
|
||||
@@ -755,6 +775,7 @@ class BuildPersonProviding(CrudCollection):
|
||||
|
||||
__tablename__ = "build_person_providing"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildPersonProvidingLanguageModel
|
||||
__include__fields__ = []
|
||||
|
||||
build_id = mapped_column(
|
||||
@@ -787,75 +808,3 @@ class BuildPersonProviding(CrudCollection):
|
||||
),
|
||||
{"comment": "People providing services for building"},
|
||||
)
|
||||
|
||||
|
||||
# owner_people: Mapped["People"] = relationship(
|
||||
# "People",
|
||||
# back_populates="owner_buildings",
|
||||
# foreign_keys=[current_owner_person_id],
|
||||
# )
|
||||
# tenant_people: Mapped["People"] = relationship(
|
||||
# "People",
|
||||
# back_populates="tenant_buildings",
|
||||
# foreign_keys=[current_tenant_person_id],
|
||||
# )
|
||||
# decision_book_management: Mapped[List["BuildDecisionBookManagement"]] = (
|
||||
# relationship(
|
||||
# "BuildDecisionBookManagement",
|
||||
# back_populates="buildings",
|
||||
# foreign_keys="BuildDecisionBookManagement.build_parts_id",
|
||||
# )
|
||||
# )
|
||||
# budget_records: Mapped[List["CompanyBudgetRecords"]] = relationship(
|
||||
# "CompanyBudgetRecords",
|
||||
# back_populates="parts",
|
||||
# foreign_keys="CompanyBudgetRecords.build_parts_id",
|
||||
# )
|
||||
# living_spaces: Mapped[List["BuildLivingSpace"]] = relationship(
|
||||
# "BuildLivingSpace",
|
||||
# back_populates="parts",
|
||||
# foreign_keys="BuildLivingSpace.build_parts_id",
|
||||
# )
|
||||
# decision_book_payment_master: Mapped[List["BuildDecisionBookPaymentsMaster"]] = (
|
||||
# relationship(
|
||||
# "BuildDecisionBookPaymentsMaster",
|
||||
# back_populates="parts",
|
||||
# foreign_keys="BuildDecisionBookPaymentsMaster.build_parts_id",
|
||||
# )
|
||||
# )
|
||||
# decision_book_project_payments_master: Mapped[
|
||||
# "BuildDecisionBookProjectPaymentsMaster"
|
||||
# ] = relationship(
|
||||
# "BuildDecisionBookProjectPaymentsMaster",
|
||||
# back_populates="parts",
|
||||
# foreign_keys="BuildDecisionBookProjectPaymentsMaster.build_parts_id",
|
||||
# )
|
||||
# search_iban_description: Mapped["BuildIbanDescription"] = relationship(
|
||||
# "BuildIbanDescription",
|
||||
# back_populates="parts",
|
||||
# foreign_keys="BuildIbanDescription.build_parts_id",
|
||||
# )
|
||||
|
||||
# parts: Mapped[List["BuildParts"]] = relationship(
|
||||
# "BuildParts", back_populates="living_spaces", foreign_keys=[build_parts_id]
|
||||
# )
|
||||
# owner_people: Mapped["People"] = relationship(
|
||||
# "People", back_populates="owner_living_spaces", foreign_keys=[owner_person_id]
|
||||
# )
|
||||
# life_people: Mapped["People"] = relationship(
|
||||
# "People", back_populates="life_living_spaces", foreign_keys=[life_person_id]
|
||||
# )
|
||||
# company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"))
|
||||
# response_company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"))
|
||||
# person_id: Mapped[int] = mapped_column(ForeignKey("people.id"))
|
||||
|
||||
# companies: Mapped["Companies"] = relationship(
|
||||
# "Companies", back_populates="buildings", foreign_keys=[company_id]
|
||||
# )
|
||||
# @classmethod
|
||||
# def select_action(cls, duty_id, token=None):
|
||||
# from database_sql_models import Companies
|
||||
#
|
||||
# related_companies = Companies.select_action(duty_id=duty_id)
|
||||
# companies_ids = [company.id for company in related_companies.all()]
|
||||
# return cls.filter_all(cls.company_id.in_(companies_ids)).query
|
||||
|
||||
@@ -977,7 +977,7 @@ class BuildDecisionBookLegal(CrudCollection):
|
||||
contact_agreement_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP(timezone=True), server_default="1900-01-01 00:00:00", nullable=True
|
||||
)
|
||||
meeting_date: Mapped[str] = mapped_column(
|
||||
meeting_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP(timezone=True), server_default="1900-01-01 00:00:00"
|
||||
)
|
||||
lawsuits_type: Mapped[str] = mapped_column(String(1), server_default="C")
|
||||
|
||||
Reference in New Issue
Block a user