# Path: nflpool/data/dbsession.py
# class DbSessionFactory:
#     factory = None
# 
#     # Start a database session at app startup
#     @staticmethod
#     def global_init(db_file):
#         if DbSessionFactory.factory:
#             return
# 
#         if not db_file or not db_file.strip():
#             raise Exception("You must specify a data file.")
# 
#         conn_str = "sqlite:///" + db_file
#         print("Connecting to db with conn string: {}".format(conn_str))
# 
#         engine = sqlalchemy.create_engine(conn_str, echo=False)
# 
#         SqlAlchemyBase.metadata.create_all(engine)
#         DbSessionFactory.factory = sqlalchemy.orm.sessionmaker(bind=engine)
# 
#     @staticmethod
#     def create_session():
#         return DbSessionFactory.factory()
# 
# Path: nflpool/data/account.py
# class Account(SqlAlchemyBase):
#     __tablename__ = "Account"
# 
#     id = Column(
#         String, primary_key=True, default=lambda: str(uuid.uuid4()).replace("-", "")
#     )
# 
#     email = Column(String, index=True, unique=True, nullable=False)
#     first_name = Column(String, nullable=False)
#     last_name = Column(String, nullable=False)
#     password_hash = Column(String)
#     created = Column(DateTime, default=datetime.datetime.now)
#     email_confirmed = Column(Boolean, nullable=False, default=False)
#     is_super_user = Column(Boolean, nullable=False, default=False)
#     twitter = Column(String, nullable=True)
#     paid = Column(Integer, default=0)
# 
# Path: nflpool/data/passwordreset.py
# class PasswordReset(SqlAlchemyBase):
#     __tablename__ = "PasswordReset"
# 
#     id = sqlalchemy.Column(
#         sqlalchemy.String,
#         primary_key=True,
#         default=lambda: str(uuid.uuid4()).replace("-", ""),
#     )
#     created_date = sqlalchemy.Column(sqlalchemy.DateTime, default=datetime.datetime.now)
#     used_date = sqlalchemy.Column(sqlalchemy.DateTime, nullable=True)
#     was_used = sqlalchemy.Column(sqlalchemy.Boolean, default=False)
#     used_ip_address = sqlalchemy.Column(sqlalchemy.String, nullable=True)
#     user_id = sqlalchemy.Column(sqlalchemy.String, sqlalchemy.ForeignKey("Account.id"))
# 
# Path: nflpool/data/player_picks.py
# class PlayerPicks(SqlAlchemyBase):
#     __tablename__ = "PlayerPicks"
#     pick_id = sqlalchemy.Column(
#         sqlalchemy.Integer, primary_key=True, autoincrement=True
#     )
#     user_id = sqlalchemy.Column(sqlalchemy.String, sqlalchemy.ForeignKey("Account.id"))
#     season = sqlalchemy.Column(sqlalchemy.Integer, index=True)
#     date_submitted = sqlalchemy.Column(sqlalchemy.DATETIME)
#     conf_id = sqlalchemy.Column(
#         sqlalchemy.Integer, sqlalchemy.ForeignKey("ConferenceInfo.conf_id")
#     )
#     division_id = sqlalchemy.Column(
#         sqlalchemy.Integer, sqlalchemy.ForeignKey("DivisionInfo.division_id")
#     )
#     rank = sqlalchemy.Column(sqlalchemy.Integer)
#     team_id = sqlalchemy.Column(
#         sqlalchemy.Integer, sqlalchemy.ForeignKey("TeamInfo.team_id")
#     )
#     multiplier = sqlalchemy.Column(sqlalchemy.Integer, default=1)
#     player_id = sqlalchemy.Column(
#         sqlalchemy.Integer, sqlalchemy.ForeignKey("ActiveNFLPlayers.player_id")
#     )
#     pick_type = sqlalchemy.Column(
#         sqlalchemy.Integer, sqlalchemy.ForeignKey("PickTypes.pick_type_id")
#     )


from passlib.handlers.sha2_crypt import sha512_crypt
from nflpool.data.dbsession import DbSessionFactory
from nflpool.data.account import Account
from nflpool.data.passwordreset import PasswordReset
from nflpool.data.player_picks import PlayerPicks
import datetime
import nflpool.data.secret as secret
        reset.was_used = True
        reset.used_date = datetime.datetime.now()

        session.commit()

    @classmethod
    def set_password(cls, plain_text_password, account_id):
        print("Resetting password for user {}".format(account_id))
        session = DbSessionFactory.create_session()

        account = session.query(Account).filter(Account.id == account_id).first()

        if not account:
            print("Warning: Cannot reset password, no account found.")
            return

        print("New password set.")
        account.password_hash = AccountService.hash_text(plain_text_password)
        session.commit()

    @classmethod
    def get_account_info(cls, user_id):
        session = DbSessionFactory.create_session()

        account_info = session.query(Account).filter(Account.id == user_id).all()

        return account_info

    @classmethod
    def get_account_date(cls, user_id):

