예제 #1
0
def revealjob(hashid):
    """
    This view is a GET request and that is intentional.
    """
    post = JobPost.query.filter_by(hashid=hashid).first_or_404()
    if post.status in [
            POSTSTATUS.REJECTED, POSTSTATUS.WITHDRAWN, POSTSTATUS.SPAM
    ]:
        abort(410)
    jobview = UserJobView.query.get((g.user.id, post.id))
    if jobview is None:
        jobview = UserJobView(user=g.user, jobpost=post, applied=True)
        cache.delete_memoized(viewcounts_by_id, post.id)
        cache.delete_memoized(viewstats_by_id_qhour, post.id)
        cache.delete_memoized(viewstats_by_id_hour, post.id)
        cache.delete_memoized(viewstats_by_id_day, post.id)
        db.session.add(jobview)
        try:
            db.session.commit()
        except IntegrityError:
            db.session.rollback()
            pass  # User double-clicked. Ignore.
        viewcounts_by_id(post.id)  # Re-populate cache
    elif not jobview.applied:
        jobview.applied = True
        cache.delete_memoized(viewcounts_by_id, post.id)
        cache.delete_memoized(viewstats_by_id_qhour, post.id)
        cache.delete_memoized(viewstats_by_id_hour, post.id)
        cache.delete_memoized(viewstats_by_id_day, post.id)
        db.session.commit()
        viewcounts_by_id(post.id)  # Re-populate cache
    if request.is_xhr:
        return redactemail(post.how_to_apply)
    else:
        return redirect(url_for('jobdetail', hashid=post.hashid), 303)
예제 #2
0
def revealjob(hashid):
    """
    This view is a GET request and that is intentional.
    """
    post = JobPost.query.filter_by(hashid=hashid).first_or_404()
    if post.status in [POSTSTATUS.REJECTED, POSTSTATUS.WITHDRAWN, POSTSTATUS.SPAM]:
        abort(410)
    jobview = UserJobView.query.get((g.user.id, post.id))
    if jobview is None:
        jobview = UserJobView(user=g.user, jobpost=post, applied=True)
        cache.delete_memoized(viewcounts_by_id, post.id)
        cache.delete_memoized(viewstats_by_id_qhour, post.id)
        cache.delete_memoized(viewstats_by_id_hour, post.id)
        cache.delete_memoized(viewstats_by_id_day, post.id)
        db.session.add(jobview)
        try:
            db.session.commit()
        except IntegrityError:
            db.session.rollback()
            pass  # User double-clicked. Ignore.
        viewcounts_by_id(post.id)  # Re-populate cache
    elif not jobview.applied:
        jobview.applied = True
        cache.delete_memoized(viewcounts_by_id, post.id)
        cache.delete_memoized(viewstats_by_id_qhour, post.id)
        cache.delete_memoized(viewstats_by_id_hour, post.id)
        cache.delete_memoized(viewstats_by_id_day, post.id)
        db.session.commit()
        viewcounts_by_id(post.id) # Re-populate cache
    if request.is_xhr:
        return redactemail(post.how_to_apply)
    else:
        return redirect(url_for('jobdetail', hashid=post.hashid), 303)
예제 #3
0
파일: listing.py 프로젝트: iambibhas/hasjob
def revealjob(domain, hashid):
    """
    Reveal job application form
    """
    post = JobPost.query.filter_by(hashid=hashid).first_or_404()
    if post.status in POSTSTATUS.GONE:
        abort(410)
    jobview = UserJobView.query.get((post.id, g.user.id))
    if jobview is None:
        jobview = UserJobView(user=g.user, jobpost=post, applied=True)
        db.session.add(jobview)
        try:
            db.session.commit()
            post.uncache_viewcounts('opened')
            cache.delete_memoized(viewstats_by_id_qhour, post.id)
            cache.delete_memoized(viewstats_by_id_hour, post.id)
            cache.delete_memoized(viewstats_by_id_day, post.id)
            post.viewcounts  # Re-populate cache
        except IntegrityError:
            db.session.rollback()
            pass  # User double-clicked. Ignore.
    elif not jobview.applied:
        jobview.applied = True
        db.session.commit()
        post.uncache_viewcounts('opened')
        cache.delete_memoized(viewstats_by_id_qhour, post.id)
        cache.delete_memoized(viewstats_by_id_hour, post.id)
        cache.delete_memoized(viewstats_by_id_day, post.id)
        post.viewcounts  # Re-populate cache

    applyform = None
    job_application = JobApplication.query.filter_by(user=g.user, jobpost=post).first()
    if not job_application:
        applyform = forms.ApplicationForm()
        applyform.apply_phone.data = g.user.phone

    return render_template('jobpost_reveal.html',
        post=post,
        instructions=redactemail(post.how_to_apply),
        applyform=applyform,
        job_application=job_application)
