# Path: recruit_app/extensions.py

# 
# Path: recruit_app/database.py
# class CRUDMixin(object):
# class Model(CRUDMixin, db.Model):
# class SurrogatePK(object):
# class TimeMixin(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=True, pk_name='id', **kwargs):


import datetime as dt
from flask_security import UserMixin, RoleMixin
from flask_security.utils import verify_and_update_password, encrypt_password
from recruit_app.extensions import bcrypt
from recruit_app.database import Column, db, Model, ReferenceCol, relationship, SurrogatePK, TimeMixin

    @property
    def get_ips(self):
        return self.last_login_ip.split(', ') + self.current_login_ip.split(', ')

    def __repr__(self):
        return '<User({name})>'.format(name=self.email)

    def __str__(self):
        return self.email

previous_chars = db.Table('previous_chars',
    db.Column('user_id', db.Integer(), db.ForeignKey('users.id')),
    db.Column('character_id', db.String(254), db.ForeignKey('characters.character_id')))

class EveCharacter(Model, TimeMixin):
    __tablename__ = 'characters'

    character_id = Column(db.String(254), primary_key=True)
    character_name = Column(db.String(254))
    corporation_id = ReferenceCol('corporations', pk_name='corporation_id', nullable=True)
    corporation = relationship('EveCorporationInfo', backref='characters', foreign_keys=[corporation_id])

    api_id = ReferenceCol('api_key_pairs', pk_name='api_id', nullable=True)
    api = relationship('EveApiKeyPair', backref='characters', foreign_keys=[api_id])

    user_id = ReferenceCol('users', nullable=True)
    user = relationship('User', backref='characters', foreign_keys=[user_id])

    skillpoints = Column(db.Integer, nullable=True)

# Path: recruit_app/extensions.py

# 
# Path: recruit_app/database.py
# class CRUDMixin(object):
# class Model(CRUDMixin, db.Model):
# class SurrogatePK(object):
# class TimeMixin(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=True, pk_name='id', **kwargs):


# Path: recruit_app/user/models.py
import datetime as dt
from flask_security import UserMixin, RoleMixin
from flask_security.utils import verify_and_update_password, encrypt_password
from recruit_app.extensions import bcrypt
from recruit_app.database import Column, db, Model, ReferenceCol, relationship, SurrogatePK, TimeMixin


    @property
    def get_ips(self):
        return self.last_login_ip.split(', ') + self.current_login_ip.split(', ')

    def __repr__(self):
        return '<User({name})>'.format(name=self.email)

    def __str__(self):
        return self.email

previous_chars = db.Table('previous_chars',
    db.Column('user_id', db.Integer(), db.ForeignKey('users.id')),
    db.Column('character_id', db.String(254), db.ForeignKey('characters.character_id')))

class EveCharacter(Model, TimeMixin):
    __tablename__ = 'characters'

    character_id = Column(db.String(254), primary_key=True)
    character_name = Column(db.String(254))
    corporation_id = ReferenceCol('corporations', pk_name='corporation_id', nullable=True)
    corporation = relationship('EveCorporationInfo', backref='characters', foreign_keys=[corporation_id])

    api_id = ReferenceCol('api_key_pairs', pk_name='api_id', nullable=True)
    api = relationship('EveApiKeyPair', backref='characters', foreign_keys=[api_id])

    user_id = ReferenceCol('users', nullable=True)
    user = relationship('User', backref='characters', foreign_keys=[user_id])

    skillpoints = Column(db.Integer, nullable=True)

    previous_users = db.relationship('User', secondary=previous_chars, backref=db.backref('previous_chars', lazy='dynamic'), lazy='dynamic')