updated app reachable codes

This commit is contained in:
2025-04-09 11:51:28 +03:00
parent 7eadadbd1d
commit 7c2150a8b0
23 changed files with 1040 additions and 187 deletions

View File

@@ -0,0 +1,28 @@
FROM python:3.12-slim
WORKDIR /
# Install system dependencies and Poetry
RUN apt-get update && apt-get install -y --no-install-recommends gcc \
&& rm -rf /var/lib/apt/lists/* && pip install --no-cache-dir poetry
# Copy Poetry configuration
COPY /pyproject.toml ./pyproject.toml
# Configure Poetry and install dependencies with optimizations
RUN poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi --no-root --only main \
&& pip cache purge && rm -rf ~/.cache/pypoetry
# Copy application code
COPY /ApiServices/DealerService /ApiServices/DealerService
COPY /ApiServices/DealerService /
COPY /Controllers /Controllers
COPY /Modules /Modules
COPY /Schemas /Schemas
# Set Python path to include app directory
ENV PYTHONPATH=/ PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1
# Run the application using the configured uvicorn server
CMD ["poetry", "run", "python", "ApiServices/DealerService/app.py"]

View File

@@ -0,0 +1,24 @@
from Controllers.Postgres.database import get_db
from Schemas import (
Users,
Employees,
)
from init_service_to_events import init_service_to_event_matches_for_super_user
from init_applications import init_applications_for_super_user
if __name__ == "__main__":
"""
Create Applications to serve on Next.js | Create Events to add to Service
Set Events to service | Set Service to employee
"""
with get_db() as db_session:
if super_man := Users.filter_one(
Users.email == "karatay.berkay.sup@evyos.com.tr", db=db_session
).data:
super_employee = Employees.filter_one(
Employees.people_id == super_man.person_id, db=db_session
).data
init_service_to_event_matches_for_super_user(super_user=super_employee, db_session=db_session)
init_applications_for_super_user(super_user=super_employee, db_session=db_session)

View File

@@ -0,0 +1,40 @@
from Schemas import (
Applications,
Application2Employee,
Employees
)
def init_applications_for_super_user(super_user: Employees, db_session=None) -> None:
list_of_created_apps = [
dict(
name="Dashboard1",
application_code = "app000001",
site_url = "/dashboard",
application_type = "info",
description = "Dashboard Page"
),
dict(
name="Dashboard2",
application_code = "app000002",
site_url = "/buildings/list",
application_type = "CreateFrom",
description = "Dashboard Page"
),
]
for list_of_created_app in list_of_created_apps:
dashboard_page = Applications.find_or_create(
**list_of_created_app, db=db_session,
)
print('dashboard_page', dashboard_page)
if dashboard_page.meta_data.created:
dashboard_page.save(db=db_session)
Application2Employee.find_or_create(
employee_id=super_user.id,
employee_uu_id=str(super_user.uu_id),
site_url=dashboard_page.site_url,
application_code=dashboard_page.application_code,
application_id=dashboard_page.id,
application_uu_id=str(dashboard_page.uu_id),
db=db_session,
)

View File

@@ -0,0 +1,47 @@
from Schemas import (
Users,
Services,
Service2Events,
Applications,
Application2Employee,
Application2Occupant,
Employees,
Event2Employee,
)
list_of_event_codes = []
def init_service_to_event_matches_for_super_user(super_user, db_session=None) -> None:
service_match = Services.filter_one(
Services.service_name == "Super User", db=db_session,
).data
for list_of_event_code in list_of_event_codes:
created_service = Service2Events.find_or_create(
service_id=service_match.id,
service_uu_id=str(service_match.uu_id),
event_id=list_of_event_code.id,
event_uu_id=str(list_of_event_code.uu_id),
is_confirmed=True,
active=True,
db=db_session,
)
if created_service.meta_data.created:
created_service.save(db=db_session)
print(
f"UUID: {created_service.uu_id} event is saved to {service_match.uu_id}"
)
employee_added_service = Event2Employee.find_or_create(
event_service_id=created_service.id,
event_service_uu_id=str(created_service.uu_id),
employee_id=super_user.id,
employee_uu_id=str(super_user.uu_id),
is_confirmed=True,
db=db_session
)
if employee_added_service.meta_data.created:
employee_added_service.save(db=db_session)
print(
f"UUID: {employee_added_service.uu_id} event is saved to {super_user.uu_id}"
)