feat: modules and module-editor pages
This commit is contained in:
95
schemas/attribute.py
Normal file
95
schemas/attribute.py
Normal file
@ -0,0 +1,95 @@
|
||||
from typing import Optional, Any
|
||||
|
||||
from schemas.base import BaseSchema, BaseResponse
|
||||
|
||||
|
||||
# region Entity
|
||||
|
||||
|
||||
class AttributeTypeSchema(BaseSchema):
|
||||
id: int
|
||||
type: str
|
||||
name: str
|
||||
|
||||
|
||||
class CreateAttributeSchema(BaseSchema):
|
||||
label: str
|
||||
is_applicable_to_group: bool
|
||||
is_shown_on_dashboard: bool
|
||||
is_highlight_if_expired: bool
|
||||
is_nullable: bool
|
||||
default_value: Optional[dict[str, Any]]
|
||||
description: str
|
||||
type_id: int
|
||||
|
||||
|
||||
class AttributeSchema(CreateAttributeSchema):
|
||||
id: int
|
||||
is_built_in: bool
|
||||
type: AttributeTypeSchema
|
||||
|
||||
|
||||
class UpdateAttributeSchema(BaseSchema):
|
||||
label: Optional[str] = None
|
||||
is_applicable_to_group: Optional[bool] = None
|
||||
is_shown_on_dashboard: Optional[bool] = None
|
||||
is_highlight_if_expired: Optional[bool] = None
|
||||
is_nullable: Optional[bool] = None
|
||||
default_value: Optional[dict[str, Any]] = None
|
||||
description: Optional[str] = None
|
||||
type: Optional[AttributeTypeSchema] = None
|
||||
|
||||
|
||||
class ModuleAttributeSchema(AttributeSchema):
|
||||
original_label: str
|
||||
|
||||
|
||||
# endregion
|
||||
|
||||
# region Request
|
||||
|
||||
|
||||
class CreateAttributeRequest(BaseSchema):
|
||||
entity: CreateAttributeSchema
|
||||
|
||||
|
||||
class UpdateAttributeRequest(BaseSchema):
|
||||
entity: UpdateAttributeSchema
|
||||
|
||||
|
||||
class UpdateAttributeLabelRequest(BaseSchema):
|
||||
module_id: int
|
||||
attribute_id: int
|
||||
label: str
|
||||
|
||||
|
||||
# endregion
|
||||
|
||||
# region Response
|
||||
|
||||
|
||||
class GetAllAttributesResponse(BaseSchema):
|
||||
items: list[AttributeSchema]
|
||||
|
||||
|
||||
class CreateAttributeResponse(BaseResponse):
|
||||
pass
|
||||
|
||||
|
||||
class UpdateAttributeResponse(BaseResponse):
|
||||
pass
|
||||
|
||||
|
||||
class DeleteAttributeResponse(BaseResponse):
|
||||
pass
|
||||
|
||||
|
||||
class UpdateAttributeLabelResponse(BaseResponse):
|
||||
pass
|
||||
|
||||
|
||||
class GetAllAttributeTypesResponse(BaseSchema):
|
||||
items: list[AttributeTypeSchema]
|
||||
|
||||
|
||||
# endregion
|
||||
@ -1,4 +1,8 @@
|
||||
from schemas.base import BaseSchema
|
||||
from typing import Optional
|
||||
|
||||
from schemas.attribute import ModuleAttributeSchema
|
||||
from schemas.base import BaseSchema, BaseResponse
|
||||
|
||||
|
||||
# region Entity
|
||||
|
||||
@ -15,11 +19,41 @@ class ModuleSchema(BaseSchema):
|
||||
id: int
|
||||
key: str
|
||||
label: str
|
||||
description: str
|
||||
description: Optional[str]
|
||||
is_built_in: bool
|
||||
depends_on: list["ModuleSchema"]
|
||||
tabs: list[ModuleTabSchema]
|
||||
|
||||
|
||||
class ModuleWithAttributesSchema(ModuleSchema):
|
||||
attributes: list[ModuleAttributeSchema]
|
||||
|
||||
|
||||
class UpdateModuleCommonInfoSchema(BaseSchema):
|
||||
label: str
|
||||
description: Optional[str]
|
||||
|
||||
|
||||
# endregion
|
||||
|
||||
|
||||
# region Requests
|
||||
|
||||
|
||||
class AddAttributeRequest(BaseSchema):
|
||||
attribute_id: int
|
||||
module_id: int
|
||||
|
||||
|
||||
class DeleteAttributeRequest(BaseSchema):
|
||||
attribute_id: int
|
||||
module_id: int
|
||||
|
||||
|
||||
class UpdateModuleCommonInfoRequest(BaseSchema):
|
||||
entity: UpdateModuleCommonInfoSchema
|
||||
|
||||
|
||||
# endregion
|
||||
|
||||
# region Response
|
||||
@ -29,4 +63,28 @@ class GetAllModulesResponse(BaseSchema):
|
||||
items: list[ModuleSchema]
|
||||
|
||||
|
||||
class GetAllWithAttributesResponse(BaseSchema):
|
||||
items: list[ModuleWithAttributesSchema]
|
||||
|
||||
|
||||
class GetByIdWithAttributesResponse(BaseSchema):
|
||||
entity: ModuleWithAttributesSchema
|
||||
|
||||
|
||||
class UpdateModuleCommonInfoResponse(BaseResponse):
|
||||
pass
|
||||
|
||||
|
||||
class DeleteModuleResponse(BaseResponse):
|
||||
pass
|
||||
|
||||
|
||||
class AddAttributeResponse(BaseResponse):
|
||||
pass
|
||||
|
||||
|
||||
class DeleteAttributeResponse(BaseResponse):
|
||||
pass
|
||||
|
||||
|
||||
# endregion
|
||||
|
||||
Reference in New Issue
Block a user