super_user and services updated

This commit is contained in:
berkay 2024-12-05 18:59:46 +03:00
parent 88f94c37c2
commit 88309eb49d
20 changed files with 317 additions and 116 deletions

View File

@ -32,9 +32,7 @@ class Config:
"/authentication/valid", "/authentication/valid",
"/api/Contact/Us/current_date", "/api/Contact/Us/current_date",
] ]
NOT_SECURE_PATHS = [ NOT_SECURE_PATHS = ["/access/endpoints/available"]
"/access/endpoints/available"
]
APP_NAME = "evyos-web-api-gateway" APP_NAME = "evyos-web-api-gateway"
TITLE = "WAG API Web Api Gateway" TITLE = "WAG API Web Api Gateway"

View File

@ -149,8 +149,8 @@ class AuthenticationSelectEventMethods(MethodToEvent):
Employees.staff_id.in_(staff_ids), Employees.staff_id.in_(staff_ids),
).data ).data
reachable_event_list_id, reachable_event_list_uu_id = ( reachable_event_list_id = Event2Employee.get_event_id_by_employee_id(
Event2Employee.get_event_id_by_employee_id(employee_id=employee.id) employee_id=employee.id
) )
staff = Staff.filter_one( staff = Staff.filter_one(
Staff.id == employee.staff_id, Staff.id == employee.staff_id,
@ -183,7 +183,7 @@ class AuthenticationSelectEventMethods(MethodToEvent):
employee_id=employee.id, employee_id=employee.id,
employee_uu_id=employee.uu_id.__str__(), employee_uu_id=employee.uu_id.__str__(),
reachable_event_list_id=reachable_event_list_id, reachable_event_list_id=reachable_event_list_id,
reachable_event_list_uu_id=reachable_event_list_uu_id, # reachable_event_list_uu_id=reachable_event_list_uu_id,
), ),
) )
return JSONResponse( return JSONResponse(
@ -225,7 +225,7 @@ class AuthenticationSelectEventMethods(MethodToEvent):
BuildLivingSpace.person_id == token_dict.person_id, BuildLivingSpace.person_id == token_dict.person_id,
BuildLivingSpace.build_parts_id == build_part.id, BuildLivingSpace.build_parts_id == build_part.id,
).data: ).data:
reachable_event_list_id, reachable_event_list_uu_id = ( reachable_event_list_id = (
Event2Occupant.get_event_id_by_build_living_space_id( Event2Occupant.get_event_id_by_build_living_space_id(
Event2Occupant.build_living_space_id Event2Occupant.build_living_space_id
== selected_occupant_type.id == selected_occupant_type.id
@ -248,7 +248,7 @@ class AuthenticationSelectEventMethods(MethodToEvent):
responsible_company_id=company_related.id, responsible_company_id=company_related.id,
responsible_company_uuid=company_related.uu_id.__str__(), responsible_company_uuid=company_related.uu_id.__str__(),
reachable_event_list_id=reachable_event_list_id, reachable_event_list_id=reachable_event_list_id,
reachable_event_list_uu_id=reachable_event_list_uu_id, # reachable_event_list_uu_id=reachable_event_list_uu_id,
), ),
) )
return JSONResponse( return JSONResponse(

View File

@ -139,8 +139,8 @@ class AuthenticationSelectEventMethods(MethodToEvent):
Employees.people_id == token_dict.person_id, Employees.people_id == token_dict.person_id,
Employees.staff_id.in_(staff_ids), Employees.staff_id.in_(staff_ids),
).data ).data
reachable_event_list_id, reachable_event_list_uu_id = ( reachable_event_list_id = Event2Employee.get_event_id_by_employee_id(
Event2Employee.get_event_id_by_employee_id(employee_id=employee.id) employee_id=employee.id
) )
staff = Staff.filter_one( staff = Staff.filter_one(
Staff.id == employee.staff_id, Staff.id == employee.staff_id,
@ -172,7 +172,6 @@ class AuthenticationSelectEventMethods(MethodToEvent):
employee_id=employee.id, employee_id=employee.id,
employee_uu_id=employee.uu_id.__str__(), employee_uu_id=employee.uu_id.__str__(),
reachable_event_list_id=reachable_event_list_id, reachable_event_list_id=reachable_event_list_id,
reachable_event_list_uu_id=reachable_event_list_uu_id,
), ),
) )
return JSONResponse( return JSONResponse(
@ -216,7 +215,7 @@ class AuthenticationSelectEventMethods(MethodToEvent):
BuildLivingSpace.person_id == token_dict.person_id, BuildLivingSpace.person_id == token_dict.person_id,
BuildLivingSpace.build_parts_id == build_part.id, BuildLivingSpace.build_parts_id == build_part.id,
).data: ).data:
reachable_event_list_id, reachable_event_list_uu_id = ( reachable_event_list_id = (
Event2Occupant.get_event_id_by_build_living_space_id( Event2Occupant.get_event_id_by_build_living_space_id(
build_living_space_id=selected_occupant_type.id build_living_space_id=selected_occupant_type.id
) )
@ -238,7 +237,6 @@ class AuthenticationSelectEventMethods(MethodToEvent):
responsible_company_id=company_related.id, responsible_company_id=company_related.id,
responsible_company_uuid=company_related.uu_id.__str__(), responsible_company_uuid=company_related.uu_id.__str__(),
reachable_event_list_id=reachable_event_list_id, reachable_event_list_id=reachable_event_list_id,
reachable_event_list_uu_id=reachable_event_list_uu_id,
), ),
) )
return JSONResponse( return JSONResponse(

View File

@ -186,15 +186,9 @@ class BuildingLivingSpacesPartsCreateEventMethods(MethodToEvent):
) )
last_living_space.save() last_living_space.save()
user_module = Modules.filter_one( created_living_space.save_and_confirm()
Modules.module_code == "USR-PUB", system=True ModulesBindOccupantEventMethods.bind_default_module_for_first_init_occupant(
).data
created_living_space.save()
created_living_space.update(is_confirmed=True)
created_living_space.save()
ModulesBindOccupantEventMethods.modules_bind_occupant_system(
build_living_space_id=created_living_space.id, build_living_space_id=created_living_space.id,
modules_id=user_module.id,
) )
return created_living_space return created_living_space

