<commit_before>"""ToU (Terms of Use)  module"""
from sqlalchemy.dialects.postgresql import ENUM

from ..database import db
from ..date_tools import FHIR_datetime

tou_types = ENUM('website terms of use', 'subject website consent',
                 'stored website consent form', 'privacy policy',
                 name='tou_types', create_type=False)


class ToU(db.Model):
    """SQLAlchemy class for `tou` table"""
    __tablename__ = 'tou'
    id = db.Column(db.Integer(), primary_key=True)
    agreement_url = db.Column(db.Text,
                              server_default='predates agreement_url',
                              nullable=False)
    audit_id = db.Column(db.ForeignKey('audit.id'), nullable=False)
    organization_id = db.Column(db.ForeignKey('organizations.id'))
    type = db.Column('type', tou_types, nullable=False)

    audit = db.relationship('Audit', cascade="save-update", lazy='joined')
    """tracks when and by whom the terms were agreed to"""

    def __str__(self):
        return "ToU ({0.audit}) {0.agreement_url}".format(self)

    def as_json(self):
        d = {}
        d['id'] = self.id
        d['agreement_url'] = self.agreement_url
        d['accepted'] = FHIR_datetime.as_fhir(self.audit.timestamp)
        d['type'] = self.type
        if self.organization_id:
            d['organization_id'] = self.organization_id
        return d<commit_msg>adding active column to ToU agreement object<commit_after>"""ToU (Terms of Use)  module"""
from sqlalchemy.dialects.postgresql import ENUM

from ..database import db
from ..date_tools import FHIR_datetime

tou_types = ENUM('website terms of use', 'subject website consent',
                 'stored website consent form', 'privacy policy',
                 name='tou_types', create_type=False)


class ToU(db.Model):
    """SQLAlchemy class for `tou` table"""
    __tablename__ = 'tou'
    id = db.Column(db.Integer(), primary_key=True)
    agreement_url = db.Column(db.Text,
                              server_default='predates agreement_url',
                              nullable=False)
    audit_id = db.Column(db.ForeignKey('audit.id'), nullable=False)
    organization_id = db.Column(db.ForeignKey('organizations.id'))
    type = db.Column('type', tou_types, nullable=False)
    active = db.Column(db.Boolean(), nullable=False, server_default='1')

    audit = db.relationship('Audit', cascade="save-update", lazy='joined')
    """tracks when and by whom the terms were agreed to"""

    def __str__(self):
        return "ToU ({0.audit}) {0.agreement_url}".format(self)

    def as_json(self):
        d = {}
        d['id'] = self.id
        d['agreement_url'] = self.agreement_url
        d['accepted'] = FHIR_datetime.as_fhir(self.audit.timestamp)
        d['type'] = self.type
        if self.organization_id:
            d['organization_id'] = self.organization_id
        d['active'] = self.active
        return d
{'fraction_non_alphanumeric': 0.13107460643394936, 'fraction_numerical': 0.0017111567419575632, 'mean_word_length': 2.8664021164021163, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5133001', 'n_tokens_mistral': 929, 'n_tokens_neox': 892, 'n_words': 203}