mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 04:25:42 +00:00
factor out read_license_file
This commit is contained in:
@ -35,21 +35,7 @@ from .version import inventreeApiText
|
||||
logger = structlog.get_logger('inventree')
|
||||
|
||||
|
||||
class LicenseViewSerializer(serializers.Serializer):
|
||||
"""Serializer for license information."""
|
||||
|
||||
backend = serializers.CharField(help_text='Backend licenses texts', read_only=True)
|
||||
frontend = serializers.CharField(
|
||||
help_text='Frontend licenses texts', read_only=True
|
||||
)
|
||||
|
||||
|
||||
class LicenseView(APIView):
|
||||
"""Simple JSON endpoint for InvenTree license information."""
|
||||
|
||||
permission_classes = [permissions.IsAuthenticated]
|
||||
|
||||
def read_license_file(self, path: Path) -> list:
|
||||
def read_license_file(path: Path) -> list:
|
||||
"""Extract license information from the provided file.
|
||||
|
||||
Arguments:
|
||||
@ -90,6 +76,21 @@ class LicenseView(APIView):
|
||||
|
||||
return output
|
||||
|
||||
|
||||
class LicenseViewSerializer(serializers.Serializer):
|
||||
"""Serializer for license information."""
|
||||
|
||||
backend = serializers.CharField(help_text='Backend licenses texts', read_only=True)
|
||||
frontend = serializers.CharField(
|
||||
help_text='Frontend licenses texts', read_only=True
|
||||
)
|
||||
|
||||
|
||||
class LicenseView(APIView):
|
||||
"""Simple JSON endpoint for InvenTree license information."""
|
||||
|
||||
permission_classes = [permissions.IsAuthenticated]
|
||||
|
||||
@extend_schema(responses={200: OpenApiResponse(response=LicenseViewSerializer)})
|
||||
def get(self, request, *args, **kwargs):
|
||||
"""Return information about the InvenTree server."""
|
||||
@ -98,8 +99,8 @@ class LicenseView(APIView):
|
||||
'web/static/web/.vite/dependencies.json'
|
||||
)
|
||||
return JsonResponse({
|
||||
'backend': self.read_license_file(backend),
|
||||
'frontend': self.read_license_file(frontend),
|
||||
'backend': read_license_file(backend),
|
||||
'frontend': read_license_file(frontend),
|
||||
})
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user