# Path: plugin.py
# class Plugin:
#     def __init__(self):
#         self.documents = Documents(self)
#         try: self.name
#         except: self.name = self.__class__.__name__.lower()
#         try: self.description
#         except: self.description = 'This plugin has no description.'
#         if self.__class__ is Plugin:
#             raise NotImplementedError
# 
#     @property
#     def user(self):
#         return app.current_user
# 
#     def process(self, request):
#         pass
# 
#     def unload(self):
#         pass
# 
# Path: database.py
# def get_session():
# def teardown_session(exception):
# 
# Path: database.py
# def get_session():
# def teardown_session(exception):
# 
# Path: models/user.py
# class User(TableBase, UserMixin):
#     """A user."""
# 
#     __tablename__ = 'user'
#     id = Column(Integer, primary_key=True)
#     email = Column(String(63), unique=True)
#     passwordhash = Column(String(127), nullable=False)
#     salt = Column(String(127), nullable=False)
#     username = Column(String(127))
#     if os.getenv('FLASK_TESTING'):
#         avatar = Column(String(16777215))
#     else:
#         avatar = Column(MEDIUMTEXT())
#     description = Column(Text())
#     education = Column(Text())
#     major = Column(Text())
# 
#     def __init__(self, email, password, username):
#         self.email = email
#         self.set_password(password)
#         self.username = username
# 
#     def set_password(self, password):
#         """hash and save the password"""
#         self.salt = random_string(10)
#         s = hashlib.sha256()
#         s.update(password.encode('utf-8'))
#         s.update(self.salt.encode('utf-8'))
#         self.passwordhash = s.hexdigest()
# 
#     def check_password(self, password):
#         """hash and check the password"""
#         s = hashlib.sha256()
#         s.update(password.encode('utf-8'))
#         s.update(self.salt.encode('utf-8'))
#         return self.passwordhash == s.hexdigest()
# 
#     @classmethod
#     def get_user_by_email(cls, email):
#         return session.query(cls).filter_by(email=email).first()
# 
#     @classmethod
#     def get_user_by_id(cls, id):
#         return session.query(cls).get(id)
# 
# Path: plugins/pano.py
# class PanoDocument(TableBase, PluginDocument):
# class Pano(Plugin):
#     def __init__(self, owner, title='Untitled', text=''):
#     def __init__(self):
#     def process(self, request):
#     def new(self, title, data, public, img, **kwargs):
#     def save(self, id, title, data, img, **kwargs):
#     def list(self, **kwargs):
#     def load(self, id, **kwargs):
#     def delete(self, id, **kwargs):
#     def get_event_data(self, **kwargs):
#     def submit_comment(self, comment, event_id, **kwargs):
#     def submit_praise(self, modify, event_id, **kwargs):
#     def get_project_data(self, **kwargs):
#     def match_node(self, s, **kwargs):


from plugin import Plugin
from database import TableBase, Column, Text
from database import engine, session
from flask_login import current_user, login_required, login_user, logout_user
from models import User
from plugins.pano import __plugin__ as pano
            login_user(user)
            # XXX: Hypercube: give user a pano for a easy begin
            welcome = '''{"nodes":[
                {"id":0,"tax_id":"","gene_id":"","name":"","info":"","title":"How To Use BioHub?","x":200,"y":-700},
                {"id":1,"tax_id":"","gene_id":"","name":"","info":"","title":"Check the detail on left","x":200,"y":-550},
                {"id":2,"tax_id":"","gene_id":"","name":"","info":"","title":"Click PREVIOUS or NEXT","x":200,"y":-400},
                {"id":3,"tax_id":"","gene_id":"","name":"","info":"","title":"Hold SHIFT to link","x":200,"y":-250},
                {"id":4,"tax_id":"","gene_id":"","name":"","info":"","title":"link source","x":350,"y":-250},
                {"id":5,"tax_id":"","gene_id":"","name":"","info":"","title":"link target","x":650,"y":-250},
                {"id":6,"tax_id":"","gene_id":"","name":"","info":"","title":"Try PATH-FINDER!","x":200,"y":-100},
                {"id":7,"tax_id":"562","gene_id":"1238710","name":"tnsA","info":"Tn7 transposase A","title":"path source","x":350,"y":50},
                {"id":8,"tax_id":"562","gene_id":"5961992","name":"bla","info":"beta-lactamase TEM precursor","title":"path target","x":650,"y":50},
                {"id":9,"tax_id":"","gene_id":"","name":"","info":"","title":"Try SMART-MAP!","x":200,"y":200},
                {"id":10,"tax_id":"","gene_id":"","name":"","info":"","title":"This is tnsA","x":425,"y":-25},
                {"id":11,"tax_id":"","gene_id":"","name":"","info":"","title":"This is bla","x":575,"y":-25},
                {"id":12,"tax_id":"","gene_id":"","name":"","info":"","title":"First choose this","x":350,"y":-100},
                {"id":13,"tax_id":"","gene_id":"","name":"","info":"","title":"Then click PATH-FINDER","x":500,"y":-100},
                {"id":14,"tax_id":"","gene_id":"","name":"","info":"","title":"Finally click this","x":650,"y":-100}
                ],"edges":[
                {"source":4,"target":5},
                {"source":3,"target":6},
                {"source":2,"target":3},
                {"source":6,"target":9},
                {"source":10,"target":7},
                {"source":11,"target":8},
                {"source":0,"target":1},
                {"source":1,"target":2},
                {"source":12,"target":7},
                {"source":14,"target":8}
                ]}'''

