| 8 | |
| 9 | |
| 10 | class ObjectiveSchema(ma.Schema): |
| 11 | |
| 12 | class Meta: |
| 13 | unknown = ma.EXCLUDE |
| 14 | |
| 15 | id = ma.fields.String() |
| 16 | name = ma.fields.String() |
| 17 | description = ma.fields.String() |
| 18 | goals = ma.fields.List(ma.fields.Nested(GoalSchema)) |
| 19 | percentage = ma.fields.Float(dump_only=True) |
| 20 | |
| 21 | @ma.pre_load |
| 22 | def remove_properties(self, data, **_): |
| 23 | data.pop('percentage', None) |
| 24 | return data |
| 25 | |
| 26 | @ma.post_load |
| 27 | def build_objective(self, data, **kwargs): |
| 28 | return None if kwargs.get('partial') is True else Objective(**data) |
| 29 | |
| 30 | |
| 31 | class Objective(FirstClassObjectInterface, BaseObject): |
no outgoing calls