Beispiel #1
0
class JobType(BaseNameMixin, db.Model):
    __tablename__ = 'jobtype'
    idref = 'type'

    #: Sequence number for sorting in the display list (to be deprecated by boards)
    seq = db.Column(db.Integer, nullable=False, default=0)
    #: This job type is an option for jobs on Hasjob (to be deprecated by boards)
    public = db.Column(db.Boolean, nullable=False, default=True)
    #: This job type is private and not available as an option in boards
    private = db.Column(db.Boolean, nullable=False, default=False)
    #: Jobs with this type may offer to pay nothing
    nopay_allowed = db.Column(db.Boolean, nullable=False, default=True)
    #: Jobs with this type may be listed from a webmail domain
    webmail_allowed = db.Column(db.Boolean, nullable=False, default=True)

    def __repr__(self):
        return '<JobType %d %s%s>' % (self.seq, self.title,
                                      ' (private)' if self.private else '')

    def search_mapping(self):
        """
        Returns a dictionary suitable for search indexing.
        """
        return {
            'title': self.title,
            'content': self.title,
            'public': self.public,
            'idref': u'%s/%s' % (self.idref, self.id),
        }
Beispiel #2
0
class ReportCode(db.Model):
    __tablename__ = 'reportcode'

    id = db.Column(db.Integer, primary_key=True)
    slug = db.Column(db.String(250), nullable=False, unique=True)
    title = db.Column(db.Unicode(250), nullable=False)
    seq = db.Column(db.Integer, nullable=False, default=0)
    public = db.Column(db.Boolean, nullable=False, default=True)
Beispiel #3
0
class JobCategory(BaseNameMixin, db.Model):
    __tablename__ = 'jobcategory'

    #: Sequence number for sorting in the display list (to be deprecated by boards)
    seq = db.Column(db.Integer, nullable=False, default=0)
    #: This job category is an option for jobs on Hasjob (to be deprecated by boards)
    public = db.Column(db.Boolean, nullable=False, default=True)
    #: This job category is private and not available as an option in boards
    private = db.Column(db.Boolean, nullable=False, default=False)

    def __repr__(self):
        return '<JobCategory %d %s%s>' % (self.seq, self.title,
                                          ' (private)' if self.private else '')
Beispiel #4
0
class JobCategory(BaseNameMixin, db.Model):
    __tablename__ = 'jobcategory'
    idref = 'category'

    seq = db.Column(db.Integer, nullable=False, default=0)
    public = db.Column(db.Boolean, nullable=False, default=True)

    def __call__(self):
        return self.title

    def search_mapping(self):
        """
        Returns a dictionary suitable for search indexing.
        """
        return {
            'title': self.title,
            'content': self.title,
            'public': self.public,
            'idref': u'%s/%s' % (self.idref, self.id),
        }
Beispiel #5
0
class JobCategory(db.Model):
    __tablename__ = 'jobcategory'
    idref = 'category'

    id = db.Column(db.Integer, primary_key=True)
    slug = db.Column(db.String(250), nullable=False, unique=True)
    title = db.Column(db.Unicode(250), nullable=False)
    seq = db.Column(db.Integer, nullable=False, default=0)
    public = db.Column(db.Boolean, nullable=False, default=True)

    def __call__(self):
        return self.title

    def search_mapping(self):
        """
        Returns a dictionary suitable for search indexing.
        """
        return {
            'title': self.title,
            'content': self.title,
            'public': self.public,
            'idref': u'%s/%s' % (self.idref, self.id),
        }
Beispiel #6
0
class JobPostReport(db.Model):
    __tablename__ = 'jobpostreport'

    id = db.Column(db.Integer, primary_key=True)
    datetime = db.Column(db.DateTime, default=datetime.utcnow, nullable=False)
    post_id = db.Column(db.Integer,
                        db.ForeignKey('jobpost.id'),
                        nullable=False)
    post = db.relation(JobPost, primaryjoin=post_id == JobPost.id)
    reportcode_id = db.Column(db.Integer,
                              db.ForeignKey('reportcode.id'),
                              nullable=False)
    reportcode = db.relation(ReportCode,
                             primaryjoin=reportcode_id == ReportCode.id)

    ipaddr = db.Column(db.String(45), nullable=False)
    useragent = db.Column(db.Unicode(250), nullable=True)
Beispiel #7
0
class JobPostReport(db.Model):
    __tablename__ = 'jobpostreport'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(None, db.ForeignKey('user.id'), nullable=True)
    user = db.relationship(User)
    datetime = db.Column(db.DateTime, default=datetime.utcnow, nullable=False)
    post_id = db.Column(db.Integer,
                        db.ForeignKey('jobpost.id'),
                        nullable=False)
    post = db.relation(JobPost,
                       primaryjoin=post_id == JobPost.id,
                       backref=db.backref('flags',
                                          cascade='all, delete-orphan'))
    reportcode_id = db.Column(db.Integer,
                              db.ForeignKey('reportcode.id'),
                              nullable=False)
    reportcode = db.relation(ReportCode,
                             primaryjoin=reportcode_id == ReportCode.id)
    report_code = db.synonym('reportcode_id')

    ipaddr = db.Column(db.String(45), nullable=False)
    useragent = db.Column(db.Unicode(250), nullable=True)
