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

app.api.schemas.key   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 24
dl 0
loc 44
rs 10
c 0
b 0
f 0
1
# -*- coding:utf-8 -*-
2
"""
3
KeySchema module
4
"""
5
6
from loglan_core import Key as BaseKey, Definition
7
from marshmallow_sqlalchemy.fields import Nested
8
9
from app.api.schemas import ma
10
11
12
# TODO from loglan_core.addons.addon_key_getter import AddonKeyGetter
13
14
15
class Key(
16
    BaseKey,
17
):  # AddonKeyGetter
18
    __tablename__ = BaseKey.__tablename__
19
20
21
class KeySchema(ma.SQLAlchemyAutoSchema):
22
    class Meta:
23
        model = Key
24
        include_fk = True
25
        exclude = ("created", "updated", "_definitions")
26
27
    _definitions = Nested(
28
        "DefinitionSchema",
29
        exclude=["word_id", "keys"],
30
        many=True,
31
        only={
32
            *Definition.attributes_basic(),
33
            *Definition.relationships(),
34
            "source_word",
35
        },
36
    )
37
    definitions = _definitions
38
39
40
key_schema_nested = KeySchema(only=Key.attributes_basic())
41
key_schema_full = KeySchema(only=(*Key.attributes_extended(), "definitions"))
42
43
blue_print_export = (Key, key_schema_nested, key_schema_full)
44