diff --git a/CHANGELOG.md b/CHANGELOG.md index 84e42836..69136a49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,11 +17,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Changed + +- Now using `django_twc_toolbox.views` for some core views. See the removed section below. + ### Fixed - Fixed reference to correct `lock` command in `just docs upgrade` just command. - Changed the `default-app` build target from `app` to `dev`. This fixes an error running the stack in development where the worker container does not have the development dependencies installed. +### Removed + +- Removed all views except the `index` view from the template project's `core/views.py`, in favor of `django_twc_toolbox.views`. + ## [2024.40] ### Changed diff --git a/src/django_twc_project/{{ module_name }}/core/views.py b/src/django_twc_project/{{ module_name }}/core/views.py index e8dbf38e..4f9805af 100644 --- a/src/django_twc_project/{{ module_name }}/core/views.py +++ b/src/django_twc_project/{{ module_name }}/core/views.py @@ -4,40 +4,9 @@ from django.http import HttpRequest from django.http import HttpResponse from django.shortcuts import render -from django.utils import timezone -from django.views.decorators.cache import cache_control from django.views.decorators.http import require_GET -def custom_error_404( - request: HttpRequest, exception: Exception | None = None, *args, **kwargs -) -> HttpResponse: - return render(request, "404.html", context={}, status=404) - - -def custom_error_500(request: HttpRequest, *args, **kwargs) -> HttpResponse: - return render(request, "500.html", context={}, status=500) - - -@require_GET -@cache_control(max_age=60 * 60 * 24, immutable=True, public=True) # one day -def robots_txt(request: HttpRequest) -> HttpResponse: - return render(request, "robots.txt", content_type="text/plain") - - -@require_GET -@cache_control(max_age=60 * 60 * 24, immutable=True, public=True) # one day -def security_txt(request: HttpRequest) -> HttpResponse: - return render( - request, - ".well-known/security.txt", - context={ - "year": timezone.now().year + 1, - }, - content_type="text/plain", - ) - - @require_GET @login_required def index(request: HttpRequest) -> HttpResponse: diff --git a/src/django_twc_project/{{ module_name }}/urls.py.jinja b/src/django_twc_project/{{ module_name }}/urls.py.jinja index ad0220cd..dd938f7a 100644 --- a/src/django_twc_project/{{ module_name }}/urls.py.jinja +++ b/src/django_twc_project/{{ module_name }}/urls.py.jinja @@ -4,6 +4,7 @@ from django.conf import settings from django.contrib import admin from django.urls import include from django.urls import path +from django_twc_toolbox import views as toolbox_views from health_check.views import MainView from {{ module_name }} import __version__ @@ -15,19 +16,19 @@ admin.site.site_header = admin_header admin.site.site_title = admin_header urlpatterns = [ - path(".well-known/security.txt", core_views.security_txt), - path("robots.txt", core_views.robots_txt), + path(".well-known/security.txt", toolbox_views.security_txt), + path("robots.txt", toolbox_views.robots_txt), path("", include("django_twc_ui.favicons.urls")), - path("404/", core_views.custom_error_404, name="404"), - path("500/", core_views.custom_error_500, name="500"), + path("404/", toolbox_views.custom_error_404, name="404"), + path("500/", toolbox_views.custom_error_500, name="500"), path("accounts/", include("allauth.urls")), path("admin/", admin.site.urls), path("health/", MainView.as_view()), path("", core_views.index, name="index"), ] -handler404 = "{{ module_name }}.core.views.custom_error_404" # noqa: F811 -handler500 = "{{ module_name }}.core.views.custom_error_500" # noqa: F811 +handler404 = "django_twc_toolbox.views.custom_error_404" # noqa: F811 +handler500 = "django_twc_toolbox.views.custom_error_500" # noqa: F811 if settings.DEBUG: