From e683394e719f670a362f0a6b71448db5182dc3bd Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Thu, 18 Apr 2024 16:33:47 +0200 Subject: [PATCH 1/3] Using importlib to grab our version --- brostar_api/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/brostar_api/__init__.py b/brostar_api/__init__.py index 5568b6d..480f903 100644 --- a/brostar_api/__init__.py +++ b/brostar_api/__init__.py @@ -1,5 +1,8 @@ # This will make sure the app is always imported when # Django starts so that shared_task will use this app. +from importlib.metadata import version + from .celery import app as celery_app __all__ = ("celery_app",) +__version__ = version("brostar_api") From 40d87bc2742b8c39de74c9ad22768e345d9f190e Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Thu, 18 Apr 2024 16:34:18 +0200 Subject: [PATCH 2/3] Added a small test for the version number --- CHANGES.md | 2 +- brostar_api/tests/test_init.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 brostar_api/tests/test_init.py diff --git a/CHANGES.md b/CHANGES.md index 3bed17b..7826e67 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,7 +3,7 @@ ## 0.8 (unreleased) -- Nothing changed yet. +- Made internal brostar_api version number available. ## 0.7 (2024-04-18) diff --git a/brostar_api/tests/test_init.py b/brostar_api/tests/test_init.py new file mode 100644 index 0000000..f6802c8 --- /dev/null +++ b/brostar_api/tests/test_init.py @@ -0,0 +1,4 @@ +def test_version(): + from brostar_api import __version__ + + assert __version__ From ed419b380a42ce04a4168b596c4f2f8e4fb06341 Mon Sep 17 00:00:00 2001 From: Florian Knappers <73856313+JJFlorian@users.noreply.github.com> Date: Thu, 18 Apr 2024 16:56:59 +0200 Subject: [PATCH 3/3] added version to api --- api/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/views.py b/api/views.py index 476edf3..d7d6a0f 100644 --- a/api/views.py +++ b/api/views.py @@ -15,6 +15,7 @@ from api import filters, mixins, models, serializers from api.bro_upload import utils +from brostar_api import __version__ class LogoutView(views.APIView): @@ -56,6 +57,9 @@ def get(self, request: HttpRequest, format: Any = None) -> HttpResponse: return Response(data) +APIOverview.__doc__ = f"**BROstar version**: *{__version__}*" + + class LocalHostRedirectView(APIView): """ View that redirects user to localhost:4200.