mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Make API code cleaner
This commit is contained in:
parent
c24882bf66
commit
24fb68bd3e
@ -4,9 +4,8 @@ from django.conf import settings
|
||||
from django.urls import include, re_path
|
||||
|
||||
from django_filters.rest_framework import DjangoFilterBackend
|
||||
from rest_framework import filters, generics, permissions, status
|
||||
from rest_framework import filters, generics, permissions
|
||||
from rest_framework.exceptions import NotFound
|
||||
from rest_framework.response import Response
|
||||
|
||||
import plugin.serializers as PluginSerializers
|
||||
from common.api import GlobalSettingsPermissions
|
||||
@ -99,17 +98,6 @@ class PluginInstall(generics.CreateAPIView):
|
||||
queryset = PluginConfig.objects.none()
|
||||
serializer_class = PluginSerializers.PluginConfigInstallSerializer
|
||||
|
||||
def create(self, request, *args, **kwargs):
|
||||
serializer = self.get_serializer(data=request.data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
result = self.perform_create(serializer)
|
||||
result['input'] = serializer.data
|
||||
headers = self.get_success_headers(serializer.data)
|
||||
return Response(result, status=status.HTTP_201_CREATED, headers=headers)
|
||||
|
||||
def perform_create(self, serializer):
|
||||
return serializer.save()
|
||||
|
||||
|
||||
class PluginSettingList(generics.ListAPIView):
|
||||
"""List endpoint for all plugin related settings.
|
||||
|
@ -144,7 +144,8 @@ class PluginConfigInstallSerializer(serializers.Serializer):
|
||||
with open(settings.PLUGIN_FILE, "a") as plugin_file:
|
||||
plugin_file.write(f'{" ".join(install_name)} # Installed {timezone.now()} by {str(self.context["request"].user)}\n')
|
||||
|
||||
return ret
|
||||
# Set result as serializer data -> this will be returned
|
||||
self.data = ret
|
||||
|
||||
|
||||
class PluginSettingSerializer(GenericReferencedSettingSerializer):
|
||||
|
Loading…
Reference in New Issue
Block a user