# Path: models.py
# def tn(tablename):
#     def __init__(self, value):
#     def __unicode__(self):
#     def __repr__(self):
#     def __init__(self, value):
#     def __unicode__(self):
#     def __repr__(self):
#     def __init__(self, value):
#     def __unicode__(self):
#     def __repr__(self):
#     def __init__(self, username, password):
#     def __unicode__(self):
#     def __repr__(self):
#     def __init__(self, title=None, summary=None, content=None, createdate=None, pubdate=None, lastmoddate=None):
#     def compile(self, repl=None):
#     def __repr__(self):
#     def year(self):
#     def month(self):
#     def day(self):
#     def __init__(self, title=None, content=None, createdate=None, pubdate=None, lastmoddate=None):
#     def compile(self, repl=None):
#     def __repr__(self):
# class Status(Base,ImposterBase):
# class Format(Base,ImposterBase):
# class Tag(Base,ImposterBase):
# class User(Base,ImposterBase):
# class Post(Base,ImposterBase):
# class Page(Base):
# 
# Path: database.py
# class DB(object):
#     engine = None
#     db_session = None
# 
#     def __init__(self, dbstring):
#         self.engine = create_engine(dbstring, convert_unicode=True)
#         self.db_session = scoped_session(sessionmaker(autocommit=False,
#                                                  autoflush=False,
#                                                  bind=self.engine))
#         Base.query = self.db_session.query_property()
# 
#     def get_session(self):
#         return self.db_session


from flask import Flask
from migrate.versioning.api import version_control, upgrade, downgrade, db_version, version
from sqlalchemy.sql import and_
from models import User, Tag, Status, Format, Post, post_tags
from database import DB
from flaskjk import encrypt_password, slugify
from datetime import datetime
import sys
import getpass
import datamigrations
    print("Done!")


def downgrade_db(v):
    """downgrade database schema to specified version"""
    from_version = db_version(url=db, repository=repo)
    to_version = int(v)

    print("Downgrading db from version %d to %d. " % (from_version, to_version))
    print("Schema upgrade ... ")
    downgrade(url=db, repository=repo, version=v)
    print("Data upgrade ... ")
    datamigrations.run_downgrade_scripts(app, from_version, to_version)
    print("Done!")

def add_initial_data():
    """Insert initial data into the database"""
    # open database session
    db_session = DB(db).get_session()

    # ask user for an admin username and password
    username = raw_input('Please enter the admin username: ')
    password = getpass.getpass(prompt='Please enter the admin password: ')

    # add user to database
    u = User(username, encrypt_password(app.config['SECRET_KEY'], password))
    db_session.add(u)

    # create statuses
    s1 = Status('draft')

# Path: models.py
# def tn(tablename):
#     def __init__(self, value):
#     def __unicode__(self):
#     def __repr__(self):
#     def __init__(self, value):
#     def __unicode__(self):
#     def __repr__(self):
#     def __init__(self, value):
#     def __unicode__(self):
#     def __repr__(self):
#     def __init__(self, username, password):
#     def __unicode__(self):
#     def __repr__(self):
#     def __init__(self, title=None, summary=None, content=None, createdate=None, pubdate=None, lastmoddate=None):
#     def compile(self, repl=None):
#     def __repr__(self):
#     def year(self):
#     def month(self):
#     def day(self):
#     def __init__(self, title=None, content=None, createdate=None, pubdate=None, lastmoddate=None):
#     def compile(self, repl=None):
#     def __repr__(self):
# class Status(Base,ImposterBase):
# class Format(Base,ImposterBase):
# class Tag(Base,ImposterBase):
# class User(Base,ImposterBase):
# class Post(Base,ImposterBase):
# class Page(Base):
# 
# Path: database.py
# class DB(object):
#     engine = None
#     db_session = None
# 
#     def __init__(self, dbstring):
#         self.engine = create_engine(dbstring, convert_unicode=True)
#         self.db_session = scoped_session(sessionmaker(autocommit=False,
#                                                  autoflush=False,
#                                                  bind=self.engine))
#         Base.query = self.db_session.query_property()
# 
#     def get_session(self):
#         return self.db_session


# Path: dbmanage.py
from flask import Flask
from migrate.versioning.api import version_control, upgrade, downgrade, db_version, version
from sqlalchemy.sql import and_
from models import User, Tag, Status, Format, Post, post_tags
from database import DB
from flaskjk import encrypt_password, slugify
from datetime import datetime
import sys
import getpass
import datamigrations

    print("Done!")


def downgrade_db(v):
    """downgrade database schema to specified version"""
    from_version = db_version(url=db, repository=repo)
    to_version = int(v)

    print("Downgrading db from version %d to %d. " % (from_version, to_version))
    print("Schema upgrade ... ")
    downgrade(url=db, repository=repo, version=v)
    print("Data upgrade ... ")
    datamigrations.run_downgrade_scripts(app, from_version, to_version)
    print("Done!")

def add_initial_data():
    """Insert initial data into the database"""
    # open database session
    db_session = DB(db).get_session()

    # ask user for an admin username and password
    username = raw_input('Please enter the admin username: ')
    password = getpass.getpass(prompt='Please enter the admin password: ')

    # add user to database
    u = User(username, encrypt_password(app.config['SECRET_KEY'], password))
    db_session.add(u)

    # create statuses
    s1 = Status('draft')

    s2 = Status('private')