|
| 1 | +from os import statvfs |
| 2 | + |
| 3 | +from drf_spectacular.utils import ( |
| 4 | + OpenApiExample, |
| 5 | + OpenApiRequest, |
| 6 | + extend_schema, |
| 7 | + inline_serializer, |
| 8 | +) |
| 9 | +from hurry.filesize import size |
1 | 10 | from rest_framework import serializers, status
|
2 | 11 | from rest_framework.response import Response
|
3 | 12 | from rest_framework.views import APIView
|
4 |
| -from api.serializers.v1_1 import CreateAssetSerializerV1_1 |
5 |
| -from api.serializers import ( |
6 |
| - AssetSerializer, |
7 |
| - UpdateAssetSerializer, |
8 |
| -) |
| 13 | + |
| 14 | +from anthias_app.models import Asset |
9 | 15 | from api.helpers import (
|
10 |
| - AssetCreationException, |
| 16 | + AssetCreationError, |
11 | 17 | parse_request,
|
12 | 18 | )
|
13 |
| -from drf_spectacular.utils import ( |
14 |
| - extend_schema, |
15 |
| - inline_serializer, |
16 |
| - OpenApiExample, |
17 |
| - OpenApiRequest, |
| 19 | +from api.serializers import ( |
| 20 | + AssetSerializer, |
| 21 | + UpdateAssetSerializer, |
18 | 22 | )
|
19 |
| -from hurry.filesize import size |
20 |
| -from lib import diagnostics |
21 |
| -from lib.auth import authorized |
22 |
| -from lib.github import is_up_to_date |
23 |
| -from lib.utils import connect_to_redis |
24 |
| -from os import statvfs |
25 |
| -from anthias_app.models import Asset |
| 23 | +from api.serializers.v1_1 import CreateAssetSerializerV1_1 |
26 | 24 | from api.views.mixins import (
|
27 | 25 | AssetContentViewMixin,
|
28 | 26 | AssetsControlViewMixin,
|
|
34 | 32 | RecoverViewMixin,
|
35 | 33 | ShutdownViewMixin,
|
36 | 34 | )
|
| 35 | +from lib import diagnostics |
| 36 | +from lib.auth import authorized |
| 37 | +from lib.github import is_up_to_date |
| 38 | +from lib.utils import connect_to_redis |
37 | 39 | from settings import ZmqCollector, ZmqPublisher
|
38 | 40 |
|
39 |
| - |
40 | 41 | r = connect_to_redis()
|
41 | 42 |
|
42 | 43 | MODEL_STRING_EXAMPLE = """
|
@@ -146,8 +147,8 @@ def post(self, request, format=None):
|
146 | 147 | try:
|
147 | 148 | serializer = CreateAssetSerializerV1_1(data=data)
|
148 | 149 | if not serializer.is_valid():
|
149 |
| - raise AssetCreationException(serializer.errors) |
150 |
| - except AssetCreationException as error: |
| 150 | + raise AssetCreationError(serializer.errors) |
| 151 | + except AssetCreationError as error: |
151 | 152 | return Response(error.errors, status=status.HTTP_400_BAD_REQUEST)
|
152 | 153 |
|
153 | 154 | asset = Asset.objects.create(**serializer.data)
|
|
0 commit comments