# Path: nflpool/data/dbsession.py
# class DbSessionFactory:
#     factory = None
# 
#     # Start a database session at app startup
#     @staticmethod
#     def global_init(db_file):
#         if DbSessionFactory.factory:
#             return
# 
#         if not db_file or not db_file.strip():
#             raise Exception("You must specify a data file.")
# 
#         conn_str = "sqlite:///" + db_file
#         print("Connecting to db with conn string: {}".format(conn_str))
# 
#         engine = sqlalchemy.create_engine(conn_str, echo=False)
# 
#         SqlAlchemyBase.metadata.create_all(engine)
#         DbSessionFactory.factory = sqlalchemy.orm.sessionmaker(bind=engine)
# 
#     @staticmethod
#     def create_session():
#         return DbSessionFactory.factory()
# 
# Path: nflpool/data/account.py
# class Account(SqlAlchemyBase):
#     __tablename__ = "Account"
# 
#     id = Column(
#         String, primary_key=True, default=lambda: str(uuid.uuid4()).replace("-", "")
#     )
# 
#     email = Column(String, index=True, unique=True, nullable=False)
#     first_name = Column(String, nullable=False)
#     last_name = Column(String, nullable=False)
#     password_hash = Column(String)
#     created = Column(DateTime, default=datetime.datetime.now)
#     email_confirmed = Column(Boolean, nullable=False, default=False)
#     is_super_user = Column(Boolean, nullable=False, default=False)
#     twitter = Column(String, nullable=True)
#     paid = Column(Integer, default=0)
# 
# Path: nflpool/data/passwordreset.py
# class PasswordReset(SqlAlchemyBase):
#     __tablename__ = "PasswordReset"
# 
#     id = sqlalchemy.Column(
#         sqlalchemy.String,
#         primary_key=True,
#         default=lambda: str(uuid.uuid4()).replace("-", ""),
#     )
#     created_date = sqlalchemy.Column(sqlalchemy.DateTime, default=datetime.datetime.now)
#     used_date = sqlalchemy.Column(sqlalchemy.DateTime, nullable=True)
#     was_used = sqlalchemy.Column(sqlalchemy.Boolean, default=False)
#     used_ip_address = sqlalchemy.Column(sqlalchemy.String, nullable=True)
#     user_id = sqlalchemy.Column(sqlalchemy.String, sqlalchemy.ForeignKey("Account.id"))
# 
# Path: nflpool/data/player_picks.py
# class PlayerPicks(SqlAlchemyBase):
#     __tablename__ = "PlayerPicks"
#     pick_id = sqlalchemy.Column(
#         sqlalchemy.Integer, primary_key=True, autoincrement=True
#     )
#     user_id = sqlalchemy.Column(sqlalchemy.String, sqlalchemy.ForeignKey("Account.id"))
#     season = sqlalchemy.Column(sqlalchemy.Integer, index=True)
#     date_submitted = sqlalchemy.Column(sqlalchemy.DATETIME)
#     conf_id = sqlalchemy.Column(
#         sqlalchemy.Integer, sqlalchemy.ForeignKey("ConferenceInfo.conf_id")
#     )
#     division_id = sqlalchemy.Column(
#         sqlalchemy.Integer, sqlalchemy.ForeignKey("DivisionInfo.division_id")
#     )
#     rank = sqlalchemy.Column(sqlalchemy.Integer)
#     team_id = sqlalchemy.Column(
#         sqlalchemy.Integer, sqlalchemy.ForeignKey("TeamInfo.team_id")
#     )
#     multiplier = sqlalchemy.Column(sqlalchemy.Integer, default=1)
#     player_id = sqlalchemy.Column(
#         sqlalchemy.Integer, sqlalchemy.ForeignKey("ActiveNFLPlayers.player_id")
#     )
#     pick_type = sqlalchemy.Column(
#         sqlalchemy.Integer, sqlalchemy.ForeignKey("PickTypes.pick_type_id")
#     )


# Path: nflpool/services/account_service.py
from passlib.handlers.sha2_crypt import sha512_crypt
from nflpool.data.dbsession import DbSessionFactory
from nflpool.data.account import Account
from nflpool.data.passwordreset import PasswordReset
from nflpool.data.player_picks import PlayerPicks
import datetime
import nflpool.data.secret as secret

        reset.was_used = True
        reset.used_date = datetime.datetime.now()

        session.commit()

    @classmethod
    def set_password(cls, plain_text_password, account_id):
        print("Resetting password for user {}".format(account_id))
        session = DbSessionFactory.create_session()

        account = session.query(Account).filter(Account.id == account_id).first()

        if not account:
            print("Warning: Cannot reset password, no account found.")
            return

        print("New password set.")
        account.password_hash = AccountService.hash_text(plain_text_password)
        session.commit()

    @classmethod
    def get_account_info(cls, user_id):
        session = DbSessionFactory.create_session()

        account_info = session.query(Account).filter(Account.id == user_id).all()

        return account_info

    @classmethod
    def get_account_date(cls, user_id):

        session = DbSessionFactory.create_session()