diff --git a/config/settings/base.py b/config/settings/base.py index 8cf4fdc..f72f99a 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -149,7 +149,6 @@ "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", - "django.middleware.common.BrokenLinkEmailsMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", "reversion.middleware.RevisionMiddleware", "allauth.account.middleware.AccountMiddleware", diff --git a/config/settings/production.py b/config/settings/production.py index 1756902..5f56a22 100644 --- a/config/settings/production.py +++ b/config/settings/production.py @@ -187,6 +187,9 @@ "maxBytes": 1024 * 1024 * 15, # 15MB "backupCount": 10, }, + "null": { + "class": "logging.NullHandler", + }, }, "root": {"level": "INFO", "handlers": ["console"]}, "loggers": { @@ -200,10 +203,12 @@ "level": "ERROR", "propagate": True, }, + # Bots hitting the ALB by IP send a Host header not in ALLOWED_HOSTS. + # Django already answers 400; logging these just buries real errors + # (and would trigger mail_admins if that's ever enabled). "django.security.DisallowedHost": { - "level": "ERROR", - "handlers": ["console"], - "propagate": True, + "handlers": ["null"], + "propagate": False, }, "anymail": { "handlers": ["console", "applogfile"], diff --git a/teleband/dashboards/views.py b/teleband/dashboards/views.py index 6345f6b..d590fc8 100644 --- a/teleband/dashboards/views.py +++ b/teleband/dashboards/views.py @@ -199,8 +199,8 @@ def test_func(self): def get_context_data(self, **kwargs): ctx = super().get_context_data(**kwargs) - ctx["courses"] = ( - Course.objects.select_related("owner").order_by("-start_date", "name") + ctx["courses"] = Course.objects.select_related("owner").order_by( + "-start_date", "name" ) return ctx @@ -238,9 +238,7 @@ def research_data_view(request): atts_by_sub = defaultdict(list) for att in attachments: if att.file: - atts_by_sub[att.submission_id].append( - {"id": att.id, "url": att.file.url} - ) + atts_by_sub[att.submission_id].append({"id": att.id, "url": att.file.url}) subs_by_ca = defaultdict(list) for sub in submissions: @@ -270,9 +268,7 @@ def research_data_view(request): assn_data["submissions"].append( { "id": sub.id, - "student": sub.enrollment.user.id - if sub.enrollment - else None, + "student": sub.enrollment.user.id if sub.enrollment else None, "instrument": str(sub.instrument) if sub.instrument else None, "submitted": sub.submitted.strftime("%Y-%m-%d %H:%M"), "content": sub.content,