def make_user_team_table(base):
    if 'users_teams' in base.metadata.tables:
        return base.metadata.tables['users_teams']
    else:
        return Table('users_teams', base.metadata, *(make_timestamp_columns() + (
            Column('user_id', Integer, ForeignKey('user.id'), primary_key=True),
            Column('team_id', Integer, ForeignKey('team.id'), primary_key=True)
            )))
def make_user_team_table(base):
    if 'users_teams' in base.metadata.tables:
        return base.metadata.tables['users_teams']
    else:
        return Table(
            'users_teams', base.metadata,
            *(make_timestamp_columns() +
              (Column(
                  'user_id', Integer, ForeignKey('user.id'), primary_key=True),
               Column(
                   'team_id', Integer, ForeignKey('team.id'),
                   primary_key=True))))
Exemple #3
0
def viewstats_by_id_qhour(jobpost_id):
    return viewstats_helper(jobpost_id, 900, 24)


@cache.memoize(timeout=3600)
def viewstats_by_id_hour(jobpost_id):
    return viewstats_helper(jobpost_id, 3600, 48)


@cache.memoize(timeout=86400)
def viewstats_by_id_day(jobpost_id):
    return viewstats_helper(jobpost_id, 1, 30, daybatch=True)


jobpost_admin_table = db.Table('jobpost_admin', db.Model.metadata,
    *(make_timestamp_columns() + (
    db.Column('user_id', None, db.ForeignKey('user.id'), primary_key=True),
    db.Column('jobpost_id', None, db.ForeignKey('jobpost.id'), primary_key=True)
    )))


class JobLocation(TimestampMixin, db.Model):
    __tablename__ = 'job_location'
    #: Job listing we are tagging
    jobpost_id = db.Column(None, db.ForeignKey('jobpost.id'), primary_key=True, nullable=False)
    jobpost = db.relationship(JobPost, backref=db.backref('locations', cascade='all, delete-orphan'))
    #: Geonameid for this job listing
    geonameid = db.Column(db.Integer, primary_key=True, nullable=False)
    primary = db.Column(db.Boolean, default=True, nullable=False)

    def __repr__(self):
Exemple #4
0
    }


@cache.memoize(timeout=3600)
def viewstats_by_id_hour(jobpost_id, limit=48):
    return viewstats_helper(jobpost_id, 4 * 3600, limit)  # 4 hours interval


@cache.memoize(timeout=86400)
def viewstats_by_id_day(jobpost_id, limit=30):
    return viewstats_helper(jobpost_id, 1, limit, daybatch=True)


jobpost_admin_table = db.Table(
    'jobpost_admin', db.Model.metadata,
    *(make_timestamp_columns() +
      (db.Column('user_id', None, db.ForeignKey('user.id'), primary_key=True),
       db.Column(
           'jobpost_id', None, db.ForeignKey('jobpost.id'),
           primary_key=True))))


class JobLocation(TimestampMixin, db.Model):
    __tablename__ = 'job_location'
    #: Job post we are tagging
    jobpost_id = db.Column(None,
                           db.ForeignKey('jobpost.id'),
                           primary_key=True,
                           nullable=False)
    jobpost = db.relationship(JobPost,
                              backref=db.backref('locations',
Exemple #5
0
from .user import User, UserActiveAt

__all__ = [
    'Board',
    'BoardJobPost',
    'BoardAutoDomain',
    'BoardAutoLocation',
    'board_auto_tag_table',
    'board_auto_jobtype_table',
    'board_auto_jobcategory_table',
]

board_jobtype_table = db.Table(
    'board_jobtype',
    db.Model.metadata,
    *(make_timestamp_columns(timezone=True) + (
        db.Column(
            'board_id', None, db.ForeignKey('board.id'), primary_key=True),
        db.Column(
            'jobtype_id', None, db.ForeignKey('jobtype.id'), primary_key=True),
    )),
)

board_jobcategory_table = db.Table(
    'board_jobcategory',
    db.Model.metadata,
    *(make_timestamp_columns(timezone=True) + (
        db.Column(
            'board_id', None, db.ForeignKey('board.id'), primary_key=True),
        db.Column(
            'jobcategory_id',
Exemple #6
0
from sqlalchemy.ext.associationproxy import association_proxy
from coaster.sqlalchemy import make_timestamp_columns
from . import db, TimestampMixin, BaseNameMixin
from .user import User, UserActiveAt
from .jobpost import JobPost
from .jobtype import JobType
from .jobcategory import JobCategory

__all__ = ["Board", "BoardJobPost", "BoardDomain", "BoardLocation"]


board_jobtype_table = db.Table(
    "board_jobtype",
    db.Model.metadata,
    *(
        make_timestamp_columns()
        + (
            db.Column("board_id", None, db.ForeignKey("board.id"), primary_key=True),
            db.Column("jobtype_id", None, db.ForeignKey("jobtype.id"), primary_key=True),
        )
    )
)


board_jobcategory_table = db.Table(
    "board_jobcategory",
    db.Model.metadata,
    *(
        make_timestamp_columns()
        + (
            db.Column("board_id", None, db.ForeignKey("board.id"), primary_key=True),
Exemple #7
0
    def __repr__(self):
        return '<UserOldId {buid} of {user}>'.format(buid=self.buid,
                                                     user=repr(
                                                         self.user)[1:-1])

    @classmethod
    def get(cls, uuid):
        return cls.query.filter_by(id=uuid).one_or_none()


# --- Organizations and teams -------------------------------------------------

team_membership = db.Table(
    'team_membership', db.Model.metadata,
    *(make_timestamp_columns() + (db.Column('user_id',
                                            None,
                                            db.ForeignKey('user.id'),
                                            nullable=False,
                                            primary_key=True),
                                  db.Column('team_id',
                                            None,
                                            db.ForeignKey('team.id'),
                                            nullable=False,
                                            primary_key=True))))


class Organization(UuidMixin, BaseMixin, db.Model):
    __tablename__ = 'organization'
    # owners_id cannot be null, but must be declared with nullable=True since there is
    # a circular dependency. The post_update flag on the relationship tackles the circular
Exemple #8
0
from . import db, TimestampMixin, BaseNameMixin
from .user import User, UserActiveAt
from .jobpost import JobPost
from .jobtype import JobType
from .jobcategory import JobCategory
from .tag import Tag

__all__ = [
    'Board', 'BoardJobPost', 'BoardAutoDomain', 'BoardAutoLocation',
    'board_auto_tag_table', 'board_auto_jobtype_table',
    'board_auto_jobcategory_table'
]

board_jobtype_table = db.Table(
    'board_jobtype', db.Model.metadata,
    *(make_timestamp_columns() +
      (db.Column('board_id', None, db.ForeignKey('board.id'),
                 primary_key=True),
       db.Column(
           'jobtype_id', None, db.ForeignKey('jobtype.id'),
           primary_key=True))))

board_jobcategory_table = db.Table(
    'board_jobcategory', db.Model.metadata,
    *(make_timestamp_columns() + (db.Column(
        'board_id', None, db.ForeignKey('board.id'), primary_key=True),
                                  db.Column('jobcategory_id',
                                            None,
                                            db.ForeignKey('jobcategory.id'),
                                            primary_key=True))))