# Path: plugin.py
# class Plugin:
#     def __init__(self):
#         self.documents = Documents(self)
#         try: self.name
#         except: self.name = self.__class__.__name__.lower()
#         try: self.description
#         except: self.description = 'This plugin has no description.'
#         if self.__class__ is Plugin:
#             raise NotImplementedError
# 
#     @property
#     def user(self):
#         return app.current_user
# 
#     def process(self, request):
#         pass
# 
#     def unload(self):
#         pass
# 
# Path: database.py
# def get_session():
# def teardown_session(exception):
# 
# Path: database.py
# def get_session():
# def teardown_session(exception):
# 
# Path: models/user.py
# class User(TableBase, UserMixin):
#     """A user."""
# 
#     __tablename__ = 'user'
#     id = Column(Integer, primary_key=True)
#     email = Column(String(63), unique=True)
#     passwordhash = Column(String(127), nullable=False)
#     salt = Column(String(127), nullable=False)
#     username = Column(String(127))
#     if os.getenv('FLASK_TESTING'):
#         avatar = Column(String(16777215))
#     else:
#         avatar = Column(MEDIUMTEXT())
#     description = Column(Text())
#     education = Column(Text())
#     major = Column(Text())
# 
#     def __init__(self, email, password, username):
#         self.email = email
#         self.set_password(password)
#         self.username = username
# 
#     def set_password(self, password):
#         """hash and save the password"""
#         self.salt = random_string(10)
#         s = hashlib.sha256()
#         s.update(password.encode('utf-8'))
#         s.update(self.salt.encode('utf-8'))
#         self.passwordhash = s.hexdigest()
# 
#     def check_password(self, password):
#         """hash and check the password"""
#         s = hashlib.sha256()
#         s.update(password.encode('utf-8'))
#         s.update(self.salt.encode('utf-8'))
#         return self.passwordhash == s.hexdigest()
# 
#     @classmethod
#     def get_user_by_email(cls, email):
#         return session.query(cls).filter_by(email=email).first()
# 
#     @classmethod
#     def get_user_by_id(cls, id):
#         return session.query(cls).get(id)
# 
# Path: plugins/pano.py
# class PanoDocument(TableBase, PluginDocument):
# class Pano(Plugin):
#     def __init__(self, owner, title='Untitled', text=''):
#     def __init__(self):
#     def process(self, request):
#     def new(self, title, data, public, img, **kwargs):
#     def save(self, id, title, data, img, **kwargs):
#     def list(self, **kwargs):
#     def load(self, id, **kwargs):
#     def delete(self, id, **kwargs):
#     def get_event_data(self, **kwargs):
#     def submit_comment(self, comment, event_id, **kwargs):
#     def submit_praise(self, modify, event_id, **kwargs):
#     def get_project_data(self, **kwargs):
#     def match_node(self, s, **kwargs):


# Path: plugins/user_model.py
from plugin import Plugin
from database import TableBase, Column, Text
from database import engine, session
from flask_login import current_user, login_required, login_user, logout_user
from models import User
from plugins.pano import __plugin__ as pano

            login_user(user)
            # XXX: Hypercube: give user a pano for a easy begin
            welcome = '''{"nodes":[
                {"id":0,"tax_id":"","gene_id":"","name":"","info":"","title":"How To Use BioHub?","x":200,"y":-700},
                {"id":1,"tax_id":"","gene_id":"","name":"","info":"","title":"Check the detail on left","x":200,"y":-550},
                {"id":2,"tax_id":"","gene_id":"","name":"","info":"","title":"Click PREVIOUS or NEXT","x":200,"y":-400},
                {"id":3,"tax_id":"","gene_id":"","name":"","info":"","title":"Hold SHIFT to link","x":200,"y":-250},
                {"id":4,"tax_id":"","gene_id":"","name":"","info":"","title":"link source","x":350,"y":-250},
                {"id":5,"tax_id":"","gene_id":"","name":"","info":"","title":"link target","x":650,"y":-250},
                {"id":6,"tax_id":"","gene_id":"","name":"","info":"","title":"Try PATH-FINDER!","x":200,"y":-100},
                {"id":7,"tax_id":"562","gene_id":"1238710","name":"tnsA","info":"Tn7 transposase A","title":"path source","x":350,"y":50},
                {"id":8,"tax_id":"562","gene_id":"5961992","name":"bla","info":"beta-lactamase TEM precursor","title":"path target","x":650,"y":50},
                {"id":9,"tax_id":"","gene_id":"","name":"","info":"","title":"Try SMART-MAP!","x":200,"y":200},
                {"id":10,"tax_id":"","gene_id":"","name":"","info":"","title":"This is tnsA","x":425,"y":-25},
                {"id":11,"tax_id":"","gene_id":"","name":"","info":"","title":"This is bla","x":575,"y":-25},
                {"id":12,"tax_id":"","gene_id":"","name":"","info":"","title":"First choose this","x":350,"y":-100},
                {"id":13,"tax_id":"","gene_id":"","name":"","info":"","title":"Then click PATH-FINDER","x":500,"y":-100},
                {"id":14,"tax_id":"","gene_id":"","name":"","info":"","title":"Finally click this","x":650,"y":-100}
                ],"edges":[
                {"source":4,"target":5},
                {"source":3,"target":6},
                {"source":2,"target":3},
                {"source":6,"target":9},
                {"source":10,"target":7},
                {"source":11,"target":8},
                {"source":0,"target":1},
                {"source":1,"target":2},
                {"source":12,"target":7},
                {"source":14,"target":8}
                ]}'''

            pano.new('Welcome to BioHub', welcome, 'false', '', user=user.id)