Source code for translator_directory.models.certificate

from uuid import uuid4

from sqlalchemy import Column, Text, Table, ForeignKey
from sqlalchemy.orm import relationship

from onegov.core.orm import Base
from onegov.core.orm.mixins import TimestampMixin
from onegov.core.orm.types import UUID


from typing import TYPE_CHECKING
if TYPE_CHECKING:
    import uuid

    from onegov.translator_directory.models.translator import Translator


[docs] certificate_association_table = Table( 'certifcate_association', Base.metadata, Column( 'translator_id', UUID, ForeignKey('translators.id'), nullable=False), Column('cert_id', UUID, ForeignKey('language_certificates.id'), nullable=False) )
[docs] class LanguageCertificate(Base, TimestampMixin):
[docs] __tablename__ = 'language_certificates'
[docs] id: 'Column[uuid.UUID]' = Column( UUID, # type:ignore[arg-type] primary_key=True, default=uuid4 )
[docs] name: 'Column[str]' = Column(Text, nullable=False)
[docs] owners: 'relationship[list[Translator]]' = relationship( 'Translator', secondary=certificate_association_table, back_populates='certificates')