예제 #1
0
파일: update.py 프로젝트: dineshk22/hasjob
def confirm(hashid):
    post = JobPost.query.filter_by(hashid=hashid).first_or_404()
    form = forms.ConfirmForm()
    if post.status == POSTSTATUS.REJECTED:
        abort(410)
    elif post.status == POSTSTATUS.DRAFT:
        if post.edit_key not in session.get('userkeys', []):
            abort(403)
    else:
        # Any other status: no confirmation required (via this handler)
        return redirect(url_for('jobdetail', hashid=post.hashid), code=302)
    if 'form.id' in request.form and form.validate_on_submit():
        # User has accepted terms of service. Now send email and/or wait for payment
        if not post.email_sent:
            msg = Message(
                subject=
                "Confirmation of your job listing at the HasGeek Job Board",
                recipients=[post.email])
            msg.body = render_template("confirm_email.md", post=post)
            msg.html = markdown(msg.body)
            mail.send(msg)
            post.email_sent = True
            post.status = POSTSTATUS.PENDING
            db.session.commit()
        session.get('userkeys', []).remove(post.edit_key)
        session.modified = True  # Since it won't detect changes to lists
        session.permanent = True
        return render_template('mailsent.html', post=post)
    return render_template('confirm.html', post=post, form=form)
예제 #2
0
def confirm(hashid):
    post = JobPost.query.filter_by(hashid=hashid).first_or_404()
    form = forms.ConfirmForm()
    if post.status in [POSTSTATUS.REJECTED, POSTSTATUS.SPAM]:
        abort(410)
    elif post.status in [POSTSTATUS.DRAFT, POSTSTATUS.PENDING]:
        if not (post.edit_key in session.get('userkeys', [])
                or post.admin_is(g.user)):
            abort(403)
    else:
        # Any other status: no confirmation required (via this handler)
        return redirect(url_for('jobdetail', hashid=post.hashid), code=302)
    if 'form.id' in request.form and form.validate_on_submit():
        # User has accepted terms of service. Now send email and/or wait for payment
        # Also (re-)set the verify key, just in case they changed their email
        # address and are re-verifying
        post.email_verify_key = random_long_key()
        msg = Message(subject="Confirmation of your job listing at Hasjob",
                      recipients=[post.email])
        msg.body = render_template("confirm_email.md", post=post)
        msg.html = markdown(msg.body)
        mail.send(msg)
        post.email_sent = True
        post.status = POSTSTATUS.PENDING
        db.session.commit()

        try:
            session.get('userkeys', []).remove(post.edit_key)
            session.modified = True  # Since it won't detect changes to lists
        except ValueError:
            pass
        return render_template('mailsent.html', post=post)
    return render_template('confirm.html', post=post, form=form)
예제 #3
0
def confirm(domain, hashid):
    post = JobPost.query.filter_by(hashid=hashid).first_or_404()
    form = forms.ConfirmForm()
    if post.status in POSTSTATUS.GONE:
        abort(410)
    elif post.status in POSTSTATUS.UNPUBLISHED and not post.admin_is(g.user):
        abort(403)
    elif post.status not in POSTSTATUS.UNPUBLISHED:
        # Any other status: no confirmation required (via this handler)
        return redirect(post.url_for(), code=302)

    # We get here if it's (a) POSTSTATUS.UNPUBLISHED and (b) the user is confirmed authorised
    if 'form.id' in request.form and form.validate_on_submit():
        # User has accepted terms of service. Now send email and/or wait for payment
        # Also (re-)set the verify key, just in case they changed their email
        # address and are re-verifying
        post.email_verify_key = random_long_key()
        msg = Message(subject="Confirmation of your job post at Hasjob",
                      recipients=[post.email])
        msg.body = render_template("confirm_email.md", post=post)
        msg.html = markdown(msg.body)
        mail.send(msg)
        post.email_sent = True
        post.status = POSTSTATUS.PENDING
        db.session.commit()

        return render_template('mailsent.html', post=post)
    return render_template('confirm.html', post=post, form=form)
예제 #4
0
파일: listing.py 프로젝트: thuannvn/hasjob
def confirm(domain, hashid):
    post = JobPost.query.filter_by(hashid=hashid).first_or_404()
    form = forms.ConfirmForm()
    if post.status in POSTSTATUS.GONE:
        abort(410)
    elif post.status in POSTSTATUS.UNPUBLISHED and not post.admin_is(g.user):
            abort(403)
    elif post.status not in POSTSTATUS.UNPUBLISHED:
        # Any other status: no confirmation required (via this handler)
        return redirect(post.url_for(), code=302)

    # We get here if it's (a) POSTSTATUS.UNPUBLISHED and (b) the user is confirmed authorised
    if 'form.id' in request.form and form.validate_on_submit():
        # User has accepted terms of service. Now send email and/or wait for payment
        msg = Message(subject="Confirmation of your job post at Hasjob",
            recipients=[post.email])
        msg.html = email_transform(render_template('confirm_email.html', post=post), base_url=request.url_root)
        msg.body = html2text(msg.html)
        mail.send(msg)
        post.email_sent = True
        post.status = POSTSTATUS.PENDING
        db.session.commit()

        footer_campaign = Campaign.for_context(CAMPAIGN_POSITION.AFTERPOST, board=g.board, user=g.user,
                    anon_user=g.anon_user, geonameids=g.user_geonameids)

        return render_template('mailsent.html', footer_campaign=footer_campaign)
    return render_template('confirm.html', post=post, form=form)