# Path: template_maker/database.py
# class CRUDMixin(object):
# class Model(CRUDMixin, db.Model):
# class SurrogatePK(object):
#     def create(cls, **kwargs):
#     def update(self, commit=True, **kwargs):
#     def save(self, commit=True):
#     def delete(self, commit=True):
#     def get_by_id(cls, id):
# def ReferenceCol(tablename, nullable=False, ondelete=None, pk_name='id', **kwargs):


from template_maker.database import (
    Column,
    Model,
    db,
    ReferenceCol
)

class DocumentBase(Model):
    '''
    Metadata about a new document, relates back to
    a template
    '''

    __tablename__ = 'document_base'
    id = Column(db.Integer, primary_key=True)
    created_at = Column(db.DateTime)
    updated_at = Column(db.DateTime)
    name = Column(db.String(255))
    # published = Column(db.Boolean, default=False)
    template_id = ReferenceCol('template_base', ondelete='CASCADE')

    def __init__(self, created_at, updated_at, name, template_id):
        self.created_at = created_at
        self.updated_at = updated_at
        self.name = name
        self.template_id = template_id


# Path: template_maker/database.py
# class CRUDMixin(object):
# class Model(CRUDMixin, db.Model):
# class SurrogatePK(object):
#     def create(cls, **kwargs):
#     def update(self, commit=True, **kwargs):
#     def save(self, commit=True):
#     def delete(self, commit=True):
#     def get_by_id(cls, id):
# def ReferenceCol(tablename, nullable=False, ondelete=None, pk_name='id', **kwargs):


# Path: template_maker/generator/models.py
from template_maker.database import (
    Column,
    Model,
    db,
    ReferenceCol
)


class DocumentBase(Model):
    '''
    Metadata about a new document, relates back to
    a template
    '''

    __tablename__ = 'document_base'
    id = Column(db.Integer, primary_key=True)
    created_at = Column(db.DateTime)
    updated_at = Column(db.DateTime)
    name = Column(db.String(255))
    # published = Column(db.Boolean, default=False)
    template_id = ReferenceCol('template_base', ondelete='CASCADE')

    def __init__(self, created_at, updated_at, name, template_id):
        self.created_at = created_at
        self.updated_at = updated_at
        self.name = name
        self.template_id = template_id


class DocumentPlaceholder(Model):