Total Complexity | 0 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 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 |