From 88309eb49da3f6d911e6d09ef38edd9ebc97a9e9 Mon Sep 17 00:00:00 2001 From: berkay Date: Thu, 5 Dec 2024 18:59:46 +0300 Subject: [PATCH] super_user and services updated --- api_configs/configs.py | 4 +- .../events/application/authentication.py | 10 +- api_events/events/authentication.py | 8 +- .../events/building/building_living_spaces.py | 10 +- .../events/events/events_bind_modules.py | 91 ++++++++-- api_events/events/identity/users.py | 2 +- api_objects/auth/token_objects.py | 8 +- .../bank_actions/wag_account_record_parser.py | 2 +- api_services/redis/auth_actions/token.py | 5 +- databases/__init__.py | 4 + databases/sql_models/account/account.py | 51 +++++- databases/sql_models/event/event.py | 155 ++++++++++++++---- docker-compose.yml | 18 +- service_account_records/app_accounts.py | 4 +- service_account_records/regex_func.py | 4 +- service_app_banks/app_mail_sender.py | 4 +- service_app_banks/isbank/isbank_sender.py | 4 +- .../initialize_app/event_initator.py | 25 ++- service_app_test/bases.py | 6 +- .../migrate_old_data/runner.py | 18 +- 20 files changed, 317 insertions(+), 116 deletions(-) diff --git a/api_configs/configs.py b/api_configs/configs.py index 3d1f920..5a322a0 100644 --- a/api_configs/configs.py +++ b/api_configs/configs.py @@ -32,9 +32,7 @@ class Config: "/authentication/valid", "/api/Contact/Us/current_date", ] - NOT_SECURE_PATHS = [ - "/access/endpoints/available" - ] + NOT_SECURE_PATHS = ["/access/endpoints/available"] APP_NAME = "evyos-web-api-gateway" TITLE = "WAG API Web Api Gateway" diff --git a/api_events/events/application/authentication.py b/api_events/events/application/authentication.py index 111bf3c..ace17fb 100644 --- a/api_events/events/application/authentication.py +++ b/api_events/events/application/authentication.py @@ -149,8 +149,8 @@ class AuthenticationSelectEventMethods(MethodToEvent): Employees.staff_id.in_(staff_ids), ).data - reachable_event_list_id, reachable_event_list_uu_id = ( - Event2Employee.get_event_id_by_employee_id(employee_id=employee.id) + reachable_event_list_id = Event2Employee.get_event_id_by_employee_id( + employee_id=employee.id ) staff = Staff.filter_one( Staff.id == employee.staff_id, @@ -183,7 +183,7 @@ class AuthenticationSelectEventMethods(MethodToEvent): employee_id=employee.id, employee_uu_id=employee.uu_id.__str__(), 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( @@ -225,7 +225,7 @@ class AuthenticationSelectEventMethods(MethodToEvent): BuildLivingSpace.person_id == token_dict.person_id, BuildLivingSpace.build_parts_id == build_part.id, ).data: - reachable_event_list_id, reachable_event_list_uu_id = ( + reachable_event_list_id = ( Event2Occupant.get_event_id_by_build_living_space_id( Event2Occupant.build_living_space_id == selected_occupant_type.id @@ -248,7 +248,7 @@ class AuthenticationSelectEventMethods(MethodToEvent): responsible_company_id=company_related.id, responsible_company_uuid=company_related.uu_id.__str__(), 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( diff --git a/api_events/events/authentication.py b/api_events/events/authentication.py index 07c045e..567fab3 100644 --- a/api_events/events/authentication.py +++ b/api_events/events/authentication.py @@ -139,8 +139,8 @@ class AuthenticationSelectEventMethods(MethodToEvent): Employees.people_id == token_dict.person_id, Employees.staff_id.in_(staff_ids), ).data - reachable_event_list_id, reachable_event_list_uu_id = ( - Event2Employee.get_event_id_by_employee_id(employee_id=employee.id) + reachable_event_list_id = Event2Employee.get_event_id_by_employee_id( + employee_id=employee.id ) staff = Staff.filter_one( Staff.id == employee.staff_id, @@ -172,7 +172,6 @@ class AuthenticationSelectEventMethods(MethodToEvent): employee_id=employee.id, employee_uu_id=employee.uu_id.__str__(), reachable_event_list_id=reachable_event_list_id, - reachable_event_list_uu_id=reachable_event_list_uu_id, ), ) return JSONResponse( @@ -216,7 +215,7 @@ class AuthenticationSelectEventMethods(MethodToEvent): BuildLivingSpace.person_id == token_dict.person_id, BuildLivingSpace.build_parts_id == build_part.id, ).data: - reachable_event_list_id, reachable_event_list_uu_id = ( + reachable_event_list_id = ( Event2Occupant.get_event_id_by_build_living_space_id( build_living_space_id=selected_occupant_type.id ) @@ -238,7 +237,6 @@ class AuthenticationSelectEventMethods(MethodToEvent): responsible_company_id=company_related.id, responsible_company_uuid=company_related.uu_id.__str__(), reachable_event_list_id=reachable_event_list_id, - reachable_event_list_uu_id=reachable_event_list_uu_id, ), ) return JSONResponse( diff --git a/api_events/events/building/building_living_spaces.py b/api_events/events/building/building_living_spaces.py index bbe5c33..dc2a61a 100644 --- a/api_events/events/building/building_living_spaces.py +++ b/api_events/events/building/building_living_spaces.py @@ -186,15 +186,9 @@ class BuildingLivingSpacesPartsCreateEventMethods(MethodToEvent): ) last_living_space.save() - user_module = Modules.filter_one( - Modules.module_code == "USR-PUB", system=True - ).data - created_living_space.save() - created_living_space.update(is_confirmed=True) - created_living_space.save() - ModulesBindOccupantEventMethods.modules_bind_occupant_system( + created_living_space.save_and_confirm() + ModulesBindOccupantEventMethods.bind_default_module_for_first_init_occupant( build_living_space_id=created_living_space.id, - modules_id=user_module.id, ) return created_living_space diff --git a/api_events/events/events/events_bind_modules.py b/api_events/events/events/events_bind_modules.py index ae6f5e6..c3fbd83 100644 --- a/api_events/events/events/events_bind_modules.py +++ b/api_events/events/events/events_bind_modules.py @@ -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_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): @@ -25,34 +27,64 @@ class ModulesBindOccupantEventMethods(MethodToEvent): } @classmethod - def modules_bind_occupant_system( - cls, build_living_space_id: int, modules_id: int, expires_at: str = None + def bind_default_module_for_first_init_occupant( + cls, build_living_space_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 - + modules = Modules.filter_all(Modules.is_default_module == True).data 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 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) - ) + expiry_ends = str(system_arrow.get(living_space.expiry_ends)) + service_build_dict["expires_at"] = expiry_ends - for service in modules.retrieve_services(): - ServiceBindOccupantEventMethods.bind_services_occupant_system( - **service_build_dict, - service_id=service.id, - ) - BuildLivingSpace.save() + for module in modules: + for service in module.retrieve_services(): + event_occupant = Event2Occupant.find_or_create( + 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), + ) + event_occupant.save_and_confirm() 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 def modules_bind_occupant( cls, @@ -70,6 +102,37 @@ class ModulesBindEmployeeEventMethods(MethodToEvent): "": "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 def modules_bind_employee( cls, diff --git a/api_events/events/identity/users.py b/api_events/events/identity/users.py index e3f2d26..535d84a 100644 --- a/api_events/events/identity/users.py +++ b/api_events/events/identity/users.py @@ -87,7 +87,7 @@ class UserCreateEventMethods(MethodToEvent): company_uuid=created_user.related_company, ) 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( subject=f"Dear {created_user.user_tag}, your password has been changed.", receivers=[str(created_user.email)], diff --git a/api_objects/auth/token_objects.py b/api_objects/auth/token_objects.py index 8ece54a..9f3853b 100644 --- a/api_objects/auth/token_objects.py +++ b/api_objects/auth/token_objects.py @@ -52,14 +52,14 @@ class OccupantToken(BaseModel): build_part_id: int 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_uuid: Optional[str] = None responsible_employee_id: Optional[int] = 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 @@ -81,7 +81,7 @@ class CompanyToken(BaseModel): # Required Company Object for an employee bulk_duties_id: int 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): diff --git a/api_services/bank_actions/wag_account_record_parser.py b/api_services/bank_actions/wag_account_record_parser.py index e40ef7a..caed763 100644 --- a/api_services/bank_actions/wag_account_record_parser.py +++ b/api_services/bank_actions/wag_account_record_parser.py @@ -18,7 +18,6 @@ from databases.sql_models.company.company import Companies from databases.sql_models.identity.identity import People - class InsertBudgetRecord(BaseModel): iban: 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" ): from regex_func import category_finder + results, results_list = category_finder(comment), [] print("results[parse]", results[parse]) for result in results[parse] or []: diff --git a/api_services/redis/auth_actions/token.py b/api_services/redis/auth_actions/token.py index c0425f3..5cc8331 100644 --- a/api_services/redis/auth_actions/token.py +++ b/api_services/redis/auth_actions/token.py @@ -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): 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 endpoint_active = EndpointRestriction.filter_one( EndpointRestriction.endpoint_name.ilike(f"%{endpoint_name}%"), diff --git a/databases/__init__.py b/databases/__init__.py index f560024..9c011e9 100644 --- a/databases/__init__.py +++ b/databases/__init__.py @@ -65,6 +65,8 @@ from databases.sql_models.event.event import ( Events, Event2Occupant, Event2Employee, + Event2OccupantExtra, + Event2EmployeeExtra, ) from databases.sql_models.identity.identity import ( Addresses, @@ -149,6 +151,8 @@ __all__ = [ "Events", "Event2Occupant", "Event2Employee", + "Event2OccupantExtra", + "Event2EmployeeExtra", "Addresses", "AddressCity", "AddressStreet", diff --git a/databases/sql_models/account/account.py b/databases/sql_models/account/account.py index db48cf7..8265422 100644 --- a/databases/sql_models/account/account.py +++ b/databases/sql_models/account/account.py @@ -368,6 +368,11 @@ class AccountDetail(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" __exclude__fields__ = [] @@ -375,11 +380,47 @@ class AccountRecords(CrudCollection): ("receive_debit", "DebitTypes", "D"), ("budget_type", "BudgetType", "B"), ] - """ - 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 - """ + + language = { + "tr": { + "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( String(64), nullable=False, comment="IBAN Number of Bank" diff --git a/databases/sql_models/event/event.py b/databases/sql_models/event/event.py index b5997f5..207fd8c 100644 --- a/databases/sql_models/event/event.py +++ b/databases/sql_models/event/event.py @@ -21,7 +21,9 @@ class Events(CrudCollection): __tablename__ = "events" __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( String, nullable=False, comment="function code" ) @@ -123,6 +125,62 @@ class Service2Events(CrudCollection): __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): """ Employee2Event class based on declarative_base and BaseMixin via session @@ -131,23 +189,41 @@ class Event2Employee(CrudCollection): __tablename__ = "event2employee" __exclude__fields__ = [] - employee_id = mapped_column(ForeignKey("employees.id"), nullable=False) - employee_uu_id = mapped_column(String, nullable=False, comment="Employee UUID") - event_id = mapped_column(ForeignKey("events.id"), nullable=False) - event_uu_id = mapped_column(String, nullable=False, comment="Event UUID") + 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_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__ = ( - 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"}, ) @classmethod - def get_event_id_by_employee_id(cls, employee_id) -> (list, list): - active_events = cls.filter_all(cls.employee_id == employee_id) - active_events_id = [event.event_id for event in active_events.data] - active_events = Events.filter_all(Events.id.in_(active_events_id)) - active_events_uu_id = [str(event.uu_id) for event in active_events.data] - return active_events_id, active_events_uu_id + def get_event_id_by_employee_id(cls, employee_id) -> list: + occupant_events = cls.filter_all( + cls.employee_id == employee_id, + ).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] + 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): @@ -158,39 +234,47 @@ class Event2Occupant(CrudCollection): __tablename__ = "event2occupant" __exclude__fields__ = [] - build_living_space_id = mapped_column( + build_living_space_id: Mapped[str] = mapped_column( 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" ) - event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), nullable=False) - 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" + ) + # event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), nullable=False) + # event_uu_id = mapped_column(String, nullable=False, comment="Event UUID") __table_args__ = ( Index( "event2occupant_bind_event_to_occupant", build_living_space_id, - event_id, + event_service_id, unique=True, ), {"comment": "Occupant2Event Information"}, ) @classmethod - def get_event_id_by_build_living_space_id( - cls, build_living_space_id - ) -> (list, list): - active_events = cls.filter_all( + def get_event_id_by_build_living_space_id(cls, build_living_space_id) -> list: + occupant_events = cls.filter_all( cls.build_living_space_id == build_living_space_id, ).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 = Events.filter_all(Events.id.in_(active_events_id)).data - active_events_uu_id = [str(event.uu_id) for event in active_events] - return active_events_id, active_events_uu_id + if extra_events := Event2OccupantExtra.filter_all( + Event2OccupantExtra.build_living_space_id == build_living_space_id + ).data: + active_events_id.extend([event.event_id for event in extra_events]) + return active_events_id -# Delete later code class ModulePrice(CrudCollection): """ ModulePrice class based on declarative_base and BaseMixin via session @@ -199,27 +283,34 @@ class ModulePrice(CrudCollection): __tablename__ = "module_price" __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_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_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_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( Numeric(6, 2), server_default="0.00" ) # %22 - discounted_price = mapped_column( + discounted_price: Mapped[float] = mapped_column( Numeric(20, 2), server_default="0.00" ) # Normal: 78.00 TL - calculated_price = mapped_column( + calculated_price: Mapped[float] = mapped_column( Numeric(20, 2), server_default="0.00" ) # sana düz 75.00 TL yapar __table_args__ = ({"comment": "ModulePrice Information"},) -# # class Modules2Occupant(CrudCollection): # """ # ModulesOccupantPrices class based on declarative_base and BaseMixin via session diff --git a/docker-compose.yml b/docker-compose.yml index 7ef924d..c76fde9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -79,15 +79,15 @@ services: # - wag_management_init_service # - grafana -# wag_management_init_service: -# container_name: wag_management_init_service -# build: -# context: . -# dockerfile: service_app_init/Dockerfile -# networks: -# - network_store_services -# depends_on: -# - postgres_commercial + wag_management_init_service: + container_name: wag_management_init_service + build: + context: . + dockerfile: service_app_init/Dockerfile + networks: + - network_store_services + depends_on: + - postgres_commercial # # wag_bank_services: # container_name: wag_bank_services diff --git a/service_account_records/app_accounts.py b/service_account_records/app_accounts.py index f9c87fb..5801b8a 100644 --- a/service_account_records/app_accounts.py +++ b/service_account_records/app_accounts.py @@ -1,7 +1,7 @@ import sys -if '/service_account_records' not in list(sys.path): - sys.path.append('/service_account_records') +if "/service_account_records" not in list(sys.path): + sys.path.append("/service_account_records") from decimal import Decimal diff --git a/service_account_records/regex_func.py b/service_account_records/regex_func.py index e020e4e..5bf0990 100644 --- a/service_account_records/regex_func.py +++ b/service_account_records/regex_func.py @@ -1,7 +1,7 @@ import sys -if '/service_account_records' not in list(sys.path): - sys.path.append('/service_account_records') +if "/service_account_records" not in list(sys.path): + sys.path.append("/service_account_records") import re diff --git a/service_app_banks/app_mail_sender.py b/service_app_banks/app_mail_sender.py index 7aa741f..6bc304c 100644 --- a/service_app_banks/app_mail_sender.py +++ b/service_app_banks/app_mail_sender.py @@ -1,7 +1,7 @@ import sys -if '/service_app_banks' not in list(sys.path): - sys.path.append('/service_app_banks') +if "/service_app_banks" not in list(sys.path): + sys.path.append("/service_app_banks") from api_services.email.service import send_email from api_library.date_time_actions.date_functions import client_arrow diff --git a/service_app_banks/isbank/isbank_sender.py b/service_app_banks/isbank/isbank_sender.py index b43546a..0be21c1 100644 --- a/service_app_banks/isbank/isbank_sender.py +++ b/service_app_banks/isbank/isbank_sender.py @@ -1,7 +1,7 @@ import sys -if '/service_app_banks' not in list(sys.path): - sys.path.append('/service_app_banks') +if "/service_app_banks" not in list(sys.path): + sys.path.append("/service_app_banks") import os import json diff --git a/service_app_init/initialize_app/event_initator.py b/service_app_init/initialize_app/event_initator.py index 890edda..02dc6ef 100644 --- a/service_app_init/initialize_app/event_initator.py +++ b/service_app_init/initialize_app/event_initator.py @@ -5,10 +5,9 @@ from databases import ( Employees, 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( created_by="System", @@ -95,8 +94,11 @@ def add_events_all_services_and_occupant_types(): service_selected.update( related_responsibility=getattr(event_block_class, "related_code", None) ) - for block in event_block_class(): - event_id, event_uu_id = block + for event_id, event_uu_id in event_block_class(): + 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_id=service_selected.id, service_uu_id=str(service_selected.uu_id), @@ -121,8 +123,13 @@ def add_events_to_system_super_user(): if not add_employee: raise Exception("Super User Employee not found") - ServiceBindEmployeeEventMethods.bind_services_employee( - service_id=add_service.id, - employee_id=add_employee.id, + ModulesBindEmployeeEventMethods.bind_default_module_for_first_init_occupant( + 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() diff --git a/service_app_test/bases.py b/service_app_test/bases.py index 33ef8d3..aef00b9 100644 --- a/service_app_test/bases.py +++ b/service_app_test/bases.py @@ -94,12 +94,13 @@ class RequestToApi: access_token = content.get("access_token") refresh_token = content.get("refresh_token") access_object = content.get("access_object") + print('access_object', access_object) if not access_object: raise Exception("Access object is not found") companies_uu_id_list = None 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": companies_uu_id_list = access_object.get("available_occupants") @@ -111,7 +112,8 @@ class RequestToApi: self.set_access_token(access_token) 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( endpoint="authentication/select", data={"company_uu_id": uu_id} ) diff --git a/service_app_test/test_application/migrate_old_data/runner.py b/service_app_test/test_application/migrate_old_data/runner.py index e8bf5b4..9cf470d 100644 --- a/service_app_test/test_application/migrate_old_data/runner.py +++ b/service_app_test/test_application/migrate_old_data/runner.py @@ -50,8 +50,8 @@ def decode_as_json_indent(data): return json.dumps(json.loads(json.dumps(data)), indent=2) -password_token = "FGS095it2IBP3gIp5glaG6u9tQy1KEPzKnBYE1fvGJSGvGUhwaGgxE-56yZAxUQnW-a_J91twOFKTWTc0ue4GZq10vY7fK2cZBsR9bUDJMCHZZZGpFYbsE6pLyaDs-1_K8v5hbggSmpXNFfafMmujuXxqvSzdLQa5hcg9qepHBOvgTbL28wGRHx9w-Fcb7bL" -password_token_occ = "kM9vHcWZVVF38IyNxMk6XMlCc8FCc_P1D-0D2u-Er5FrcQzvswSjJe9Lu9QnhJ5fJw5WqC45UYxopme_aCX6YDfZfQ3wQ9RP4Ak5YYTWBZbtwKGXTomlpYCQJghy0RC-1-Q9ATNEgcjYXqU2P9UjjdS9JNvhUawT0R38wXap-Mum6oazjqiKow41SUebnZ-H" +password_token = "AVqRAPWQ9yvZqX14pWEAHfv72MsTYbjrlPNH97xDPr9RrDySPmu1zlPEH-IsQ9GNR1wrGQHv4xsR6eNbZYDe8rnvYbaiGOFpu1t18AMOZBEB3cKiashFCXznglPGd670QmAsRAqC-VO8GsIoGjtRr2ZQCKVY2lXTc3RcqRA26YXP31Bc-mDr_nzpjQCGrVcd" +password_token_occ = "" login_data = { "domain": "evyos.com.tr", "access_key": "karatay.berkay.sup@evyos.com.tr", @@ -67,8 +67,8 @@ login_creds_occupant = { "password_token": password_token_occ, } selection_list = [ - "d9ffa716-331c-48fc-83b2-47bf31289b3e", - "afebb7f8-9f62-4703-b11c-ee8f14fe73b7", + # "d9ffa716-331c-48fc-83b2-47bf31289b3e", + # "afebb7f8-9f62-4703-b11c-ee8f14fe73b7", ] 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( login_data=login_data, is_password_valid=False ) - # migrate_company(requester=both_apis) - # migrate_people(requester=both_apis) - # migrate_build(requester=both_apis) - # migrate_build_living_space(requester=both_apis) - migrate_account_records(requester=both_apis) + migrate_company(requester=both_apis) + migrate_people(requester=both_apis) + migrate_build(requester=both_apis) + migrate_build_living_space(requester=both_apis) + # migrate_account_records(requester=both_apis) if assign_people_to_create_item == 0: if not bool(selection_list):