From 80e766b8add7616cbf7d224709f146cf3c6e2f84 Mon Sep 17 00:00:00 2001 From: David Slusser Date: Wed, 6 Aug 2025 22:11:49 -0700 Subject: [PATCH 1/2] adding host info page --- src/django_project/core/settings.py | 2 +- .../web/templates/web/full/host_info.html | 77 +++++++++++++++++++ src/django_project/web/urls/gui.py | 2 + src/django_project/web/views/gui.py | 17 ++++ 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 src/django_project/web/templates/web/full/host_info.html diff --git a/src/django_project/core/settings.py b/src/django_project/core/settings.py index 6236cf4..c6a0cf6 100644 --- a/src/django_project/core/settings.py +++ b/src/django_project/core/settings.py @@ -296,5 +296,5 @@ PROJECT_DESCRIPTION = ( """spokane_python is a super awesome project powered, in part, by amazing code provided by DjangoAddicts.""" ) -PROJECT_VERSION = env.str("PROJECT_VERSION", "0.0.1") +PROJECT_VERSION = env.str("IMAGE_TAG", "0.0.0") PROJECT_SOURCE = "https://github.com/SpokaneTech/SpokanePythonWeb" diff --git a/src/django_project/web/templates/web/full/host_info.html b/src/django_project/web/templates/web/full/host_info.html new file mode 100644 index 0000000..6fd0a10 --- /dev/null +++ b/src/django_project/web/templates/web/full/host_info.html @@ -0,0 +1,77 @@ +{% load static %} + + + + + + + + + + + + + + + + + + Spokane Python User Group + + + + + + +
+
+

+

Spokane Python User Group

+ +

This page provides information about the host system running this application.

+
+
+ Start Time: + {{ HH_STARTTIME }} +
+
+ Version + {{ PROJECT_VERSION }} +
+
+ Python Version: + {{ python_version }} +
+
+ Django Version: + {{ django_version }} +
+
+ Hostname: + {{ hostname }} +
+
+ Source Code: + {{ source_code }} +
+
+ Client IP Address: + {{ remote_ip_address }} +
+
+ Client User Agent: + {{ user_agent }} +
+
+
+
+ + diff --git a/src/django_project/web/urls/gui.py b/src/django_project/web/urls/gui.py index 8dea15d..2bf38fe 100644 --- a/src/django_project/web/urls/gui.py +++ b/src/django_project/web/urls/gui.py @@ -1,4 +1,5 @@ from django.urls import path + from web.views import gui urlpatterns = [ @@ -7,6 +8,7 @@ path("index/", gui.IndexView.as_view(), name="index"), path("default/", gui.IndexView.as_view(), name="default"), path("home/", gui.IndexView.as_view(), name="home"), + path("host/", gui.HostView.as_view(), name="host_info"), # HTMX views path("htmx/resource-list//", gui.ResourceListPartialView.as_view(), name="htmx_resource_list"), path("htmx/past-events/", gui.PastEventsPartialView.as_view(), name="htmx_past_events"), diff --git a/src/django_project/web/views/gui.py b/src/django_project/web/views/gui.py index d48ed31..d03571c 100644 --- a/src/django_project/web/views/gui.py +++ b/src/django_project/web/views/gui.py @@ -1,5 +1,8 @@ +import sys from typing import Any +import django +from django.conf import settings from django.db.models.manager import BaseManager from django.http import HttpResponse from django.shortcuts import render @@ -7,6 +10,7 @@ from django.views import View from django.views.generic import TemplateView from handyhelpers.views.htmx import HtmxFormPostSimple, HtmxPartialView + from web.forms import PresentationRequestForm, TopicSuggestionForm from web.models import Event, Resource, ResourceCategory @@ -15,6 +19,19 @@ class IndexView(TemplateView): template_name = "web/full/index.html" +class HostView(View): + def get(self, request) -> HttpResponse: + host_info: dict[str, str] = { + "hostname": request.get_host(), + "remote_ip_address": request.META.get("REMOTE_ADDR", "Unknown"), + "user_agent": request.META.get("HTTP_USER_AGENT", "Unknown"), + "source_code": getattr(settings, "PROJECT_SOURCE", "Unknown"), + "python_version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + "django_version": django.get_version(), + } + return render(request, "web/full/host_info.html", host_info) + + class ResourceListPartialView(View): def get(self, request, pk) -> HttpResponse: category: Any = ResourceCategory.objects.get_object_or_none(pk=pk) From 41a58d2fe34c17c27c5ff1feffa602fb6bdd63f8 Mon Sep 17 00:00:00 2001 From: David Slusser Date: Wed, 6 Aug 2025 22:12:02 -0700 Subject: [PATCH 2/2] adding host info page --- src/django_project/web/urls/gui.py | 1 - src/django_project/web/views/gui.py | 1 - 2 files changed, 2 deletions(-) diff --git a/src/django_project/web/urls/gui.py b/src/django_project/web/urls/gui.py index 2bf38fe..1419009 100644 --- a/src/django_project/web/urls/gui.py +++ b/src/django_project/web/urls/gui.py @@ -1,5 +1,4 @@ from django.urls import path - from web.views import gui urlpatterns = [ diff --git a/src/django_project/web/views/gui.py b/src/django_project/web/views/gui.py index d03571c..a4438df 100644 --- a/src/django_project/web/views/gui.py +++ b/src/django_project/web/views/gui.py @@ -10,7 +10,6 @@ from django.views import View from django.views.generic import TemplateView from handyhelpers.views.htmx import HtmxFormPostSimple, HtmxPartialView - from web.forms import PresentationRequestForm, TopicSuggestionForm from web.models import Event, Resource, ResourceCategory