This commit is contained in:
Ross
2025-12-08 09:52:18 +00:00
parent 02a9118faf
commit 0917947a98
8 changed files with 24 additions and 4 deletions
+3 -2
View File
@@ -18,5 +18,6 @@ GUNICORN_WORKERS=3
GUNICORN_LOGLEVEL=info GUNICORN_LOGLEVEL=info
# Nginx host ports for local development (override prod defaults) # Nginx host ports for local development (override prod defaults)
NGINX_HTTP_PORT=8000 NGINX_HTTP_PORT=8080
NGINX_HTTPS_PORT=8443 # Pick a non-privileged HTTPS port to avoid conflicts with host installs
NGINX_HTTPS_PORT=8444
+2
View File
@@ -16,3 +16,5 @@ temp/
# Loki runtime data # Loki runtime data
/docker/loki-data/ /docker/loki-data/
/docker/loki-wal/ /docker/loki-wal/
# Local runtime logs collected by Promtail
/logs/
+4
View File
@@ -7,6 +7,10 @@ server {
listen [::]:80; listen [::]:80;
server_name _; server_name _;
# Write logs to the host-mounted folder so Promtail can scrape them
access_log /var/log/rad/nginx.access.log combined;
error_log /var/log/rad/nginx.error.log warn;
client_max_body_size 100M; client_max_body_size 100M;
location /static/ { location /static/ {
+8
View File
@@ -8,6 +8,10 @@ server {
listen [::]:80; listen [::]:80;
server_name _; server_name _;
# Write logs to the host-mounted folder so Promtail can scrape them
access_log /var/log/rad/nginx.access.log combined;
error_log /var/log/rad/nginx.error.log warn;
client_max_body_size 100M; client_max_body_size 100M;
# Serve static files from the static volume # Serve static files from the static volume
@@ -112,6 +116,10 @@ server {
client_max_body_size 4G; client_max_body_size 4G;
# Write logs to the host-mounted folder so Promtail can scrape them
access_log /var/log/rad/nginx.access.log combined;
error_log /var/log/rad/nginx.error.log warn;
# Same static/media handling as above # Same static/media handling as above
location /static/ { alias /usr/src/app/static/; } location /static/ { alias /usr/src/app/static/; }
location /media { alias /usr/src/app/media; } location /media { alias /usr/src/app/media; }
+1
View File
@@ -24,6 +24,7 @@ services:
image: nginx:1.25-alpine image: nginx:1.25-alpine
volumes: volumes:
- ../deploy/nginx/dev.conf:/etc/nginx/conf.d/default.conf:ro - ../deploy/nginx/dev.conf:/etc/nginx/conf.d/default.conf:ro
- ../logs:/var/log/rad:rw
loki: loki:
image: grafana/loki:2.8.2 image: grafana/loki:2.8.2
+1
View File
@@ -45,6 +45,7 @@ services:
- web - web
volumes: volumes:
- ../deploy/nginx/prod.conf:/etc/nginx/conf.d/default.conf:ro - ../deploy/nginx/prod.conf:/etc/nginx/conf.d/default.conf:ro
- ../logs:/var/log/rad:rw
- static_volume:/usr/src/app/static:ro - static_volume:/usr/src/app/static:ro
- media_volume:/usr/src/app/media:ro - media_volume:/usr/src/app/media:ro
- ../deploy/nginx/certs:/etc/letsencrypt:ro - ../deploy/nginx/certs:/etc/letsencrypt:ro
+3
View File
@@ -65,6 +65,9 @@ class AuthorMixin():
def is_author(self, user: User) -> bool: def is_author(self, user: User) -> bool:
"""Returns True if the user is an author of the object""" """Returns True if the user is an author of the object"""
if user.is_superuser:
return True
return self.author.filter(id=user.id).exists() return self.author.filter(id=user.id).exists()
+1 -1
View File
@@ -1774,7 +1774,7 @@ class ExamViews(View, LoginRequiredMixin):
def exam_list_collection(self, request, collection_id): def exam_list_collection(self, request, collection_id):
collection = get_object_or_404(ExamCollection, pk=collection_id) collection = get_object_or_404(ExamCollection, pk=collection_id)
if not request.user in collection.author.all(): if not collection.is_author(request.user):
raise PermissionDenied raise PermissionDenied
return self.exam_list(request, all=True, collection=collection) return self.exam_list(request, all=True, collection=collection)