Example #1
0
class Role(db.Model, RoleMixin):
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(80), unique=True)
    description = db.Column(db.String(255))

    def __str__(self):
        return '%s' % (self.name)
Example #2
0
class Jobs(db.Model):
    id = db.Column(db.Integer(), primary_key=True)

    # comments
    # views
    # overall_sentiment

    # see below for relationship argument api
    # http://docs.sqlalchemy.org/en/latest/orm/relationship_api.html#relationships-api
    job_role = db.relationship('OfferingRole',
                               secondary=job_roles,
                               backref=db.backref('jobs', lazy='dynamic'))

    job_level = db.relationship('OfferingLevel',
                                secondary=job_levels,
                                backref=db.backref('jobs', lazy='dynamic'))

    job_location = db.relationship('OfferingLocation',
                                   secondary=job_locations,
                                   backref=db.backref('jobs', lazy='dynamic'))

    submitted_by = db.relationship('User',
                                   secondary=job_submitted_by,
                                   backref=db.backref('jobs', lazy='dynamic'))

    submitted_at = db.Column(db.DateTime(timezone=True),
                             default=datetime.now())

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

    job_rec_name = db.Column(db.String(255), nullable=False)

    # TODO this is only okay for MVP purposes -- if this becomes a thing we'll have to put job recs somewhere else.
    # TODO not putting this in s3 because I want these files local for rapid xport to user
    job_rec_file = db.Column(db.LargeBinary(), nullable=False)

    def __str__(self):
        return '<Job id=%s>' % (self.id)

    # ty so https://stackoverflow.com/a/11884806
    def as_dict(self):
        return {
            c.name: getattr(self, c.name)
            for c in self.__table__.columns if c.name != '_sa_instance_state'
            and c.name != 'submitted_at' and c.name != 'active'
        }
Example #3
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer(), primary_key=True)
    first_name = db.Column(db.String(255), nullable=False)
    last_name = db.Column(db.String(255), nullable=False)
    email = db.Column(db.String(120), nullable=False, unique=True)
    password = db.Column(db.String(255), nullable=False)
    active = db.Column(db.Boolean(), nullable=False, default=False)
    confirmed_at = db.Column(db.DateTime(timezone=True))
    current_login_at = db.Column(db.DateTime(timezone=True))
    last_login_at = db.Column(db.DateTime(timezone=True))
    login_count = db.Column(db.Integer(), default=1)
    current_login_ip = db.Column(db.String(42))
    last_login_ip = db.Column(db.String(42))

    # see below for relationship argument api
    # http://docs.sqlalchemy.org/en/latest/orm/relationship_api.html#relationships-api
    roles = db.relationship('Role',
                            secondary=roles_users,
                            backref=db.backref('users', lazy='dynamic'))

    def __str__(self):
        return '<User id=%s email=%s>' % (self.id, self.email)
Example #4
0
# users and roles table
# copyright (c) 2018 wildduck.io

from flask_security import UserMixin, RoleMixin

from app_src.helpers.datastore_helpers import db

roles_users = db.Table(
    'roles_users', db.Column('user_id', db.Integer(),
                             db.ForeignKey('user.id')),
    db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))


class User(db.Model, UserMixin):
    id = db.Column(db.Integer(), primary_key=True)
    first_name = db.Column(db.String(255), nullable=False)
    last_name = db.Column(db.String(255), nullable=False)
    email = db.Column(db.String(120), nullable=False, unique=True)
    password = db.Column(db.String(255), nullable=False)
    active = db.Column(db.Boolean(), nullable=False, default=False)
    confirmed_at = db.Column(db.DateTime(timezone=True))
    current_login_at = db.Column(db.DateTime(timezone=True))
    last_login_at = db.Column(db.DateTime(timezone=True))
    login_count = db.Column(db.Integer(), default=1)
    current_login_ip = db.Column(db.String(42))
    last_login_ip = db.Column(db.String(42))

    # see below for relationship argument api
    # http://docs.sqlalchemy.org/en/latest/orm/relationship_api.html#relationships-api
    roles = db.relationship('Role',
                            secondary=roles_users,
Example #5
0
# jobs table(s)
# copyright (c) 2018 wildduck.io

from datetime import datetime

from app_src.helpers.datastore_helpers import db

job_roles = db.Table(
    'job_roles', db.Column('jobs_id', db.Integer(), db.ForeignKey('jobs.id')),
    db.Column('offering_role_id', db.Integer(),
              db.ForeignKey('offering_role.id')))

job_levels = db.Table(
    'job_levels', db.Column('jobs_id', db.Integer(), db.ForeignKey('jobs.id')),
    db.Column('offering_level_id', db.Integer(),
              db.ForeignKey('offering_level.id')))

job_locations = db.Table(
    'job_locations',
    db.Column('jobs_id', db.Integer(), db.ForeignKey('jobs.id')),
    db.Column('offering_location_id', db.Integer(),
              db.ForeignKey('offering_location.id')))

job_submitted_by = db.Table(
    'job_submitted_by',
    db.Column('jobs_id', db.Integer(), db.ForeignKey('jobs.id')),
    db.Column('user_id', db.Integer(), db.ForeignKey('user.id')))


class Jobs(db.Model):
    id = db.Column(db.Integer(), primary_key=True)