3 Commits

Author SHA1 Message Date
5291956a31 Add assigned aircraft tp output excel 2025-11-28 12:06:28 +01:00
7f908157bf Added git hash as version number 2025-11-28 11:48:29 +01:00
35f773047d Updated version, Updated poetry 2025-11-28 11:19:45 +01:00
9 changed files with 42 additions and 24 deletions

5
cntmanage/docker/build.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
GIT_HASH=$(git rev-parse --short HEAD)
echo "Building Flightslot version ${GIT_HASH}"
docker compose build --build-arg GIT_HASH=${GIT_HASH}

View File

@@ -22,6 +22,8 @@ services:
build: build:
context: .. context: ..
dockerfile: ./docker/flightslot.Dockerfile dockerfile: ./docker/flightslot.Dockerfile
args:
GIT_HASH:
image: flightslot:latest image: flightslot:latest
container_name: tech-flightslot container_name: tech-flightslot
restart: unless-stopped restart: unless-stopped

View File

@@ -23,5 +23,5 @@ else
echo "👁️ Superuser ${DJANGO_SUPERUSER_USERNAME} created successfully ..." echo "👁️ Superuser ${DJANGO_SUPERUSER_USERNAME} created successfully ..."
fi fi
echo "🚀 Launching Flightslot..." echo "🚀 Launching Flightslot version ${VERSION} ..."
exec "$@" exec "$@"

View File

