Skip to content

Commit d3e3818

Browse files
committed
Add version display to admin header and site footer
- Add context processor to expose APP_VERSION to templates - Set admin site header/title to "Grorg v{version}" - Display version in the site footer - Make admin URL configurable via ADMIN_URL env var (defaults to django-admin/) - Disable admin nav sidebar
1 parent e015313 commit d3e3818

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

config/context_processors.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from __future__ import annotations
2+
3+
from config import __version__
4+
5+
6+
def version(request) -> dict:
7+
return {
8+
"APP_VERSION": __version__,
9+
}

config/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"django.template.context_processors.request",
4646
"django.contrib.auth.context_processors.auth",
4747
"django.contrib.messages.context_processors.messages",
48+
"config.context_processors.version",
4849
],
4950
"debug": DEBUG,
5051
},
@@ -127,6 +128,8 @@
127128

128129
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
129130

131+
ADMIN_URL = env.str("ADMIN_URL", default="django-admin/")
132+
130133
SITE_ID = 1
131134

132135
AUTHENTICATION_BACKENDS = [

config/urls.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
from __future__ import annotations
22

3+
from django.conf import settings
34
from django.contrib import admin
45
from django.urls import include
56
from django.urls import path
67

7-
from grants.views import bulk_load, program
8+
from config import __version__
89
from config.views import favicon
10+
from grants.views import bulk_load, program
911
from users import views as users
1012

13+
admin_header = f"Grorg v{__version__}"
14+
admin.site.enable_nav_sidebar = False
15+
admin.site.site_header = admin_header
16+
admin.site.site_title = admin_header
17+
1118
urlpatterns = [
1219
path("health/", include("health_check.urls")),
1320
path("favicon.ico", favicon),
@@ -17,7 +24,7 @@
1724
# path("logout/", auth.views.LogoutView.as_view()),
1825
path("register/", users.register, name="register"),
1926
path("join/", users.join, name="join"),
20-
path("admin/", admin.site.urls),
27+
path(settings.ADMIN_URL, admin.site.urls),
2128
path("programs/create/", program.CreateProgram.as_view(), name="create_program"),
2229
path("<str:program>/", program.ProgramHome.as_view()),
2330
path("<str:program>/edit/", program.EditProgram.as_view(), name="edit_program"),

templates/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ <h1 class="text-2xl font-bold text-gray-900">
106106
<footer class="bg-gray-100 border-t border-gray-200 mt-auto">
107107
<div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
108108
<div class="text-center text-sm text-gray-600 space-y-2">
109-
<p>&copy; {% now "Y" %} Grorg - A grant management platform</p>
109+
<p>&copy; {% now "Y" %} Grorg v{{ APP_VERSION }} - A grant management platform</p>
110110
<p class="space-x-4">
111111
<a href="https://github.com/djangocon/grorg" class="hover:text-gray-900 transition-colors">Open Source on GitHub</a>
112112
<span class="text-gray-400">|</span>

0 commit comments

Comments
 (0)