~homeworkprod/byceps

ref: 4237b3ec9496efe95dcce82bea3207ab9de4d520 byceps/byceps/services/consent/models/consent.py -rw-r--r-- 999 bytes
4237b3ec — Jochen Kupperschmidt Move ticketing blueprint into `site` subpackage 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
byceps.services.consent.models.consent
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2020 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from datetime import datetime

from ....database import db
from ....typing import UserID

from ...user.models.user import User

from ..transfer.models import SubjectID

from .subject import Subject


class Consent(db.Model):
    """A user's consent to a subject."""

    __tablename__ = 'consents'

    user_id = db.Column(db.Uuid, db.ForeignKey('users.id'), primary_key=True)
    user = db.relationship(User)
    subject_id = db.Column(db.Uuid, db.ForeignKey('consent_subjects.id'), primary_key=True)
    subject = db.relationship(Subject)
    expressed_at = db.Column(db.DateTime, nullable=False)

    def __init__(
        self, user_id: UserID, subject_id: SubjectID, expressed_at: datetime
    ) -> None:
        self.user_id = user_id
        self.subject_id = subject_id
        self.expressed_at = expressed_at