Passed
Push — master ( 38bed0...e25529 )
by torrua
01:14
created

app.api.schemas.definition   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 19
dl 0
loc 34
rs 10
c 0
b 0
f 0
1
# -*- coding:utf-8 -*-
2
"""
3
DefinitionSchema module
4
"""
5
6
from loglan_core import Definition, Word, Key
7
from marshmallow_sqlalchemy.fields import Nested
8
9
from app.api.schemas import ma
10
from app.api.schemas.key import KeySchema
11
12
13
class DefinitionSchema(ma.SQLAlchemyAutoSchema):
14
    class Meta:
15
        model = Definition
16
        include_fk = True
17
        exclude = ("created", "updated", "_keys", "_source_word")
18
19
    _source_word = Nested("WordSchema", only=Word.attributes_basic())
20
    source_word = _source_word
21
22
    _keys = Nested(KeySchema, only=Key.attributes_basic(), many=True)
23
    keys = _keys
24
25
26
definition_schema_nested = DefinitionSchema(
27
    only=(*Definition.attributes_basic(), "source_word")
28
)
29
definition_schema_full = DefinitionSchema(
30
    only=(*Definition.attributes_extended(), "keys", "source_word")
31
)
32
33
blue_print_export = (Definition, definition_schema_nested, definition_schema_full)
34