コード例 #1
0
ファイル: models.py プロジェクト: clive1230/Recruitment-App
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
コード例 #2
0
ファイル: models.py プロジェクト: clive1230/Recruitment-App
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)
コード例 #3
0
ファイル: models.py プロジェクト: Ryan526/Recruitment-App
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
コード例 #4
0
ファイル: models.py プロジェクト: clive1230/Recruitment-App
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"
コード例 #5
0
ファイル: models.py プロジェクト: Ryan526/Recruitment-App
class AuthInfo(SurrogatePK, Model):
    __tablename__ = 'auth_info'

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

    main_character_id = ReferenceCol('characters', pk_name='character_id', nullable=True)
    main_character = relationship('EveCharacter', lazy='subquery', backref=db.backref('auth_info', lazy='dynamic'))

    def __repr__(self):
        return '<AuthInfo({name})>'.format(name=self.user)
コード例 #6
0
ファイル: models.py プロジェクト: clive1230/Recruitment-App
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"
コード例 #7
0
ファイル: models.py プロジェクト: Ryan526/Recruitment-App
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)
コード例 #8
0
ファイル: models.py プロジェクト: clive1230/Recruitment-App
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
コード例 #9
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"
コード例 #10
0
ファイル: models.py プロジェクト: Ryan526/Recruitment-App
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
コード例 #11
0
ファイル: models.py プロジェクト: clive1230/Recruitment-App
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
コード例 #12
0
ファイル: models.py プロジェクト: clive1230/Recruitment-App
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
コード例 #13
0
ファイル: models.py プロジェクト: Ryan526/Recruitment-App
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
コード例 #14
0
ファイル: models.py プロジェクト: clive1230/Recruitment-App
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 + '>'
コード例 #15
0
ファイル: models.py プロジェクト: clive1230/Recruitment-App
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 + '>'
コード例 #16
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