Пример #1
0
    def file(self, request, **kwargs):
        obj = self.get_object()
        if request.method == "GET":
            return self.download_file(obj.image.path, "application/binary")

        if not request.user.has_perm("screenshot.edit", obj.component):
            raise PermissionDenied()

        serializer = ScreenshotFileSerializer(data=request.data)
        serializer.is_valid(raise_exception=True)

        obj.image.save(serializer.validated_data["image"].name,
                       serializer.validated_data["image"])

        return Response(data={"result": True})
Пример #2
0
    def file(self, request, **kwargs):
        obj = self.get_object()
        if request.method == 'GET':
            return self.download_file(
                obj.image.path,
                'application/binary',
            )

        if not request.user.has_perm('screenshot.edit', obj.component):
            raise PermissionDenied()

        serializer = ScreenshotFileSerializer(data=request.data)
        serializer.is_valid(raise_exception=True)

        obj.image.save(serializer.validated_data['image'].name,
                       serializer.validated_data['image'])

        return Response(data={
            'result': True,
        })
Пример #3
0
    def file(self, request, **kwargs):
        obj = self.get_object()
        if request.method == 'GET':
            return self.download_file(
                obj.image.path,
                'application/binary',
            )

        if not request.user.has_perm('screenshot.edit', obj.component):
            raise PermissionDenied()

        serializer = ScreenshotFileSerializer(data=request.data)
        serializer.is_valid(raise_exception=True)

        obj.image.save(
            serializer.validated_data['image'].name,
            serializer.validated_data['image']
        )

        return Response(data={
            'result': True,
        })