예제 #1
0
class EveCharacter(Model):
    __tablename__ = 'characters'

    character_id = Column(db.String(254), unique=True, primary_key=True)
    character_name = Column(db.String(254))
    corporation_id = ReferenceCol('corporations', pk_name='corporation_id', nullable=True)
    corporation = relationship('EveCorporationInfo', backref='characters')

    alliance_id = ReferenceCol('alliances', pk_name='alliance_id', nullable=True)
    alliance = relationship('EveAllianceInfo', backref='characters')

    api_id = ReferenceCol('api_key_pairs', pk_name='api_id', nullable=True)
    api = relationship('EveApiKeyPair', backref='characters')

    user_id = ReferenceCol('users', nullable=True)
    user = relationship('User', backref='characters')

    skillpoints = Column(db.Integer, nullable=True)

    # def __init__(self, character_id, character_name, corporation_id,  **kwargs):
    #     db.Model.__init__(self, character_id=character_id, character_name=character_name, corporation_id=corporation_id, **kwargs)

    #hr_applications = db.relationship('HrApplications', backref='person', lazy='dynamic')
    #hr_comments = db.relationship('Comments', backref='person', lazy='dynamic')

    def __str__(self):
        return self.character_name
예제 #2
0
class EveCharacter(Model, TimeMixin):
    __tablename__ = 'characters'

    character_id = Column(db.String(254), primary_key=True)
    character_name = Column(db.String(254))
    corporation_id = ReferenceCol('corporations',
                                  pk_name='corporation_id',
                                  nullable=True)
    corporation = relationship('EveCorporationInfo',
                               backref='characters',
                               foreign_keys=[corporation_id])

    api_id = ReferenceCol('api_key_pairs', pk_name='api_id', nullable=True)
    api = relationship('EveApiKeyPair',
                       backref='characters',
                       foreign_keys=[api_id])

    user_id = ReferenceCol('users', nullable=True)
    user = relationship('User', backref='characters', foreign_keys=[user_id])

    skillpoints = Column(db.Integer, nullable=True)
    previous_users = db.relationship('User',
                                     secondary=previous_chars,
                                     backref=db.backref('previous_chars',
                                                        lazy='dynamic'),
                                     lazy='dynamic')

    def __str__(self):
        return self.character_name
예제 #3
0
class EveCorporationInfo(Model):
    __tablename__ = 'corporations'

    corporation_id = Column(db.String(254), unique=True, primary_key=True)
    corporation_name = Column(db.String(254))
    corporation_ticker = Column(db.String(254))
    member_count = Column(db.Integer)
    is_blue = Column(db.Boolean, default=False)
    alliance_id = ReferenceCol('alliances', pk_name='alliance_id', nullable=True)
    alliance = relationship('EveAllianceInfo', backref='corporations')

    # def __init__(self, corporation_id, corporation_name, corporation_ticker, member_count=member_count,  **kwargs):
    #     db.Model.__init__(self, corporation_id=corporation_id, corporation_name=corporation_name, corporation_ticker=corporation_ticker, **kwargs)

    def __str__(self):
        return self.corporation_name
예제 #4
0
class Role(SurrogatePK, Model, RoleMixin):
    __tablename__ = 'roles'
    name = Column(db.String(80), unique=True)
    description = db.Column(db.String(255))

    def __repr__(self):
        return '<Role({name})>'.format(name=self.name)
예제 #5
0
class EveApiKeyPair(Model):
    __tablename__ = 'api_key_pairs'

    api_id = Column(db.String(254), primary_key=True)
    api_key = Column(db.String(254))
    last_update_time = Column(db.DateTime(), nullable=True)
    last_scraped_time = Column(db.DateTime(),
                               nullable=True,
                               default=dt.date(day=1, month=1, year=1980))

    user_id = ReferenceCol('users', nullable=True)
    user = relationship('User', backref='api_keys', foreign_keys=[user_id])

    valid = Column(db.Boolean, default=True)

    def __str__(self):
        return self.api_id
예제 #6
0
class EveApiKeyPair(Model):
    __tablename__ = 'api_key_pairs'

    api_id = Column(db.String(254), unique=True, primary_key=True)
    api_key = Column(db.String(254))
    last_update_time = Column(db.DateTime(), nullable=True)

    user_id = ReferenceCol('users', nullable=True)
    user = relationship('User', backref='api_keys')

    valid = Column(db.Boolean, default=True)

    # def __init__(self, api_id, api_key, user_id,  **kwargs):
    #     db.Model.__init__(self, api_id=api_id, api_key=api_key, user_id=user_id, **kwargs)

    def __str__(self):
        return self.api_id
