Skip to content

Commit 57fb948

Browse files
committed
Replace ADMIN_TOOLBAR_VERSION with new APP_VERSION setting
1 parent f6d8162 commit 57fb948

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

plain-admin/plain/admin/default_settings.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

plain-admin/plain/admin/toolbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class Toolbar:
1111
def __init__(self, request):
1212
self.request = request
13-
self.version = settings.ADMIN_TOOLBAR_VERSION
13+
self.version = settings.APP_VERSION
1414

1515
def should_render(self):
1616
if settings.DEBUG:

plain/plain/runtime/global_settings.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
by the PLAIN_SETTINGS_MODULE environment variable.
44
"""
55

6-
from .utils import get_app_name_from_pyproject
6+
from .utils import get_app_info_from_pyproject
77

88
# MARK: Core Settings
99

1010
DEBUG: bool = False
1111

12-
APP_NAME: str = get_app_name_from_pyproject()
12+
name, version = get_app_info_from_pyproject()
13+
APP_NAME: str = name
14+
APP_VERSION: str = version
1315

1416
# List of strings representing installed packages.
1517
INSTALLED_PACKAGES: list[str] = []

plain/plain/runtime/utils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from pathlib import Path
33

44

5-
def get_app_name_from_pyproject():
6-
"""Get the project name from the nearest pyproject.toml file."""
5+
def get_app_info_from_pyproject():
6+
"""Get the project name and version from the nearest pyproject.toml file."""
77
current_path = Path.cwd()
88

99
# Walk up the directory tree looking for pyproject.toml
@@ -13,8 +13,11 @@ def get_app_name_from_pyproject():
1313
try:
1414
with pyproject_path.open("rb") as f:
1515
pyproject = tomllib.load(f)
16-
return pyproject.get("project", {}).get("name", "App")
16+
project = pyproject.get("project", {})
17+
name = project.get("name", "App")
18+
version = project.get("version", "dev")
19+
return name, version
1720
except (tomllib.TOMLDecodeError, OSError):
1821
continue
1922

20-
return "App"
23+
return "App", "dev"

0 commit comments

Comments
 (0)