""" 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())

[((237, 296), 'app.db.Column', 'db.Column', (['db.Integer'], {'primary_key': '(True)', 'autoincrement': '(True)'}), '(db.Integer, primary_key=True, autoincrement=True)\n', (246, 296), False, 'from app import db\n'), ((363, 383), 'app.db.session.add', 'db.session.add', (['self'], {}), '(self)\n', (377, 383), False, 'from app import db\n'), ((392, 411), 'app.db.session.commit', 'db.session.commit', ([], {}), '()\n', (409, 411), False, 'from app import db\n'), ((484, 507), 'app.db.session.delete', 'db.session.delete', (['self'], {}), '(self)\n', (501, 507), False, 'from app import db\n'), ((516, 535), 'app.db.session.commit', 'db.session.commit', ([], {}), '()\n', (533, 535), False, 'from app import db\n'), ((680, 707), 'app.db.func.current_timestamp', 'db.func.current_timestamp', ([], {}), '()\n', (705, 707), False, 'from app import db\n'), ((760, 787), 'app.db.func.current_timestamp', 'db.func.current_timestamp', ([], {}), '()\n', (785, 787), False, 'from app import db\n'), ((812, 839), 'app.db.func.current_timestamp', 'db.func.current_timestamp', ([], {}), '()\n', (837, 839), False, 'from app import db\n')]