1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-22 06:44:21 +00:00

Add the /api/core/version view

This commit is contained in:
Steffo 2021-09-14 03:28:33 +02:00
parent f1606a5c50
commit ad839d567c
3 changed files with 21 additions and 0 deletions

View file

@ -35,6 +35,13 @@
<inspection_tool class="PyRelativeImportInspection" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="PyReturnFromInitInspection" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="PySetFunctionToLiteralInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PyShadowingBuiltinsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredNames">
<list>
<option value="format" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyStringFormatInspection" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="PyTrailingSemicolonInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PyUnnecessaryBackslashInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />

View file

@ -10,4 +10,5 @@ router.register("groups", views.ResearchGroupViewSet, basename="research-group")
urlpatterns = [
path("", include(router.urls)),
path("version", views.VersionView.as_view())
]

View file

@ -2,6 +2,8 @@ import abc
import typing as t
import deprecation
import pkg_resources
from rest_framework.views import APIView
from rest_framework.viewsets import ModelViewSet
from rest_framework.response import Response
from rest_framework.serializers import Serializer
@ -245,3 +247,14 @@ class SophonGroupViewSet(SophonViewSet, metaclass=abc.ABCMeta):
return permissions.Edit,
else:
return permissions.AllowAny,
class VersionView(APIView):
"""
Get the Sophon server version.
"""
# noinspection PyMethodMayBeStatic,PyUnusedLocal
def get(self, request, format=None):
version = pkg_resources.get_distribution("sophon").version
return Response(version, status=status.HTTP_200_OK)