Beispiel #8
0
class JobPost(db.Model):
    __tablename__ = 'jobpost'
    idref = 'post'

    # Metadata
    id = db.Column(db.Integer, primary_key=True)
    hashid = db.Column(db.String(5), nullable=False, unique=True)
    created_datetime = db.Column(db.DateTime,
                                 default=datetime.utcnow,
                                 nullable=False)
    datetime = db.Column(db.DateTime, default=datetime.utcnow,
                         nullable=False)  # Published
    closed_datetime = db.Column(db.DateTime,
                                nullable=True)  # If withdrawn or rejected
    #modified_datetime = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
    sticky = db.Column(db.Boolean, nullable=False, default=False)

    # Job description
    headline = db.Column(db.Unicode(100), nullable=False)
    type_id = db.Column(db.Integer,
                        db.ForeignKey('jobtype.id'),
                        nullable=False)
    type = db.relation(JobType, primaryjoin=type_id == JobType.id)
    category_id = db.Column(db.Integer,
                            db.ForeignKey('jobcategory.id'),
                            nullable=False)
    category = db.relation(JobCategory,
                           primaryjoin=category_id == JobCategory.id)
    location = db.Column(db.Unicode(80), nullable=False)
    relocation_assist = db.Column(db.Boolean, default=False, nullable=False)
    description = db.Column(db.UnicodeText, nullable=False)
    perks = db.Column(db.UnicodeText, nullable=False)
    how_to_apply = db.Column(db.UnicodeText, nullable=False)
    hr_contact = db.Column(db.Boolean, nullable=True)

    # Company details
    company_name = db.Column(db.Unicode(80), nullable=False)
    company_logo = db.Column(db.Unicode(255), nullable=True)
    company_url = db.Column(db.Unicode(255), nullable=False, default=u'')
    email = db.Column(db.Unicode(80), nullable=False)
    email_domain = db.Column(db.Unicode(80), nullable=False, index=True)
    md5sum = db.Column(db.String(32), nullable=False, index=True)

    # Payment, audit and workflow fields
    words = db.Column(
        db.UnicodeText,
        nullable=True)  # All words in description, perks and how_to_apply
    promocode = db.Column(db.String(40), nullable=True)
    status = db.Column(db.Integer, nullable=False, default=POSTSTATUS.DRAFT)
    ipaddr = db.Column(db.String(45), nullable=False)
    useragent = db.Column(db.Unicode(250), nullable=True)
    edit_key = db.Column(db.String(40),
                         nullable=False,
                         default=random_long_key)
    email_verify_key = db.Column(db.String(40),
                                 nullable=False,
                                 default=random_long_key)
    email_sent = db.Column(db.Boolean, nullable=False, default=False)
    email_verified = db.Column(db.Boolean, nullable=False, default=False)
    payment_value = db.Column(db.Integer, nullable=False, default=0)
    payment_received = db.Column(db.Boolean, nullable=False, default=False)
    reviewer_id = db.Column(db.Integer,
                            db.ForeignKey('user.id'),
                            nullable=True)
    review_datetime = db.Column(db.DateTime, nullable=True)
    review_comments = db.Column(db.Unicode(250), nullable=True)

    def is_draft(self):
        return self.status == POSTSTATUS.DRAFT

    def is_listed(self):
        now = datetime.utcnow()
        return (self.status in [POSTSTATUS.CONFIRMED, POSTSTATUS.REVIEWED
                                ]) and (self.datetime > now - agelimit)

    def is_flagged(self):
        return self.status == POSTSTATUS.FLAGGED

    def is_old(self):
        return self.datetime <= datetime.utcnow() - agelimit

    def search_mapping(self):
        """
        Returns a dictionary suitable for search indexing.
        """
        content = '\n'.join(
            (self.headline, self.location, self.company_name, self.company_url,
             self.description, self.perks, self.how_to_apply))

        return {
            'title': self.headline,
            'content': content,
            'public': self.is_listed(),
            'idref': u'%s/%s' % (self.idref, self.id),
        }
Beispiel #9
0
class User(UserBase, db.Model):
    __tablename__ = 'user'

    blocked = db.Column(db.Boolean, nullable=False, default=False)
Beispiel #10
0
class ReportCode(BaseNameMixin, db.Model):
    __tablename__ = 'reportcode'

    seq = db.Column(db.Integer, nullable=False, default=0)
    public = db.Column(db.Boolean, nullable=False, default=True)