# Path: recruit_app/database.py
# class CRUDMixin(object):
# class Model(CRUDMixin, db.Model):
# class SurrogatePK(object):
# class TimeMixin(object):
#     def create(cls, **kwargs):
#     def update(self, commit=True, **kwargs):
#     def save(self, commit=True):
#     def delete(self, commit=True):
#     def get_by_id(cls, id):
# def ReferenceCol(tablename, nullable=True, pk_name='id', **kwargs):


from recruit_app.database import Column, db, Model, ReferenceCol, relationship, SurrogatePK, TimeMixin
from flask import current_app
from sqlalchemy.orm import backref
import requests
import datetime as dt

    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 + '>'


# A cache table and wrapper for the GSF blacklist
class BlacklistGSF(TimeMixin, Model):
    __tablename__ = 'blacklist_gsf'
    
    status = Column(db.Unicode)
    character_id = ReferenceCol('characters', pk_name='character_id', primary_key=True)
    character = relationship('EveCharacter', foreign_keys=[character_id], backref=backref('blacklist_gsf', cascade="delete"))
    
    @staticmethod
    def getStatus(character):
        try:
            entry = BlacklistGSF.query.filter_by(character_id=character.character_id).one()
        except:
            # No entry, create a new one

# Path: recruit_app/database.py
# class CRUDMixin(object):
# class Model(CRUDMixin, db.Model):
# class SurrogatePK(object):
# class TimeMixin(object):
#     def create(cls, **kwargs):
#     def update(self, commit=True, **kwargs):
#     def save(self, commit=True):
#     def delete(self, commit=True):
#     def get_by_id(cls, id):
# def ReferenceCol(tablename, nullable=True, pk_name='id', **kwargs):


# Path: recruit_app/blacklist/models.py
from recruit_app.database import Column, db, Model, ReferenceCol, relationship, SurrogatePK, TimeMixin
from flask import current_app
from sqlalchemy.orm import backref
import requests
import datetime as dt


    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 + '>'


# A cache table and wrapper for the GSF blacklist
class BlacklistGSF(TimeMixin, Model):
    __tablename__ = 'blacklist_gsf'
    
    status = Column(db.Unicode)
    character_id = ReferenceCol('characters', pk_name='character_id', primary_key=True)
    character = relationship('EveCharacter', foreign_keys=[character_id], backref=backref('blacklist_gsf', cascade="delete"))
    
    @staticmethod
    def getStatus(character):
        try:
            entry = BlacklistGSF.query.filter_by(character_id=character.character_id).one()
        except:
            # No entry, create a new one

            entry = BlacklistGSF()