mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-22 23:04:21 +00:00
✨ Add the /api/core/version
view
This commit is contained in:
parent
703d0d7a3c
commit
1b842770bc
3 changed files with 21 additions and 0 deletions
|
@ -35,6 +35,13 @@
|
||||||
<inspection_tool class="PyRelativeImportInspection" enabled="true" level="WARNING" enabled_by_default="true" />
|
<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="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="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="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="PyTrailingSemicolonInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
<inspection_tool class="PyUnnecessaryBackslashInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
<inspection_tool class="PyUnnecessaryBackslashInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
|
|
|
@ -10,4 +10,5 @@ router.register("groups", views.ResearchGroupViewSet, basename="research-group")
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", include(router.urls)),
|
path("", include(router.urls)),
|
||||||
|
path("version", views.VersionView.as_view())
|
||||||
]
|
]
|
||||||
|
|
|
@ -2,6 +2,8 @@ import abc
|
||||||
import typing as t
|
import typing as t
|
||||||
|
|
||||||
import deprecation
|
import deprecation
|
||||||
|
import pkg_resources
|
||||||
|
from rest_framework.views import APIView
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.viewsets import ModelViewSet
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.serializers import Serializer
|
from rest_framework.serializers import Serializer
|
||||||
|
@ -245,3 +247,14 @@ class SophonGroupViewSet(SophonViewSet, metaclass=abc.ABCMeta):
|
||||||
return permissions.Edit,
|
return permissions.Edit,
|
||||||
else:
|
else:
|
||||||
return permissions.AllowAny,
|
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)
|
||||||
|
|
Loading…
Reference in a new issue