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

app.api.schemas.event   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 17
dl 0
loc 30
rs 10
c 0
b 0
f 0
1
# -*- coding:utf-8 -*-
2
"""
3
EventSchema module
4
"""
5
6
from loglan_core import Event, Word
7
from marshmallow_sqlalchemy.fields import Nested
8
9
from app.api.schemas import ma
10
11
12
class EventSchema(ma.SQLAlchemyAutoSchema):
13
    class Meta:
14
        model = Event
15
        include_fk = True
16
        exclude = ("created", "updated", "_appeared_words", "_deprecated_words")
17
18
    _appeared_words = Nested("WordSchema", only=Word.attributes_basic(), many=True)
19
    appeared_words = _appeared_words
20
    _deprecated_words = Nested("WordSchema", only=Word.attributes_basic(), many=True)
21
    deprecated_words = _deprecated_words
22
23
24
event_schema_nested = EventSchema(only=Event.attributes_basic())
25
event_schema_full = EventSchema(
26
    only=(*Event.attributes_extended(), "appeared_words", "deprecated_words")
27
)
28
29
blue_print_export = (Event, event_schema_nested, event_schema_full)
30