# Path: recruit_app/user/models.py
# class Role(SurrogatePK, Model, RoleMixin):
# class User(SurrogatePK, Model, UserMixin):
# class EveCharacter(Model, TimeMixin):
# class EveApiKeyPair(Model):
# class EveAllianceInfo(Model):
# class EveCorporationInfo(Model):
#     def __repr__(self):
#     def set_password(self, password):
#     def check_password(self, value):
#     def create(self, **kwargs):
#     def get_ips(self):
#     def __repr__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
# 
# Path: recruit_app/admin.py
# class AuthenticatedModelView(ModelView):
#     column_display_pk = True
# 
#     def is_accessible(self):
#         if current_user.has_role("admin"):
#             return True
#         return False
# 
#     def _handle_view(self, name, **kwargs):
#         if not self.is_accessible():
#             abort(401)
# 
# Path: recruit_app/recruit/models.py
# class HrApplication(SurrogatePK, TimeMixin, Model):
#     # query_class = HrApplicationQuery
#     __tablename__ = 'hr_applications'
# 
#     __searchable__ = ['thesis',
#                       'how_long',
#                       'notable_accomplishments',
#                       'corporation_history',
#                       'why_leaving',
#                       'what_know',
#                       'what_expect',
#                       'bought_characters',
#                       'why_interested',
#                       'find_out',
#                       'favorite_role',
#                       'main_character_name']
# 
#     main_character_name = Column(db.Unicode, nullable=True)
# 
#     alt_application = Column(db.Boolean, default=False)
# 
#     characters = relationship('EveCharacter', secondary=character_apps, backref=db.backref('hr_applications', lazy='dynamic'), lazy='dynamic')
# 
#     thesis = Column(db.UnicodeText, nullable=True)
#     how_long = Column(db.Text, nullable=True)
#     notable_accomplishments = Column(db.Text, nullable=True)
#     corporation_history = Column(db.Text, nullable=True)
#     why_leaving = Column(db.Text, nullable=True)
#     what_know = Column(db.Text, nullable=True)
#     what_expect = Column(db.Text, nullable=True)
#     bought_characters = Column(db.Text, nullable=True)
#     why_interested = Column(db.Text, nullable=True)
# 
#     goon_interaction = Column(db.Text, nullable=True)
#     friends = Column(db.Text, nullable=True)
# 
#     scale = Column(db.Text, nullable=True)
# 
#     find_out = Column(db.Text, nullable=True)
# 
#     favorite_role = Column(db.Text, nullable=True)
# 
#     user_id = ReferenceCol('users', nullable=True)
#     reviewer_user_id = ReferenceCol('users', nullable=True)
#     last_user_id = ReferenceCol('users', nullable=True)
# 
#     approved_denied = Column(db.Text, default="New")
# 
#     hidden = Column(db.Boolean, nullable=True, default=False)
# 
#     # search_vector = Column(TSVectorType('main_character_name', 'thesis'))
# 
#     user = relationship('User', foreign_keys=[user_id], backref='hr_applications')
#     reviewer_user = relationship('User', foreign_keys=[reviewer_user_id], backref='hr_applications_reviewed')
#     last_action_user = relationship('User', foreign_keys=[last_user_id], backref='hr_applications_touched')
#     
#     training = Column(db.Boolean, default=False)
# 
#     def __str__(self):
#         return '<Application %r>' % str(self.main_character_name)
# 
# class HrApplicationComment(SurrogatePK, TimeMixin, Model):
#     __tablename__ = 'hr_comments'
# 
#     comment = Column(db.Text, nullable=True)
# 
#     application_id = ReferenceCol('hr_applications')
#     user_id = ReferenceCol('users')
#     application = relationship('HrApplication', foreign_keys=[application_id], backref=backref('hr_comments', cascade="delete"))
#     user = relationship('User', backref='hr_comments', foreign_keys=[user_id])
# 
#     def __repr__(self):
#         return str(self.user) + " - Comment"
# 
# Path: recruit_app/blacklist/models.py
# class BlacklistCharacter(SurrogatePK, TimeMixin, Model):
#     __tablename__ = 'blacklist_character'
#     # __searchable__ = ['name', 'main_name', 'corporation', 'alliance', 'notes', 'ip_address']
# 
#     name = Column(db.Unicode, nullable=True)
#     main_name = Column(db.Unicode, nullable=True)
#     corporation = Column(db.Unicode)
#     alliance = Column(db.Unicode)
#     notes = Column(db.Unicode)
# 
#     ip_address = Column(db.Unicode)
# 
#     creator_id = ReferenceCol('users', nullable=True)
#     creator = relationship('User', foreign_keys=[creator_id], backref='blacklist_character_entries')
# 
#     def __repr__(self):
#         return '<' + self.name + ': ' + self.notes + '>'


from .models import EveCharacter, EveAllianceInfo, EveApiKeyPair, EveCorporationInfo, User, Role, roles_users
from flask_security import current_user
from recruit_app.admin import AuthenticatedModelView
from wtforms import PasswordField
from recruit_app.recruit.models import HrApplication, HrApplicationComment
from recruit_app.blacklist.models import BlacklistCharacter
from flask import url_for
from flask.ext.admin.menu import MenuLink

def register_admin_views(admin, db):
    admin.add_link(MenuLink(name='Go Back', url='/', category=''))
    admin.add_view(EveCharacterAdmin(EveCharacter, db.session, category='EvE'))
    admin.add_view(EveCorporationInfoAdmin(EveCorporationInfo, db.session, category='EvE'))