@@ -4,7 +4,6 @@ FROM python:3.12 AS builder
# Install Poetry # Install Poetry
RUN curl -sSL https://install.python-poetry.org | python3 - RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH="${PATH}:/root/.local/bin" ENV PATH="${PATH}:/root/.local/bin"
RUN env
# Create build directory # Create build directory
WORKDIR /build WORKDIR /build
# Copy project files # Copy project files
@@ -14,28 +13,26 @@ RUN poetry update --no-interaction --no-ansi
# Build project # Build project
RUN poetry build RUN poetry build
### STAGE 2 — Final image ### STAGE 2 — Final image ###
FROM python:3.12-slim AS deploy FROM python:3.12-slim AS deploy
# Create app run directory
WORKDIR /app WORKDIR /app
# Copy application custom static files # Copy application custom static files
RUN mkdir -p static RUN mkdir -p static
COPY ./static/cantorair.jpg ./static COPY ./static/cantorair.jpg ./static
COPY ./static/cantorair_blue.jpg ./static COPY ./static/cantorair_blue.jpg ./static
# Copy application custom templates for admin page # Copy application custom templates for admin page
RUN mkdir -p /templates/admin RUN mkdir -p /templates/admin
COPY ./templates/admin/* ./templates/admin/ COPY ./templates/admin/* ./templates/admin/
# Copy and install application wheel package # Copy and install application wheel package
COPY --from=builder /build/dist/*.whl ./ COPY --from=builder /build/dist/*.whl ./
RUN pip install --no-cache-dir *.whl RUN pip install --no-cache-dir *.whl
RUN pip install gunicorn whitenoise RUN pip install gunicorn whitenoise
# Copy entryupoint bash script # Copy entryupoint bash script
COPY ./docker/entrypoint.sh ./ COPY ./docker/entrypoint.sh ./
# Collect build number from build arg
ARG GIT_HASH
ENV VERSION=${GIT_HASH}
ENTRYPOINT ["/app/entrypoint.sh"] ENTRYPOINT ["/app/entrypoint.sh"]
# Command to be executed after entry point # Command to be executed after entry point
CMD ["gunicorn", "cntmanage.wsgi:application", "--bind", "0.0.0.0:8000", "--timeout", "600"] CMD ["gunicorn", "cntmanage.wsgi:application", "--bind", "0.0.0.0:8000", "--timeout", "600"]

View File

@@ -5,13 +5,12 @@ from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill, Alignment, Border, Side from openpyxl.styles import Font, PatternFill, Alignment, Border, Side
from openpyxl.utils import get_column_letter from openpyxl.utils import get_column_letter
from datetime import date, datetime
from typing import List
from ..models.weekpref import WeekPreference
from ..models.missions import Training from ..models.missions import Training
from ..models.weekpref import WeekPreference
from ..models.hourbuildings import HourBuilding, HourBuildingLegFlight, HourBuildingLegStop, HourBuildingLegBase from ..models.hourbuildings import HourBuilding, HourBuildingLegFlight, HourBuildingLegStop, HourBuildingLegBase
from datetime import date, datetime
from typing import List
def export_selected(request: HttpRequest, queryset: QuerySet[WeekPreference]) -> HttpResponse: def export_selected(request: HttpRequest, queryset: QuerySet[WeekPreference]) -> HttpResponse:
@@ -83,8 +82,17 @@ def export_selected(request: HttpRequest, queryset: QuerySet[WeekPreference]) ->
student_data: List[str] student_data: List[str]
student_phone: str = q.student.phone if q.student.phone else "" student_phone: str = q.student.phone if q.student.phone else ""
student_email: str = q.student.email student_email: str = q.student.email
student_course_type: str
student_course_number: str
student_course_ac: str
if q.student.course: if q.student.course:
student_data = [f"{q.student.surname} {q.student.name}", f"{q.student.course.ctype}-{q.student.course.cnumber}"] student_course_type = q.student.course.ctype
student_course_number = str(q.student.course.cnumber)
student_course_ac = " / ".join(t.type for t in q.student.aircrafts.distinct("type").all())
student_data = [
f"{q.student.surname} {q.student.name}\n{student_course_ac}",
f"{student_course_type}-{student_course_number}"
]
else: else:
student_data = [f"{q.student.surname} {q.student.name}", f"No Course Assigned"] student_data = [f"{q.student.surname} {q.student.name}", f"No Course Assigned"]

View File

@@ -15,6 +15,9 @@ from .admins.weekpref_adm import WeekPreferenceAdmin
from django.contrib.admin import AdminSite from django.contrib.admin import AdminSite
from os import environ
# User website under /user/ URL
class FlightSlotUserSite(AdminSite): class FlightSlotUserSite(AdminSite):
site_header = "Flight Scheduler 🛫" site_header = "Flight Scheduler 🛫"
site_title = "Flight Scheduler 🛫" site_title = "Flight Scheduler 🛫"
@@ -28,13 +31,16 @@ class FlightSlotUserSite(AdminSite):
return app_list return app_list
# Register only user visible models
flightslot_user = FlightSlotUserSite(name="user_site") flightslot_user = FlightSlotUserSite(name="user_site")
# registra SOLO i modelli autorizzati
flightslot_user.register(WeekPreference, WeekPreferenceAdmin) flightslot_user.register(WeekPreference, WeekPreferenceAdmin)
admin.site.site_header = "Flight Scheduler Admin 🛫"
admin.site.site_title = "Flight Scheduler Admin 🛫" # Get version for debug purposes
ver: str = environ.get("VERSION", "dev")
# Register all visible models
admin.site.site_header = f"Flight Scheduler Admin 🛫 - ver.{ver}"
admin.site.site_title = f"Flight Scheduler Admin 🛫 - ver.{ver}"
admin.site.index_title = "Welcome to CantorAir Flight Scheduler Administrator Portal" admin.site.index_title = "Welcome to CantorAir Flight Scheduler Administrator Portal"
admin.site.register(Aircraft, AircraftAdmin) admin.site.register(Aircraft, AircraftAdmin)

View File

@@ -1,4 +1,4 @@
from django.forms import ModelChoiceField, TypedMultipleChoiceField, ModelMultipleChoiceField from django.forms import ModelMultipleChoiceField
from django.contrib import admin, messages from django.contrib import admin, messages
from django.http import HttpRequest from django.http import HttpRequest
from django.db.models.query import QuerySet, Q from django.db.models.query import QuerySet, Q

8
cntmanage/poetry.lock generated
View File

@@ -385,18 +385,18 @@ files = [
[[package]] [[package]]
name = "sqlparse" name = "sqlparse"
version = "0.5.3" version = "0.5.4"
description = "A non-validating SQL parser." description = "A non-validating SQL parser."
optional = false optional = false
python-versions = ">=3.8" python-versions = ">=3.8"
groups = ["main"] groups = ["main"]
files = [ files = [
{file = "sqlparse-0.5.3-py3-none-any.whl", hash = "sha256:cf2196ed3418f3ba5de6af7e82c694a9fbdbfecccdfc72e281548517081f16ca"}, {file = "sqlparse-0.5.4-py3-none-any.whl", hash = "sha256:99a9f0314977b76d776a0fcb8554de91b9bb8a18560631d6bc48721d07023dcb"},
{file = "sqlparse-0.5.3.tar.gz", hash = "sha256:09f67787f56a0b16ecdbde1bfc7f5d9c3371ca683cfeaa8e6ff60b4807ec9272"}, {file = "sqlparse-0.5.4.tar.gz", hash = "sha256:4396a7d3cf1cd679c1be976cf3dc6e0a51d0111e87787e7a8d780e7d5a998f9e"},
] ]
[package.extras] [package.extras]
dev = ["build", "hatch"] dev = ["build"]
doc = ["sphinx"] doc = ["sphinx"]
[[package]] [[package]]

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "cntmanage" name = "cntmanage"
version = "0.1.0" version = "0.2.0"
packages = [{include = "flightslot"}, {include = "cntmanage"}] packages = [{include = "flightslot"}, {include = "cntmanage"}]
description = "CantorAir Flight Scheduler" description = "CantorAir Flight Scheduler"
authors = ["Emanuele <ema.trabattoni@gmail.com>"] authors = ["Emanuele <ema.trabattoni@gmail.com>"]