View File

@ -15,6 +15,8 @@ from api_events.events.events.events_bind_services import (
) )
from api_library.date_time_actions.date_functions import system_arrow from api_library.date_time_actions.date_functions import system_arrow
from api_validations.core_response import AlchemyJsonResponse from api_validations.core_response import AlchemyJsonResponse
from databases.sql_models.company.employee import Employees
from databases.sql_models.event.event import Event2Occupant, Event2Employee
class ModulesBindOccupantEventMethods(MethodToEvent): class ModulesBindOccupantEventMethods(MethodToEvent):
@ -25,34 +27,64 @@ class ModulesBindOccupantEventMethods(MethodToEvent):
} }
@classmethod @classmethod
def modules_bind_occupant_system( def bind_default_module_for_first_init_occupant(
cls, build_living_space_id: int, modules_id: int, expires_at: str = None cls, build_living_space_id: int, expires_at: str = None
): ):
living_space = BuildLivingSpace.filter_one( living_space = BuildLivingSpace.filter_one(
BuildLivingSpace.id == build_living_space_id, BuildLivingSpace.id == build_living_space_id,
).data ).data
modules = Modules.filter_one(Modules.id == modules_id).data modules = Modules.filter_all(Modules.is_default_module == True).data
if not living_space or not modules: if not living_space or not modules:
print(f"Giving living Space or Modules: {modules.module_name} not found") print(f"Giving living Space or Modules: Default not found")
return return
service_build_dict = dict(build_living_space_id=living_space.id) service_build_dict = dict(build_living_space_id=living_space.id)
if expires_at: if expires_at:
service_build_dict["expires_at"] = str(system_arrow.get(expires_at)) service_build_dict["expires_at"] = str(system_arrow.get(expires_at))
else: else:
service_build_dict["expires_at"] = str( expiry_ends = str(system_arrow.get(living_space.expiry_ends))
system_arrow.get(living_space.expiry_ends) service_build_dict["expires_at"] = expiry_ends
)
for service in modules.retrieve_services(): for module in modules:
ServiceBindOccupantEventMethods.bind_services_occupant_system( for service in module.retrieve_services():
**service_build_dict, event_occupant = Event2Occupant.find_or_create(
service_id=service.id, event_service_id=service.id,
event_service_uu_id=str(service.uu_id),
build_living_space_id=living_space.id,
build_living_space_uu_id=str(living_space.uu_id),
) )
BuildLivingSpace.save() event_occupant.save_and_confirm()
return True return True
# @classmethod
# def modules_bind_occupant_system(
# cls, build_living_space_id: int, modules_id: int, expires_at: str = None
# ):
#
# living_space = BuildLivingSpace.filter_one(
# BuildLivingSpace.id == build_living_space_id,
# ).data
# modules = Modules.filter_one(Modules.id == modules_id).data
#
# if not living_space or not modules:
# print(f"Giving living Space or Modules: {modules.module_name} not found")
# return
# service_build_dict = dict(build_living_space_id=living_space.id)
# if expires_at:
# service_build_dict["expires_at"] = str(system_arrow.get(expires_at))
# else:
# service_build_dict["expires_at"] = str(
# system_arrow.get(living_space.expiry_ends)
# )
#
# for service in modules.retrieve_services():
# ServiceBindOccupantEventMethods.bind_services_occupant_system(
# **service_build_dict,
# service_id=service.id,
# )
# BuildLivingSpace.save()
# return True
@classmethod @classmethod
def modules_bind_occupant( def modules_bind_occupant(
cls, cls,
@ -70,6 +102,37 @@ class ModulesBindEmployeeEventMethods(MethodToEvent):
"": "modules_bind_employee", "": "modules_bind_employee",
} }
@classmethod
def bind_default_module_for_first_init_occupant(
cls, employee_id: int, expires_at: str = None
):
employee = Employees.filter_one(
Employees.id == employee_id,
).data
modules = Modules.filter_all(Modules.is_default_module == True).data
if not employee or not modules:
print(f"Giving living Space or Modules: Default not found")
return
service_build_dict = dict(build_living_space_id=employee.id)
if expires_at:
service_build_dict["expires_at"] = str(system_arrow.get(expires_at))
else:
expiry_ends = str(system_arrow.get(employee.expiry_ends))
service_build_dict["expires_at"] = expiry_ends
for module in modules:
for service in module.retrieve_services():
event_employee = Event2Employee.find_or_create(
event_service_id=service.id,
event_service_uu_id=str(service.uu_id),
employee_id=employee.id,
employee_uu_id=str(employee.uu_id),
)
event_employee.save_and_confirm()
return True
@classmethod @classmethod
def modules_bind_employee( def modules_bind_employee(
cls, cls,

View File

@ -87,7 +87,7 @@ class UserCreateEventMethods(MethodToEvent):
company_uuid=created_user.related_company, company_uuid=created_user.related_company,
) )
mongo_query_identity.create_domain_via_user(payload=domain_via_user) mongo_query_identity.create_domain_via_user(payload=domain_via_user)
reset_password_token = created_user.reset_password_token() reset_password_token = created_user.reset_password_token(found_user=created_user)
send_email_completed = send_email( send_email_completed = send_email(
subject=f"Dear {created_user.user_tag}, your password has been changed.", subject=f"Dear {created_user.user_tag}, your password has been changed.",
receivers=[str(created_user.email)], receivers=[str(created_user.email)],

View File

@ -52,14 +52,14 @@ class OccupantToken(BaseModel):
build_part_id: int build_part_id: int
build_part_uuid: str build_part_uuid: str
reachable_event_list_id: Optional[list] = None # ID list of reachable modules
reachable_event_list_uu_id: Optional[list] = None # UUID list of reachable modules
responsible_company_id: Optional[int] = None responsible_company_id: Optional[int] = None
responsible_company_uuid: Optional[str] = None responsible_company_uuid: Optional[str] = None
responsible_employee_id: Optional[int] = None responsible_employee_id: Optional[int] = None
responsible_employee_uuid: Optional[str] = None responsible_employee_uuid: Optional[str] = None
reachable_event_list_id: Optional[list] = None # ID list of reachable modules
# reachable_event_list_uu_id: Optional[list] = None # UUID list of reachable modules
class CompanyToken(BaseModel): # Required Company Object for an employee class CompanyToken(BaseModel): # Required Company Object for an employee
@ -81,7 +81,7 @@ class CompanyToken(BaseModel): # Required Company Object for an employee
bulk_duties_id: int bulk_duties_id: int
reachable_event_list_id: Optional[list] = None # ID list of reachable modules reachable_event_list_id: Optional[list] = None # ID list of reachable modules
reachable_event_list_uu_id: Optional[list] = None # UUID list of reachable modules # reachable_event_list_uu_id: Optional[list] = None # UUID list of reachable modules
class OccupantTokenObject(ApplicationToken): class OccupantTokenObject(ApplicationToken):

View File

@ -18,7 +18,6 @@ from databases.sql_models.company.company import Companies
from databases.sql_models.identity.identity import People from databases.sql_models.identity.identity import People
class InsertBudgetRecord(BaseModel): class InsertBudgetRecord(BaseModel):
iban: str iban: str
bank_date: str = datetime.now().__str__() bank_date: str = datetime.now().__str__()
@ -272,6 +271,7 @@ def parse_comment_for_build_parts(
comment: str, max_build_part: int = 200, parse: str = "DAIRE" comment: str, max_build_part: int = 200, parse: str = "DAIRE"
): ):
from regex_func import category_finder from regex_func import category_finder
results, results_list = category_finder(comment), [] results, results_list = category_finder(comment), []
print("results[parse]", results[parse]) print("results[parse]", results[parse])
for result in results[parse] or []: for result in results[parse] or []:

View File

@ -10,7 +10,10 @@ def parse_token_object_to_dict(request): # from requests import Request
if valid_token := get_object_via_access_key(request=request): if valid_token := get_object_via_access_key(request=request):
endpoint_name = str(request.url).replace(str(request.base_url), "/") endpoint_name = str(request.url).replace(str(request.base_url), "/")
if str(endpoint_name) in Config.INSECURE_PATHS or str(endpoint_name) in Config.NOT_SECURE_PATHS: if (
str(endpoint_name) in Config.INSECURE_PATHS
or str(endpoint_name) in Config.NOT_SECURE_PATHS
):
return valid_token return valid_token
endpoint_active = EndpointRestriction.filter_one( endpoint_active = EndpointRestriction.filter_one(
EndpointRestriction.endpoint_name.ilike(f"%{endpoint_name}%"), EndpointRestriction.endpoint_name.ilike(f"%{endpoint_name}%"),

View File

@ -65,6 +65,8 @@ from databases.sql_models.event.event import (
Events, Events,
Event2Occupant, Event2Occupant,
Event2Employee, Event2Employee,
Event2OccupantExtra,
Event2EmployeeExtra,
) )
from databases.sql_models.identity.identity import ( from databases.sql_models.identity.identity import (
Addresses, Addresses,
@ -149,6 +151,8 @@ __all__ = [
"Events", "Events",
"Event2Occupant", "Event2Occupant",
"Event2Employee", "Event2Employee",
"Event2OccupantExtra",
"Event2EmployeeExtra",
"Addresses", "Addresses",
"AddressCity", "AddressCity",
"AddressStreet", "AddressStreet",

View File

@ -368,6 +368,11 @@ class AccountDetail(CrudCollection):
class AccountRecords(CrudCollection): class AccountRecords(CrudCollection):
"""
build_decision_book_id = kaydın sorumlu olduğu karar defteri
send_company_id = kaydı gönderen firma, send_person_id = gönderen kişi
customer_id = sorumlu kullanıcı bilgisi, company_id = sorumlu firma
"""
__tablename__ = "account_records" __tablename__ = "account_records"
__exclude__fields__ = [] __exclude__fields__ = []
@ -375,11 +380,47 @@ class AccountRecords(CrudCollection):
("receive_debit", "DebitTypes", "D"), ("receive_debit", "DebitTypes", "D"),
("budget_type", "BudgetType", "B"), ("budget_type", "BudgetType", "B"),
] ]
"""
build_decision_book_id = kaydın sorumlu olduğu karar defteri language = {
send_company_id = kaydı gönderen firma, send_person_id = gönderen kişi "tr": {
customer_id = sorumlu kullanıcı bilgisi, company_id = sorumlu firma "iban": "IBAN Numarası",
""" "bank_date": "Bank Tarih",
"currency_value": "Para Değeri",
"bank_balance": "Banka Bakiye",
"currency": "Para Birimi",
"additional_balance": "Ek Bakiye",
"channel_branch": "Kanal Şubesi",
"process_name": "İşlem Adı",
"process_type": "İşlem Tipi",
"process_comment": "İşlem Yorum",
"bank_reference_code": "Banka Referans Kodu",
"add_comment_note": "Yorum Not",
"is_receipt_mail_send": "Fiş Mail Gönderildi",
"found_from": "Bulunduğu Yer",
"similarity": "Benzerlik",
"remainder_balance": "Kalan Bakiye",
"bank_date_y": "Bank Tarih Yıl",
"bank_date_m": "Bank Tarih Ay",
"bank_date_w": "Bank Tarih Hafta",
"bank_date_d": "Bank Tarih Gün",
"approving_accounting_record": "Onaylayan Muhasebe Kaydı",
"accounting_receipt_date": "Muhasebe Fiş Tarihi",
"accounting_receipt_number": "Muhasebe Fiş Numarası",
"approved_record": "Onaylanmış Kayıt",
"import_file_name": "İçe Aktarım Dosya Adı",
"receive_debit_uu_id": "Alacak UU ID",
"budget_type_uu_id": "Bütçe Tipi UU ID",
"company_uu_id": "Şirket UU ID",
"send_company_uu_id": "Gönderen Şirket UU ID",
"customer_id": "Müşteri ID",
"customer_uu_id": "Müşteri UU ID",
"send_person_uu_id": "Gönderen Kişi UU ID",
"approving_accounting_person_uu_id": "Onaylayan Muhasebe Kişi UU ID",
"build_parts_uu_id": "Daire UU ID",
"build_decision_book_uu_id": "Karar Defteri UU ID",
},
"en": {},
}
iban: Mapped[str] = mapped_column( iban: Mapped[str] = mapped_column(
String(64), nullable=False, comment="IBAN Number of Bank" String(64), nullable=False, comment="IBAN Number of Bank"

View File

@ -21,7 +21,9 @@ class Events(CrudCollection):
__tablename__ = "events" __tablename__ = "events"
__exclude__fields__ = [] __exclude__fields__ = []
event_type: Mapped[str] = mapped_column(String, nullable=False, comment="Event Type") event_type: Mapped[str] = mapped_column(
String, nullable=False, comment="Event Type"
)
function_code: Mapped[str] = mapped_column( function_code: Mapped[str] = mapped_column(
String, nullable=False, comment="function code" String, nullable=False, comment="function code"
) )
@ -123,6 +125,62 @@ class Service2Events(CrudCollection):
__table_args__ = ({"comment": "Service2Events Information"},) __table_args__ = ({"comment": "Service2Events Information"},)
class Event2OccupantExtra(CrudCollection):
__tablename__ = "event2occupant_extra"
__exclude__fields__ = []
build_living_space_id: Mapped[int] = mapped_column(
ForeignKey("build_living_space.id"), nullable=False
)
build_living_space_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Build Living Space UUID"
)
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), nullable=False)
event_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Event UUID"
)
__table_args__ = (
Index(
"event2occupant_extra_bind_event_to_occupant",
build_living_space_id,
event_id,
unique=True,
),
{"comment": "Occupant2Event Information"},
)
class Event2EmployeeExtra(CrudCollection):
"""
Employee2Event class based on declarative_base and BaseMixin via session
"""
__tablename__ = "event2employee_extra"
__exclude__fields__ = []
employee_id: Mapped[int] = mapped_column(ForeignKey("employees.id"), nullable=False)
employee_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Employee UUID"
)
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), nullable=False)
event_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Event UUID"
)
__table_args__ = (
Index(
"event2employee_extra_employee_to_event",
employee_id,
event_id,
unique=True,
),
{"comment": "Employee to Event Information"},
)
class Event2Employee(CrudCollection): class Event2Employee(CrudCollection):
""" """
Employee2Event class based on declarative_base and BaseMixin via session Employee2Event class based on declarative_base and BaseMixin via session
@ -131,23 +189,41 @@ class Event2Employee(CrudCollection):
__tablename__ = "event2employee" __tablename__ = "event2employee"
__exclude__fields__ = [] __exclude__fields__ = []
employee_id = mapped_column(ForeignKey("employees.id"), nullable=False) employee_id: Mapped[int] = mapped_column(ForeignKey("employees.id"), nullable=False)
employee_uu_id = mapped_column(String, nullable=False, comment="Employee UUID") employee_uu_id: Mapped[str] = mapped_column(
event_id = mapped_column(ForeignKey("events.id"), nullable=False) String, nullable=False, comment="Employee UUID"
event_uu_id = mapped_column(String, nullable=False, comment="Event UUID") )
event_service_id: Mapped[int] = mapped_column(
ForeignKey("services.id"), nullable=False
)
event_service_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Event Cluster UUID"
)
__table_args__ = ( __table_args__ = (
Index("event2employee_employee_to_event", employee_id, event_id, unique=True), Index(
"event2employee_employee_to_event",
employee_id,
event_service_id,
unique=True,
),
{"comment": "Employee to Event Information"}, {"comment": "Employee to Event Information"},
) )
@classmethod @classmethod
def get_event_id_by_employee_id(cls, employee_id) -> (list, list): def get_event_id_by_employee_id(cls, employee_id) -> list:
active_events = cls.filter_all(cls.employee_id == employee_id) occupant_events = cls.filter_all(
active_events_id = [event.event_id for event in active_events.data] cls.employee_id == employee_id,
active_events = Events.filter_all(Events.id.in_(active_events_id)) ).data
active_events_uu_id = [str(event.uu_id) for event in active_events.data] active_events = Service2Events.filter_all(
return active_events_id, active_events_uu_id Service2Events.service_id.in_([event.event_service_id for event in occupant_events]), system=True
).data
active_events_id = [event.event_id for event in active_events]
if extra_events := Event2EmployeeExtra.filter_all(
Event2EmployeeExtra.employee_id == employee_id
).data:
active_events_id.extend([event.event_id for event in extra_events])
return active_events_id
class Event2Occupant(CrudCollection): class Event2Occupant(CrudCollection):
@ -158,39 +234,47 @@ class Event2Occupant(CrudCollection):
__tablename__ = "event2occupant" __tablename__ = "event2occupant"
__exclude__fields__ = [] __exclude__fields__ = []
build_living_space_id = mapped_column( build_living_space_id: Mapped[str] = mapped_column(
ForeignKey("build_living_space.id"), nullable=False ForeignKey("build_living_space.id"), nullable=False
) )
build_living_space_uu_id = mapped_column( build_living_space_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Build Living Space UUID" String, nullable=False, comment="Build Living Space UUID"
) )
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), nullable=False) event_service_id: Mapped[int] = mapped_column(
event_uu_id = mapped_column(String, nullable=False, comment="Event UUID") ForeignKey("services.id"), nullable=False
)
event_service_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Event Cluster UUID"
)
# event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), nullable=False)
# event_uu_id = mapped_column(String, nullable=False, comment="Event UUID")
__table_args__ = ( __table_args__ = (
Index( Index(
"event2occupant_bind_event_to_occupant", "event2occupant_bind_event_to_occupant",
build_living_space_id, build_living_space_id,
event_id, event_service_id,
unique=True, unique=True,
), ),
{"comment": "Occupant2Event Information"}, {"comment": "Occupant2Event Information"},
) )
@classmethod @classmethod
def get_event_id_by_build_living_space_id( def get_event_id_by_build_living_space_id(cls, build_living_space_id) -> list:
cls, build_living_space_id occupant_events = cls.filter_all(
) -> (list, list):
active_events = cls.filter_all(
cls.build_living_space_id == build_living_space_id, cls.build_living_space_id == build_living_space_id,
).data ).data
active_events = Service2Events.filter_all(
Service2Events.service_id.in_([event.event_service_id for event in occupant_events]), system=True
).data
active_events_id = [event.event_id for event in active_events] active_events_id = [event.event_id for event in active_events]
active_events = Events.filter_all(Events.id.in_(active_events_id)).data if extra_events := Event2OccupantExtra.filter_all(
active_events_uu_id = [str(event.uu_id) for event in active_events] Event2OccupantExtra.build_living_space_id == build_living_space_id
return active_events_id, active_events_uu_id ).data:
active_events_id.extend([event.event_id for event in extra_events])
return active_events_id
# Delete later code
class ModulePrice(CrudCollection): class ModulePrice(CrudCollection):
""" """
ModulePrice class based on declarative_base and BaseMixin via session ModulePrice class based on declarative_base and BaseMixin via session
@ -199,27 +283,34 @@ class ModulePrice(CrudCollection):
__tablename__ = "module_price" __tablename__ = "module_price"
__exclude__fields__ = [] __exclude__fields__ = []
campaign_code = mapped_column(String, nullable=False, comment="Campaign Code") campaign_code: Mapped[str] = mapped_column(
String, nullable=False, comment="Campaign Code"
)
module_id: Mapped[int] = mapped_column(ForeignKey("modules.id"), nullable=False) module_id: Mapped[int] = mapped_column(ForeignKey("modules.id"), nullable=False)
module_uu_id = mapped_column(String, nullable=False, comment="Module UUID") module_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Module UUID"
)
service_id: Mapped[int] = mapped_column(ForeignKey("services.id"), nullable=False) service_id: Mapped[int] = mapped_column(ForeignKey("services.id"), nullable=False)
service_uu_id = mapped_column(String, nullable=False, comment="Service UUID") service_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Service UUID"
)
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), nullable=False) event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), nullable=False)
event_uu_id = mapped_column(String, nullable=False, comment="Event UUID") event_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Event UUID"
)
is_counted_percentage: Mapped[float] = mapped_column( is_counted_percentage: Mapped[float] = mapped_column(
Numeric(6, 2), server_default="0.00" Numeric(6, 2), server_default="0.00"
) # %22 ) # %22
discounted_price = mapped_column( discounted_price: Mapped[float] = mapped_column(
Numeric(20, 2), server_default="0.00" Numeric(20, 2), server_default="0.00"
) # Normal: 78.00 TL ) # Normal: 78.00 TL
calculated_price = mapped_column( calculated_price: Mapped[float] = mapped_column(
Numeric(20, 2), server_default="0.00" Numeric(20, 2), server_default="0.00"
) # sana düz 75.00 TL yapar ) # sana düz 75.00 TL yapar
__table_args__ = ({"comment": "ModulePrice Information"},) __table_args__ = ({"comment": "ModulePrice Information"},)
#
# class Modules2Occupant(CrudCollection): # class Modules2Occupant(CrudCollection):
# """ # """
# ModulesOccupantPrices class based on declarative_base and BaseMixin via session # ModulesOccupantPrices class based on declarative_base and BaseMixin via session

View File

@ -79,15 +79,15 @@ services:
# - wag_management_init_service # - wag_management_init_service
# - grafana # - grafana
# wag_management_init_service: wag_management_init_service:
# container_name: wag_management_init_service container_name: wag_management_init_service
# build: build:
# context: . context: .
# dockerfile: service_app_init/Dockerfile dockerfile: service_app_init/Dockerfile
# networks: networks:
# - network_store_services - network_store_services
# depends_on: depends_on:
# - postgres_commercial - postgres_commercial
# #
# wag_bank_services: # wag_bank_services:
# container_name: wag_bank_services # container_name: wag_bank_services

View File

@ -1,7 +1,7 @@
import sys import sys
if '/service_account_records' not in list(sys.path): if "/service_account_records" not in list(sys.path):
sys.path.append('/service_account_records') sys.path.append("/service_account_records")
from decimal import Decimal from decimal import Decimal

View File

@ -1,7 +1,7 @@
import sys import sys
if '/service_account_records' not in list(sys.path): if "/service_account_records" not in list(sys.path):
sys.path.append('/service_account_records') sys.path.append("/service_account_records")
import re import re

View File

@ -1,7 +1,7 @@
import sys import sys
if '/service_app_banks' not in list(sys.path): if "/service_app_banks" not in list(sys.path):
sys.path.append('/service_app_banks') sys.path.append("/service_app_banks")
from api_services.email.service import send_email from api_services.email.service import send_email
from api_library.date_time_actions.date_functions import client_arrow from api_library.date_time_actions.date_functions import client_arrow

View File

@ -1,7 +1,7 @@
import sys import sys
if '/service_app_banks' not in list(sys.path): if "/service_app_banks" not in list(sys.path):
sys.path.append('/service_app_banks') sys.path.append("/service_app_banks")
import os import os
import json import json

View File

@ -5,10 +5,9 @@ from databases import (
Employees, Employees,
Staff, Staff,
) )
from api_events.events.events.events_bind_services import (
ServiceBindEmployeeEventMethods,
)
from databases.sql_models.event.event import Event2Employee
from api_events.events.events.events_bind_modules import ModulesBindEmployeeEventMethods
active_confirmed = dict( active_confirmed = dict(
created_by="System", created_by="System",
@ -95,8 +94,11 @@ def add_events_all_services_and_occupant_types():
service_selected.update( service_selected.update(
related_responsibility=getattr(event_block_class, "related_code", None) related_responsibility=getattr(event_block_class, "related_code", None)
) )
for block in event_block_class(): for event_id, event_uu_id in event_block_class():
event_id, event_uu_id = block if Service2Events.filter_by_one(
service_id=service_selected.id, event_id=event_id, system=True
).data:
continue
service_events = Service2Events.find_or_create( service_events = Service2Events.find_or_create(
service_id=service_selected.id, service_id=service_selected.id,
service_uu_id=str(service_selected.uu_id), service_uu_id=str(service_selected.uu_id),
@ -121,8 +123,13 @@ def add_events_to_system_super_user():
if not add_employee: if not add_employee:
raise Exception("Super User Employee not found") raise Exception("Super User Employee not found")
ServiceBindEmployeeEventMethods.bind_services_employee( ModulesBindEmployeeEventMethods.bind_default_module_for_first_init_occupant(
service_id=add_service.id, employee_id=add_employee.id
employee_id=add_employee.id,
) )
Employees.save() event_employee = Event2Employee.find_or_create(
event_service_id=add_service.id,
event_service_uu_id=str(add_service.uu_id),
employee_id=add_employee.id,
employee_uu_id=str(add_employee.uu_id),
)
event_employee.save_and_confirm()

View File

@ -94,12 +94,13 @@ class RequestToApi:
access_token = content.get("access_token") access_token = content.get("access_token")
refresh_token = content.get("refresh_token") refresh_token = content.get("refresh_token")
access_object = content.get("access_object") access_object = content.get("access_object")
print('access_object', access_object)
if not access_object: if not access_object:
raise Exception("Access object is not found") raise Exception("Access object is not found")
companies_uu_id_list = None companies_uu_id_list = None
if access_object.get("user_type") == "employee": if access_object.get("user_type") == "employee":
companies_uu_id_list = access_object.get("companies_uu_id_list") companies_uu_id_list = access_object.get("companies_list")
elif access_object.get("user_type") == "occupant": elif access_object.get("user_type") == "occupant":
companies_uu_id_list = access_object.get("available_occupants") companies_uu_id_list = access_object.get("available_occupants")
@ -111,7 +112,8 @@ class RequestToApi:
self.set_access_token(access_token) self.set_access_token(access_token)
if access_object.get("user_type") == "employee": if access_object.get("user_type") == "employee":
uu_id = companies_uu_id_list[0] uu_id = companies_uu_id_list[0].get('uu_id')
print('uu_id', uu_id)
refresh_company = self.post( refresh_company = self.post(
endpoint="authentication/select", data={"company_uu_id": uu_id} endpoint="authentication/select", data={"company_uu_id": uu_id}
) )

View File

@ -50,8 +50,8 @@ def decode_as_json_indent(data):
return json.dumps(json.loads(json.dumps(data)), indent=2) return json.dumps(json.loads(json.dumps(data)), indent=2)
password_token = "FGS095it2IBP3gIp5glaG6u9tQy1KEPzKnBYE1fvGJSGvGUhwaGgxE-56yZAxUQnW-a_J91twOFKTWTc0ue4GZq10vY7fK2cZBsR9bUDJMCHZZZGpFYbsE6pLyaDs-1_K8v5hbggSmpXNFfafMmujuXxqvSzdLQa5hcg9qepHBOvgTbL28wGRHx9w-Fcb7bL" password_token = "AVqRAPWQ9yvZqX14pWEAHfv72MsTYbjrlPNH97xDPr9RrDySPmu1zlPEH-IsQ9GNR1wrGQHv4xsR6eNbZYDe8rnvYbaiGOFpu1t18AMOZBEB3cKiashFCXznglPGd670QmAsRAqC-VO8GsIoGjtRr2ZQCKVY2lXTc3RcqRA26YXP31Bc-mDr_nzpjQCGrVcd"
password_token_occ = "kM9vHcWZVVF38IyNxMk6XMlCc8FCc_P1D-0D2u-Er5FrcQzvswSjJe9Lu9QnhJ5fJw5WqC45UYxopme_aCX6YDfZfQ3wQ9RP4Ak5YYTWBZbtwKGXTomlpYCQJghy0RC-1-Q9ATNEgcjYXqU2P9UjjdS9JNvhUawT0R38wXap-Mum6oazjqiKow41SUebnZ-H" password_token_occ = ""
login_data = { login_data = {
"domain": "evyos.com.tr", "domain": "evyos.com.tr",
"access_key": "karatay.berkay.sup@evyos.com.tr", "access_key": "karatay.berkay.sup@evyos.com.tr",
@ -67,8 +67,8 @@ login_creds_occupant = {
"password_token": password_token_occ, "password_token": password_token_occ,
} }
selection_list = [ selection_list = [
"d9ffa716-331c-48fc-83b2-47bf31289b3e", # "d9ffa716-331c-48fc-83b2-47bf31289b3e",
"afebb7f8-9f62-4703-b11c-ee8f14fe73b7", # "afebb7f8-9f62-4703-b11c-ee8f14fe73b7",
] ]
manager_token = "g0Z1YYjh2WqFfoI3MdJ9wrfXAHeL6f7UatEkySzOK0dFX6CH1sXgjQ" manager_token = "g0Z1YYjh2WqFfoI3MdJ9wrfXAHeL6f7UatEkySzOK0dFX6CH1sXgjQ"
@ -93,11 +93,11 @@ if assign_people_to_create_item == -1:
local_api.selected_object = local_api.login_via_email_and_password( local_api.selected_object = local_api.login_via_email_and_password(
login_data=login_data, is_password_valid=False login_data=login_data, is_password_valid=False
) )
# migrate_company(requester=both_apis) migrate_company(requester=both_apis)
# migrate_people(requester=both_apis) migrate_people(requester=both_apis)
# migrate_build(requester=both_apis) migrate_build(requester=both_apis)
# migrate_build_living_space(requester=both_apis) migrate_build_living_space(requester=both_apis)
migrate_account_records(requester=both_apis) # migrate_account_records(requester=both_apis)
if assign_people_to_create_item == 0: if assign_people_to_create_item == 0:
if not bool(selection_list): if not bool(selection_list):