예제 #4
0
def revealjob(domain, hashid):
    """
    This view is a GET request and that is intentional.
    """
    post = JobPost.query.filter_by(hashid=hashid).first_or_404()
    # If the domain doesn't match, redirect to correct URL
    if post.email_domain != domain:
        return redirect(post.url_for('reveal'), code=301)

    if post.status in [
            POSTSTATUS.REJECTED, POSTSTATUS.WITHDRAWN, POSTSTATUS.SPAM
    ]:
        abort(410)
    jobview = UserJobView.query.get((post.id, g.user.id))
    if jobview is None:
        jobview = UserJobView(user=g.user, jobpost=post, applied=True)
        post.uncache_viewcounts('opened')
        cache.delete_memoized(viewstats_by_id_qhour, post.id)
        cache.delete_memoized(viewstats_by_id_hour, post.id)
        cache.delete_memoized(viewstats_by_id_day, post.id)
        db.session.add(jobview)
        try:
            db.session.commit()
        except IntegrityError:
            db.session.rollback()
            pass  # User double-clicked. Ignore.
        post.viewcounts  # Re-populate cache
    elif not jobview.applied:
        jobview.applied = True
        post.uncache_viewcounts('opened')
        cache.delete_memoized(viewstats_by_id_qhour, post.id)
        cache.delete_memoized(viewstats_by_id_hour, post.id)
        cache.delete_memoized(viewstats_by_id_day, post.id)
        db.session.commit()
        post.viewcounts  # Re-populate cache
    if request.is_xhr:
        return redactemail(post.how_to_apply)
    else:
        return redirect(post.url_for(), 303)
예제 #5
0
def revealjob(domain, hashid):
    """
    This view is a GET request and that is intentional.
    """
    post = JobPost.query.filter_by(hashid=hashid).first_or_404()
    # If the domain doesn't match, redirect to correct URL
    if post.email_domain != domain:
        return redirect(post.url_for('reveal'), code=301)

    if post.status in [POSTSTATUS.REJECTED, POSTSTATUS.WITHDRAWN, POSTSTATUS.SPAM]:
        abort(410)
    jobview = UserJobView.query.get((post.id, g.user.id))
    if jobview is None:
        jobview = UserJobView(user=g.user, jobpost=post, applied=True)
        post.uncache_viewcounts('opened')
        cache.delete_memoized(viewstats_by_id_qhour, post.id)
        cache.delete_memoized(viewstats_by_id_hour, post.id)
        cache.delete_memoized(viewstats_by_id_day, post.id)
        db.session.add(jobview)
        try:
            db.session.commit()
        except IntegrityError:
            db.session.rollback()
            pass  # User double-clicked. Ignore.
        post.viewcounts  # Re-populate cache
    elif not jobview.applied:
        jobview.applied = True
        post.uncache_viewcounts('opened')
        cache.delete_memoized(viewstats_by_id_qhour, post.id)
        cache.delete_memoized(viewstats_by_id_hour, post.id)
        cache.delete_memoized(viewstats_by_id_day, post.id)
        db.session.commit()
        post.viewcounts  # Re-populate cache
    if request.is_xhr:
        return redactemail(post.how_to_apply)
    else:
        return redirect(post.url_for(), 303)
예제 #6
0
def hideemail_filter(data, message='[redacted]'):
    return redactemail(data, message)
예제 #7
0
 def test_redactemail(self):
     message = "Send email to [email protected] and you are all set."
     expected_message = "Send email to [redacted] and you are all set."
     assert redactemail(message) == expected_message