예제 #7
0
class EveCorporationInfo(Model):
    __tablename__ = 'corporations'

    corporation_id = Column(db.String(254), primary_key=True)
    corporation_name = Column(db.String(254))
    corporation_ticker = Column(db.String(254))
    member_count = Column(db.Integer)
    is_blue = Column(db.Boolean, default=False)
    alliance_id = ReferenceCol('alliances',
                               pk_name='alliance_id',
                               nullable=True)
    alliance = relationship('EveAllianceInfo',
                            backref='corporations',
                            foreign_keys=[alliance_id])

    def __str__(self):
        return self.corporation_name
예제 #8
0
class HrApplicationCommentHistory(SurrogatePK, TimeMixin, Model):
    __tablename__ = 'hr_comment_history'
    
    old_comment = Column(db.Text, nullable=True)
    comment_id = ReferenceCol('hr_comments')
    editor = ReferenceCol('users')
    comment = relationship('HrApplicationComment', foreign_keys=[comment_id], backref=backref('hr_comment_history', cascade="delete"))
    user = relationship('User', backref='hr_comment_history', foreign_keys=[editor])
    
    def __repr__(self):
        return str(self.editor) + " - Edited comment"
예제 #9
0
class RolePair(SurrogatePK, Model):
    __tablename__ = 'role_pair'
    member_role_id = ReferenceCol('roles', nullable=True)
    leader_role_id = ReferenceCol('roles', nullable=True)
    name = Column(db.String(80), unique=True)
    description = db.Column(db.String(255))

    member_role = relationship('Role', foreign_keys=[member_role_id], backref='member_pairs')
    reviewer_user = relationship('Role', foreign_keys=[leader_role_id], backref='leader_pairs')

    def __repr__(self):
        return '<RolePair({name})>'.format(name=self.name)
예제 #10
0
class Role(SurrogatePK, Model, RoleMixin):
    __tablename__ = 'roles'
    name = Column(db.String(80), unique=True)
    description = db.Column(db.String(255))
    #user_id = ReferenceCol('users', nullable=True)
    #user = relationship('User', backref='roles')

    # def __init__(self, name, **kwargs):
    #     db.Model.__init__(self, name=name, **kwargs)

    def __repr__(self):
        return '<Role({name})>'.format(name=self.name)
예제 #11
0
class HrApplicationComment(SurrogatePK, Model):
    __tablename__ = 'hr_comments'

    comment = Column(db.Text, nullable=True)

    application_id = ReferenceCol('hr_applications', nullable=False)
    user_id = ReferenceCol('users', nullable=False)

    last_update_time = Column(db.DateTime(), nullable=True)

    application = relationship('HrApplication',
                               foreign_keys=[application_id],
                               backref=db.backref('hr_comments',
                                                  cascade="delete"),
                               single_parent=True)

    user = relationship('User',
                        backref=db.backref('hr_comments', lazy='dynamic'))

    def __repr__(self):
        return str(self.user) + " - Comment"
예제 #12
0
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"
예제 #13
0
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()
            entry.character_id = character.character_id
            entry.status = u'UNKNOWN'

        if entry.last_update_time is None or (
                dt.datetime.utcnow() -
                entry.last_update_time).total_seconds() > 86400:  # 1 day cache
            try:
                url = current_app.config[
                    'GSF_BLACKLIST_URL'] + character.character_name
                r = requests.post(url)
                entry.status = unicode(r.json()[0]['output'])
                entry.last_update_time = dt.datetime.utcnow()
            except:  # Will except on NONE for URL or connection issues.  Just keep status as UNKNOWN
                pass

            try:
                entry.save()
            except:
                # It's possible that multiple people are viewing the same new app at the same time, causing multiple threads to make the same cache object,
                # which throws an IntegrityError.  In that case just ignore the error, this is just a cache anyway.
                pass

        return str(entry.status)

    def __repr__(self):
        return '<BlacklistCacheEntry' + ': ' + self.character_id + '>'
예제 #14
0
class EveAllianceInfo(Model):
    __tablename__ = 'alliances'

    alliance_id = Column(db.String(254), primary_key=True)
    alliance_name = Column(db.String(254))
    alliance_ticker = Column(db.String(254))
    executor_corp_id = Column(db.String(254))
    is_blue = Column(db.Boolean, default=False)
    member_count = Column(db.Integer)

    def __str__(self):
        return self.alliance_name
