# Path: recruit_app/user/models.py
# class User(SurrogatePK, Model, UserMixin):
#     __tablename__ = 'users'
# 
#     email = Column(db.String(80), unique=True, nullable=False)
#     #: The hashed password
#     password = Column(db.String(128), nullable=True)
#     created_at = Column(db.DateTime, nullable=False, default=dt.datetime.utcnow)
#     active = Column(db.Boolean(), default=False)
#     is_admin = Column(db.Boolean(), default=False)
# 
#     confirmed_at = Column(db.DateTime, nullable=True)
# 
#     last_login_at = Column(db.DateTime())
#     current_login_at = Column(db.DateTime())
#     last_login_ip = Column(db.String(100))
#     current_login_ip = Column(db.String(100))
#     login_count = Column(db.Integer)
# 
#     roles = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic'), lazy='dynamic')
# 
#     main_character_id = ReferenceCol('characters', pk_name='character_id', nullable=True)
#     main_character = relationship('EveCharacter', backref='user_main_character', foreign_keys=[main_character_id])
# 
#     def set_password(self, password):
#         self.password = encrypt_password(password)
#         self.save()
# 
#     def check_password(self, value):
#         return verify_and_update_password(value, self)
# 
#     @classmethod
#     def create(self, **kwargs):
#         """Create a new record and save it the database."""
#         instance = self(**kwargs)
#         if kwargs['password']:
#             instance.password = encrypt_password(kwargs['password'])
#         return instance.save()
# 
#     @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
# 
# class Role(SurrogatePK, Model, RoleMixin):
#     __tablename__ = 'roles'
#     name = Column(db.String(80), unique=True)
#     description = db.Column(db.String(255))
# 
#     def __repr__(self):
#         return '<Role({name})>'.format(name=self.name)


from flask_bcrypt import Bcrypt
from flask_cache import Cache
from flask_sqlalchemy import SQLAlchemy
from flask_security import Security, SQLAlchemyUserDatastore
from recruit_app.user.models import User, Role
from flask_migrate import Migrate
from raven.contrib.flask import Sentry
from flask_debugtoolbar import DebugToolbarExtension
from flask_bootstrap import Bootstrap
from flask_mail import Mail
from flask_rq import RQ
from flask_misaka import Misaka
# -*- coding: utf-8 -*-
"""Extensions module. Each extension is initialized in the app factory located
in app.py
"""

bcrypt = Bcrypt()

# from flask_login import LoginManager
# login_manager = LoginManager()

cache_extension = Cache()

db = SQLAlchemy()

security = Security()

# Path: recruit_app/user/models.py
# class User(SurrogatePK, Model, UserMixin):
#     __tablename__ = 'users'
# 
#     email = Column(db.String(80), unique=True, nullable=False)
#     #: The hashed password
#     password = Column(db.String(128), nullable=True)
#     created_at = Column(db.DateTime, nullable=False, default=dt.datetime.utcnow)
#     active = Column(db.Boolean(), default=False)
#     is_admin = Column(db.Boolean(), default=False)
# 
#     confirmed_at = Column(db.DateTime, nullable=True)
# 
#     last_login_at = Column(db.DateTime())
#     current_login_at = Column(db.DateTime())
#     last_login_ip = Column(db.String(100))
#     current_login_ip = Column(db.String(100))
#     login_count = Column(db.Integer)
# 
#     roles = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic'), lazy='dynamic')
# 
#     main_character_id = ReferenceCol('characters', pk_name='character_id', nullable=True)
#     main_character = relationship('EveCharacter', backref='user_main_character', foreign_keys=[main_character_id])
# 
#     def set_password(self, password):
#         self.password = encrypt_password(password)
#         self.save()
# 
#     def check_password(self, value):
#         return verify_and_update_password(value, self)
# 
#     @classmethod
#     def create(self, **kwargs):
#         """Create a new record and save it the database."""
#         instance = self(**kwargs)
#         if kwargs['password']:
#             instance.password = encrypt_password(kwargs['password'])
#         return instance.save()
# 
#     @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
# 
# class Role(SurrogatePK, Model, RoleMixin):
#     __tablename__ = 'roles'
#     name = Column(db.String(80), unique=True)
#     description = db.Column(db.String(255))
# 
#     def __repr__(self):
#         return '<Role({name})>'.format(name=self.name)


# Path: recruit_app/extensions.py
from flask_bcrypt import Bcrypt
from flask_cache import Cache
from flask_sqlalchemy import SQLAlchemy
from flask_security import Security, SQLAlchemyUserDatastore
from recruit_app.user.models import User, Role
from flask_migrate import Migrate
from raven.contrib.flask import Sentry
from flask_debugtoolbar import DebugToolbarExtension
from flask_bootstrap import Bootstrap
from flask_mail import Mail
from flask_rq import RQ
from flask_misaka import Misaka

# -*- coding: utf-8 -*-
"""Extensions module. Each extension is initialized in the app factory located
in app.py
"""

bcrypt = Bcrypt()

# from flask_login import LoginManager
# login_manager = LoginManager()

cache_extension = Cache()

db = SQLAlchemy()

security = Security()

user_datastore = SQLAlchemyUserDatastore(db, User, Role)