Skip to content
Snippets Groups Projects
Select Git revision
  • 2cb54618e649a64f622282cf8122388705f343c2
  • develop default
  • master protected
  • feature/frontend-tests
  • 0.99
  • 0.98
  • 0.97
  • 0.96
  • 0.95
  • 0.94
  • 0.93
  • 0.92
  • 0.91
  • 0.90
  • 0.89
  • 0.88
  • 0.87
  • 0.86
  • 0.85
  • 0.84
  • 0.83
  • 0.82
  • 0.81
  • 0.80
24 results

survey_model.py

Blame
  • Remco Tukker's avatar
    Remco Tukker authored
    02268529
    History
    survey_model.py 1.24 KiB
    import logging
    
    from typing import Dict, Any
    from typing_extensions import Annotated
    
    from sqlalchemy.orm import Mapped, mapped_column, relationship
    from sqlalchemy.schema import ForeignKey
    from sqlalchemy.types import JSON
    
    
    from compendium_v2.db import db
    from compendium_v2.db.model import NREN
    
    
    logger = logging.getLogger(__name__)
    
    
    int_pk = Annotated[int, mapped_column(primary_key=True)]
    int_pk_fkNREN = Annotated[int, mapped_column(ForeignKey("nren.id"), primary_key=True)]
    int_pk_fkSurvey = Annotated[int, mapped_column(ForeignKey("survey.year"), primary_key=True)]
    json = Annotated[Dict[str, Any], mapped_column(JSON)]
    
    
    # Unfortunately flask-sqlalchemy doesnt fully support DeclarativeBase yet.
    # See https://github.com/pallets-eco/flask-sqlalchemy/issues/1140
    # mypy: disable-error-code="name-defined"
    
    class Survey(db.Model):
        __tablename__ = 'survey'
        year: Mapped[int_pk]
        survey: Mapped[json]
        # status column?
    
    
    class SurveyResponse(db.Model):
        __tablename__ = 'survey_response'
        nren_id: Mapped[int_pk_fkNREN]
        nren: Mapped[NREN] = relationship(lazy='joined')
        survey_year: Mapped[int_pk_fkSurvey]
        survey: Mapped[Survey] = relationship(lazy='joined')
        answers: Mapped[json]
        # completed column?? I think we need that..