""" Model mixin classes for auth, category and recipe modules """

from app import db

# pylint: disable=C0103
# pylint: disable=E1101

class BaseMixin(object):
    """ Define the 'BaseModel' mapped to all database tables. """

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)

    def save(self):
        """Save to database table"""
        db.session.add(self)
        db.session.commit()

    def delete(self):
        """Delete from database table"""
        db.session.delete(self)
        db.session.commit()

class TimestampMixin(object):
    """ Database logging of data manipulation timestamps. """

    date_created = db.Column(db.DateTime, default=db.func.current_timestamp())
    date_modified = db.Column(db.DateTime, default=db.func.current_timestamp(), \
            onupdate=db.func.current_timestamp())

[((11, 9, 11, 68), 'app.db.Column', 'db.Column', (), '', False, 'from app import db\n'), ((15, 8, 15, 28), 'app.db.session.add', 'db.session.add', ({(15, 23, 15, 27): 'self'}, {}), '(self)', False, 'from app import db\n'), ((16, 8, 16, 27), 'app.db.session.commit', 'db.session.commit', ({}, {}), '()', False, 'from app import db\n'), ((20, 8, 20, 31), 'app.db.session.delete', 'db.session.delete', ({(20, 26, 20, 30): 'self'}, {}), '(self)', False, 'from app import db\n'), ((21, 8, 21, 27), 'app.db.session.commit', 'db.session.commit', ({}, {}), '()', False, 'from app import db\n'), ((26, 50, 26, 77), 'app.db.func.current_timestamp', 'db.func.current_timestamp', ({}, {}), '()', False, 'from app import db\n'), ((27, 51, 27, 78), 'app.db.func.current_timestamp', 'db.func.current_timestamp', ({}, {}), '()', False, 'from app import db\n'), ((28, 21, 28, 48), 'app.db.func.current_timestamp', 'db.func.current_timestamp', ({}, {}), '()', False, 'from app import db\n')]