mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-22 23:04:21 +00:00
🔧 Merge version
route into instance
This commit is contained in:
parent
47d0e5c2ff
commit
bd8a6c4994
4 changed files with 11 additions and 15 deletions
|
@ -6,6 +6,8 @@ properly.
|
|||
from __future__ import annotations
|
||||
import typing
|
||||
import abc
|
||||
|
||||
import pkg_resources
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from rest_framework.serializers import ModelSerializer
|
||||
|
@ -203,12 +205,17 @@ class SophonInstanceDetails(SophonModel):
|
|||
max_length=32,
|
||||
)
|
||||
|
||||
@property
|
||||
def version(self) -> str:
|
||||
return pkg_resources.get_distribution("sophon").version
|
||||
|
||||
@classmethod
|
||||
def get_fields(cls) -> set[str]:
|
||||
return {
|
||||
"name",
|
||||
"description",
|
||||
"theme",
|
||||
"version",
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from django.contrib.auth.models import User
|
||||
from rest_framework.serializers import Serializer, ModelSerializer
|
||||
from rest_framework.serializers import Serializer, ModelSerializer, CharField
|
||||
|
||||
|
||||
class NoneSerializer(Serializer):
|
||||
|
|
|
@ -11,6 +11,5 @@ router.register("users", views.UserViewSet, basename="user")
|
|||
|
||||
urlpatterns = [
|
||||
path("", include(router.urls)),
|
||||
path("version", views.VersionView.as_view()),
|
||||
path("instance", views.SophonInstanceDetailsView.as_view()),
|
||||
]
|
||||
|
|
|
@ -279,17 +279,6 @@ class SophonGroupViewSet(WriteSophonViewSet, metaclass=abc.ABCMeta):
|
|||
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=s.HTTP_200_OK)
|
||||
|
||||
|
||||
class SophonInstanceDetailsView(APIView):
|
||||
"""
|
||||
Get the details of this Sophon instance.
|
||||
|
@ -298,6 +287,7 @@ class SophonInstanceDetailsView(APIView):
|
|||
# noinspection PyMethodMayBeStatic,PyUnusedLocal
|
||||
def get(self, request, format=None):
|
||||
details = models.SophonInstanceDetails.objects.get()
|
||||
Serializer = details.get_view_serializer()
|
||||
serializer = Serializer(instance=details)
|
||||
# noinspection PyPep8Naming
|
||||
ViewSerializer = details.get_view_serializer()
|
||||
serializer = ViewSerializer(instance=details)
|
||||
return Response(serializer.data, status=s.HTTP_200_OK)
|
||||
|
|
Loading…
Reference in a new issue