Compare commits

...

2 Commits

Author SHA1 Message Date
bisco 0fe57dc47f fix(admin): handle unsaved performance seats display 2026-04-29 18:56:19 +02:00
bisco 784076e6be fix(docker): serve django static files via nginx 2026-04-29 18:46:53 +02:00
5 changed files with 37 additions and 5 deletions
+2 -1
View File
@@ -112,7 +112,8 @@ DEFAULT_FROM_EMAIL = os.environ.get("DEFAULT_FROM_EMAIL", "no-reply@azionelab.lo
if "test" in sys.argv:
EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
STATIC_URL = "static/"
STATIC_URL = "/static/"
STATIC_ROOT = BASE_DIR / "staticfiles"
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
REST_FRAMEWORK = {
+7
View File
@@ -41,4 +41,11 @@ class PerformanceAdmin(admin.ModelAdmin):
@admin.display(description="Available seats")
def available_seats_display(self, obj):
if (
not getattr(obj, "pk", None)
or obj.room_capacity is None
or obj.additional_seats is None
or obj.manually_occupied_seats is None
):
return "-"
return obj.available_seats()
+20 -1
View File
@@ -1,5 +1,7 @@
from django.contrib import admin
from django.test import SimpleTestCase
from django.contrib.auth import get_user_model
from django.test import SimpleTestCase, TestCase
from django.urls import reverse
from bookings.models import Reservation, ReservationToken
from checkins.models import CheckIn
@@ -11,3 +13,20 @@ class AdminRegistrationTests(SimpleTestCase):
for model in (Show, Venue, Performance, Reservation, ReservationToken, CheckIn):
with self.subTest(model=model.__name__):
self.assertTrue(admin.site.is_registered(model))
class PerformanceAdminTests(TestCase):
def setUp(self):
user_model = get_user_model()
self.admin_user = user_model.objects.create_superuser(
username="admin",
email="admin@example.com",
password="password123",
)
self.client.force_login(self.admin_user)
def test_performance_add_page_renders_for_unsaved_object(self):
response = self.client.get(reverse("admin:shows_performance_add"))
self.assertEqual(response.status_code, 200)
self.assertContains(response, "Available seats")
+5
View File
@@ -19,11 +19,14 @@ services:
POSTGRES_PORT: ${POSTGRES_PORT:-5432}
expose:
- "${BACKEND_PORT:-8000}"
volumes:
- django_static:/app/staticfiles
depends_on:
postgres:
condition: service_healthy
networks:
- internal
user: "0:0"
restart: unless-stopped
frontend:
@@ -66,6 +69,7 @@ services:
NGINX_ENVSUBST_FILTER: "^(BACKEND_HOST|BACKEND_PORT|FRONTEND_HOST|FRONTEND_PORT)$"
volumes:
- ./nginx/templates:/etc/nginx/templates:ro
- django_static:/var/www/static:ro
depends_on:
- backend
- frontend
@@ -75,6 +79,7 @@ services:
volumes:
postgres_data:
django_static:
networks:
internal:
@@ -29,9 +29,9 @@ server {
}
location /static/ {
proxy_pass http://azionelab_backend;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
alias /var/www/static/;
access_log off;
expires 1d;
}
location /media/ {