예제 #15
0
class EveAllianceInfo(Model):
    __tablename__ = 'alliances'

    alliance_id = Column(db.String(254), unique=True, primary_key=True)
    alliance_name = Column(db.String(254))
    alliance_ticker = Column(db.String(254))
    executor_corp_id = Column(db.String(254))
    is_blue = Column(db.Boolean, default=False)
    member_count = Column(db.Integer)

    # def __init__(self, alliance_id, alliance_name, alliance_ticker, executor_corp_id,  **kwargs):
    #     db.Model.__init__(self, alliance_id=alliance_id, alliance_name=alliance_name, alliance_ticker=alliance_ticker, **kwargs)

    def __str__(self):
        return self.alliance_name
예제 #16
0
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 + '>'
예제 #17
0
class User(SurrogatePK, Model, UserMixin):
    __tablename__ = 'users'

    username = Column(db.String(80), unique=True, nullable=True)
    email = Column(db.String(80), unique=True, nullable=False)
    #: The hashed password
    password = Column(db.String(128), nullable=True)
    created_at = Column(db.DateTime, nullable=False, default=dt.datetime.utcnow)
    active = Column(db.Boolean(), default=False)
    is_admin = Column(db.Boolean(), default=False)

    confirmed_at = Column(db.DateTime, nullable=True)

    last_login_at = Column(db.DateTime())
    current_login_at = Column(db.DateTime())
    last_login_ip = Column(db.String(100))
    current_login_ip = Column(db.String(100))
    login_count = Column(db.Integer)

    roles = db.relationship('Role', secondary=roles_users,
                            backref=db.backref('users', lazy='dynamic'))

    # def __init__(self, username, email, password=None, **kwargs):
    #     db.Model.__init__(self, username=username, email=email, **kwargs)
    #     if password:
    #         self.set_password(password)
    #     else:
    #         self.password = None

    def set_password(self, password):
        self.password = bcrypt.generate_password_hash(password)

    def check_password(self, value):
        return bcrypt.check_password_hash(self.password, value)

    @property
    def full_name(self):
        return "{0} {1}".format(self.first_name, self.last_name)

    # def __repr__(self):
    #     return '<User({username!r})>'.format(username=self.username)
    def __repr__(self):
        return '<User({name})>'.format(name=self.email)
예제 #18
0
class User(SurrogatePK, Model, UserMixin):
    __tablename__ = 'users'

    email = Column(db.String(80), unique=True, nullable=False)
    #: The hashed password
    password = Column(db.String(128), nullable=True)
    created_at = Column(db.DateTime,
                        nullable=False,
                        default=dt.datetime.utcnow)
    active = Column(db.Boolean(), default=False)
    is_admin = Column(db.Boolean(), default=False)

    confirmed_at = Column(db.DateTime, nullable=True)

    last_login_at = Column(db.DateTime())
    current_login_at = Column(db.DateTime())
    last_login_ip = Column(db.String(100))
    current_login_ip = Column(db.String(100))
    login_count = Column(db.Integer)

    roles = db.relationship('Role',
                            secondary=roles_users,
                            backref=db.backref('users', lazy='dynamic'),
                            lazy='dynamic')

    main_character_id = ReferenceCol('characters',
                                     pk_name='character_id',
                                     nullable=True)
    main_character = relationship('EveCharacter',
                                  backref='user_main_character',
                                  foreign_keys=[main_character_id])

    def set_password(self, password):
        self.password = encrypt_password(password)
        self.save()

    def check_password(self, value):
        return verify_and_update_password(value, self)

    @classmethod
    def create(self, **kwargs):
        """Create a new record and save it the database."""
        instance = self(**kwargs)
        if kwargs['password']:
            instance.password = encrypt_password(kwargs['password'])
        return instance.save()

    @property
    def get_ips(self):
        return self.last_login_ip.split(', ') + self.current_login_ip.split(
            ', ')

    def __repr__(self):
        return '<User({name})>'.format(name=self.email)

    def __str__(self):
        return self.email
예제 #19
0
class HrApplication(SurrogatePK, Model):
    __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.Text, nullable=True)

    alt_application = Column(db.Boolean, default=False)

    characters = db.relationship('EveCharacter',
                                 secondary=character_apps,
                                 backref=db.backref('alt_apps',
                                                    lazy='dynamic'))

    thesis = Column(db.Text, 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)

    #reason_for_joining = Column(db.Text, nullable=True)
    find_out = Column(db.Text, nullable=True)

    favorite_role = Column(db.Text, nullable=True)

    last_update_time = Column(db.DateTime(), 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.String(10), default="Pending")

    hidden = Column(db.Boolean, nullable=True, default=False)

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

    # def __str__(self):
    #     return self.user.auth_info + " - Application"
    def __str__(self):
        return '<Application %r>' % self.user.auth_info
예제 #20
0
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)