super_user and services updated
This commit is contained in:
parent
88f94c37c2
commit
88309eb49d
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)],
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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 []:
|
||||
|
|
|
|||
|
|
@ -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}%"),
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in New Issue