Source code for pynami.schemas.training

# -*- coding: utf-8 -*-
"""
Schemas for trainings
"""
from marshmallow import fields

from .base import BaseSchema, BaseSearchSchema, BaseModel, BaseSearchModel


[docs]class SearchAusbildung(BaseSearchModel): """ Main class for a training obtained as a search result. This class is intended to be instantiated by calling the :meth:`~marshmallow.Schema.load` method on a corresponding data dictionary. """ _tabkeys = ['id', 'vstgTag', 'baustein'] def __repr__(self): return f'<SearchAusbildung({self.baustein}, Id: {self.id})>' def __str__(self): return f'{self.baustein} ({self.id}): {self.vstgTag}'
[docs] def get_ausbildung(self, nami, mglId): """ Create a real :class:`Ausbildung` form the search result by getting the corresponding data set through the training id. Args: nami (:class:`~pynami.nami.NaMi`): Main |NAMI| class mglId (int): Member id (not |DPSG| Mitgliedsnummer) Returns: Ausbildung: The activity object corresponding to this search result. """ return nami.get_ausbildung(mglId, self.id)
[docs]class SearchAusbildungSchema(BaseSearchSchema): """ Schema class for the :class:`SearchAusbildung` class """ __model__ = SearchAusbildung entries_vstgTag = fields.Date(attribute='vstgTag') """:class:`~datetime.date`: Day of the training event""" entries_veranstalter = fields.String(attribute='veranstalter') """str: Who organized the event (e.g. a `Bezirk`)""" entries_vstgName = fields.String(attribute='vstgName') """str: Name of the event""" entries_baustein = fields.String(attribute='baustein') """str: Name of the training (e.g. ``'Baustein 3a'``)""" entries_id = fields.Integer(attribute='id_') """int: |NAMI| id of this training entry""" entries_mitglied = fields.String(attribute='mitglied') """str: Who absolved the training"""
[docs]class Ausbildung(BaseModel): """ Main class for a training obtained directly from its id. This class is intended to be instantiated by calling the :meth:`~marshmallow.Schema.load` method on a corresponding data dictionary. """ _tabkeys = ['id', 'baustein', 'vstgTag'] def __repr__(self): return f'<Ausbildung({self.baustein}, Id: {self.id})>' def __str__(self): return f'{self.baustein}'
[docs]class AusbildungSchema(BaseSchema): """ Schema class for the :class:`Ausbildung` class """ __model__ = Ausbildung id = fields.Integer() """int: |NAMI| id""" baustein = fields.String() """str: Name of the training (e.g. ``'Baustein 3a'``)""" bausteinId = fields.Integer() """int: Id of the training""" mitglied = fields.String() """str: Who absolved the training""" vstgTag = fields.Date() """:class:`~datetime.date`: Day of the training event""" vstgName = fields.String() """str: Name of the event""" veranstalter = fields.String() """str: Who organized the event (e.g. a `Bezirk`)""" lastModifiedFrom = fields.String(load_only=True) """str: Who did the last change to this entry"""