# Path: recruit_app/user/models.py
# class Role(SurrogatePK, Model, RoleMixin):
# class User(SurrogatePK, Model, UserMixin):
# class EveCharacter(Model, TimeMixin):
# class EveApiKeyPair(Model):
# class EveAllianceInfo(Model):
# class EveCorporationInfo(Model):
#     def __repr__(self):
#     def set_password(self, password):
#     def check_password(self, value):
#     def create(self, **kwargs):
#     def get_ips(self):
#     def __repr__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
# 
# Path: recruit_app/admin.py
# class AuthenticatedModelView(ModelView):
#     column_display_pk = True
# 
#     def is_accessible(self):
#         if current_user.has_role("admin"):
#             return True
#         return False
# 
#     def _handle_view(self, name, **kwargs):
#         if not self.is_accessible():
#             abort(401)
# 
# Path: recruit_app/recruit/models.py
# class HrApplication(SurrogatePK, TimeMixin, Model):
#     # query_class = HrApplicationQuery
#     __tablename__ = 'hr_applications'
# 
#     __searchable__ = ['thesis',
#                       'how_long',
#                       'notable_accomplishments',
#                       'corporation_history',
#                       'why_leaving',
#                       'what_know',
#                       'what_expect',
#                       'bought_characters',
#                       'why_interested',
#                       'find_out',
#                       'favorite_role',
#                       'main_character_name']
# 
#     main_character_name = Column(db.Unicode, nullable=True)
# 
#     alt_application = Column(db.Boolean, default=False)
# 
#     characters = relationship('EveCharacter', secondary=character_apps, backref=db.backref('hr_applications', lazy='dynamic'), lazy='dynamic')
# 
#     thesis = Column(db.UnicodeText, nullable=True)
#     how_long = Column(db.Text, nullable=True)
#     notable_accomplishments = Column(db.Text, nullable=True)
#     corporation_history = Column(db.Text, nullable=True)
#     why_leaving = Column(db.Text, nullable=True)
#     what_know = Column(db.Text, nullable=True)
#     what_expect = Column(db.Text, nullable=True)
#     bought_characters = Column(db.Text, nullable=True)
#     why_interested = Column(db.Text, nullable=True)
# 
#     goon_interaction = Column(db.Text, nullable=True)
#     friends = Column(db.Text, nullable=True)
# 
#     scale = Column(db.Text, nullable=True)
# 
#     find_out = Column(db.Text, nullable=True)
# 
#     favorite_role = Column(db.Text, nullable=True)
# 
#     user_id = ReferenceCol('users', nullable=True)
#     reviewer_user_id = ReferenceCol('users', nullable=True)
#     last_user_id = ReferenceCol('users', nullable=True)
# 
#     approved_denied = Column(db.Text, default="New")
# 
#     hidden = Column(db.Boolean, nullable=True, default=False)
# 
#     # search_vector = Column(TSVectorType('main_character_name', 'thesis'))
# 
#     user = relationship('User', foreign_keys=[user_id], backref='hr_applications')
#     reviewer_user = relationship('User', foreign_keys=[reviewer_user_id], backref='hr_applications_reviewed')
#     last_action_user = relationship('User', foreign_keys=[last_user_id], backref='hr_applications_touched')
#     
#     training = Column(db.Boolean, default=False)
# 
#     def __str__(self):
#         return '<Application %r>' % str(self.main_character_name)
# 
# class HrApplicationComment(SurrogatePK, TimeMixin, Model):
#     __tablename__ = 'hr_comments'
# 
#     comment = Column(db.Text, nullable=True)
# 
#     application_id = ReferenceCol('hr_applications')
#     user_id = ReferenceCol('users')
#     application = relationship('HrApplication', foreign_keys=[application_id], backref=backref('hr_comments', cascade="delete"))
#     user = relationship('User', backref='hr_comments', foreign_keys=[user_id])
# 
#     def __repr__(self):
#         return str(self.user) + " - Comment"
# 
# Path: recruit_app/blacklist/models.py
# class BlacklistCharacter(SurrogatePK, TimeMixin, Model):
#     __tablename__ = 'blacklist_character'
#     # __searchable__ = ['name', 'main_name', 'corporation', 'alliance', 'notes', 'ip_address']
# 
#     name = Column(db.Unicode, nullable=True)
#     main_name = Column(db.Unicode, nullable=True)
#     corporation = Column(db.Unicode)
#     alliance = Column(db.Unicode)
#     notes = Column(db.Unicode)
# 
#     ip_address = Column(db.Unicode)
# 
#     creator_id = ReferenceCol('users', nullable=True)
#     creator = relationship('User', foreign_keys=[creator_id], backref='blacklist_character_entries')
# 
#     def __repr__(self):
#         return '<' + self.name + ': ' + self.notes + '>'


# Path: recruit_app/user/admin.py
from .models import EveCharacter, EveAllianceInfo, EveApiKeyPair, EveCorporationInfo, User, Role, roles_users
from flask_security import current_user
from recruit_app.admin import AuthenticatedModelView
from wtforms import PasswordField
from recruit_app.recruit.models import HrApplication, HrApplicationComment
from recruit_app.blacklist.models import BlacklistCharacter
from flask import url_for
from flask.ext.admin.menu import MenuLink


def register_admin_views(admin, db):
    admin.add_link(MenuLink(name='Go Back', url='/', category=''))
    admin.add_view(EveCharacterAdmin(EveCharacter, db.session, category='EvE'))
    admin.add_view(EveCorporationInfoAdmin(EveCorporationInfo, db.session, category='EvE'))

    admin.add_view(EveAllianceInfoAdmin(EveAllianceInfo, db.session, category='EvE'))