Code clean up

This commit is contained in:
2022-04-10 16:40:56 +03:00
parent e536574e84
commit 138e0ffa2f
20 changed files with 12 additions and 525 deletions

View File

@@ -3,8 +3,6 @@ from typing import Optional
from pydantic import BaseModel
from app.serializers.orjson_config import ORJSONConfig
class Author(BaseModel):
id: int
@@ -15,30 +13,6 @@ class Author(BaseModel):
annotation_exists: bool
class Config(ORJSONConfig):
pass
class CreateAuthor(BaseModel):
source: int
remote_id: int
first_name: str
last_name: str
middle_name: Optional[str]
class Config(ORJSONConfig):
pass
class UpdateAuthor(BaseModel):
first_name: str
last_name: str
middle_name: Optional[str]
class Config(ORJSONConfig):
pass
class AuthorBook(BaseModel):
id: int
@@ -50,9 +24,6 @@ class AuthorBook(BaseModel):
translators: list[Author]
annotation_exists: bool
class Config(ORJSONConfig):
pass
class TranslatedBook(BaseModel):
id: int
@@ -62,6 +33,3 @@ class TranslatedBook(BaseModel):
available_types: list[str]
authors: list[Author]
annotation_exists: bool
class Config(ORJSONConfig):
pass

View File

@@ -2,33 +2,9 @@ from typing import Optional
from pydantic import BaseModel
from app.serializers.orjson_config import ORJSONConfig
class AuthorAnnotation(BaseModel):
id: int
title: str
text: str
file: Optional[str]
class Config(ORJSONConfig):
pass
class CreateAuthorAnnotation(BaseModel):
author: int
title: str
text: str
file: Optional[str]
class Config(ORJSONConfig):
pass
class UpdateAuthorAnnotation(BaseModel):
title: str
text: str
file: Optional[str]
class Config(ORJSONConfig):
pass

View File

@@ -3,7 +3,6 @@ from datetime import date
from pydantic import BaseModel
from app.serializers.author import Author
from app.serializers.orjson_config import ORJSONConfig
from app.serializers.sequence import Sequence
@@ -28,9 +27,6 @@ class Book(BaseModel):
translators: list[Author]
annotation_exists: bool
class Config(ORJSONConfig):
pass
class RemoteBook(Book):
source: BookSource
@@ -41,40 +37,3 @@ class BookDetail(RemoteBook):
sequences: list[Sequence]
genres: list[BookGenre]
is_deleted: bool
class CreateBook(BaseModel):
source: int
remote_id: int
title: str
lang: str
file_type: str
uploaded: date
authors: list[int]
class Config(ORJSONConfig):
pass
class UpdateBook(BaseModel):
title: str
lang: str
file_type: str
uploaded: date
authors: list[int]
class Config(ORJSONConfig):
pass
class CreateRemoteBook(BaseModel):
source: int
remote_id: int
title: str
lang: str
file_type: str
uploaded: date
remote_authors: list[int]
class Config(ORJSONConfig):
pass

View File

@@ -2,34 +2,9 @@ from typing import Optional
from pydantic import BaseModel
from app.serializers.orjson_config import ORJSONConfig
class BookAnnotation(BaseModel):
id: int
title: str
text: str
file: Optional[str]
class Config(ORJSONConfig):
pass
class CreateBookAnnotation(BaseModel):
id: int
title: str
text: str
file: Optional[str]
class Config(ORJSONConfig):
pass
class UpdateBookAnnotation(BaseModel):
id: int
title: str
text: str
file: Optional[str]
class Config(ORJSONConfig):
pass

View File

@@ -1,6 +1,4 @@
from pydantic import BaseModel, constr
from app.serializers.orjson_config import ORJSONConfig
from pydantic import BaseModel
class GenreSource(BaseModel):
@@ -15,28 +13,3 @@ class Genre(BaseModel):
code: str
description: str
meta: str
class Config(ORJSONConfig):
pass
class CreateGenre(BaseModel):
source: int
remote_id: int
code: constr(max_length=45) # type: ignore
description: constr(max_length=99) # type: ignore
meta: constr(max_length=45) # type: ignore
class Config(ORJSONConfig):
pass
class UpdateGenre(BaseModel):
source: int
remote_id: int
code: constr(max_length=45) # type: ignore
description: constr(max_length=99) # type: ignore
meta: constr(max_length=45) # type: ignore
class Config(ORJSONConfig):
pass

View File

@@ -1,10 +0,0 @@
import orjson
def orjson_dumps(v, *, default):
return orjson.dumps(v, default=default).decode()
class ORJSONConfig:
json_loads = orjson.loads
json_dumps = orjson_dumps

View File

@@ -3,25 +3,11 @@ from typing import Optional
from pydantic import BaseModel
from app.serializers.orjson_config import ORJSONConfig
class Sequence(BaseModel):
id: int
name: str
class Config(ORJSONConfig):
pass
class CreateSequence(BaseModel):
source: int
remote_id: int
name: str
class Config(ORJSONConfig):
pass
class Author(BaseModel):
id: int
@@ -30,9 +16,6 @@ class Author(BaseModel):
last_name: str
middle_name: Optional[str]
class Config(ORJSONConfig):
pass
class Book(BaseModel):
id: int
@@ -44,6 +27,3 @@ class Book(BaseModel):
authors: list[Author]
translators: list[Author]
annotation_exists: bool
class Config(ORJSONConfig):
pass

View File

@@ -1,18 +1,6 @@
from pydantic import BaseModel
from app.serializers.orjson_config import ORJSONConfig
class Source(BaseModel):
id: int
name: str
class Config(ORJSONConfig):
pass
class CreateSource(BaseModel):
name: str
class Config(ORJSONConfig):
pass

View File

@@ -1,7 +1,5 @@
from pydantic import BaseModel
from app.serializers.orjson_config import ORJSONConfig
class TranslationBook(BaseModel):
id: int
@@ -9,9 +7,6 @@ class TranslationBook(BaseModel):
lang: str
file_type: str
class Config(ORJSONConfig):
pass
class TranslationTranslator(BaseModel):
id: int
@@ -19,33 +14,8 @@ class TranslationTranslator(BaseModel):
last_name: str
middle_name: str
class Config(ORJSONConfig):
pass
class Translation(BaseModel):
book: TranslationBook
translator: TranslationTranslator
position: int
class Config(ORJSONConfig):
pass
class CreateTranslation(BaseModel):
book: int
translator: int
position: int
class Config(ORJSONConfig):
pass
class CreateRemoteTranslation(BaseModel):
source: int
remote_book: int
remote_translator: int
position: int
class Config(ORJSONConfig):
pass