@@ -435,16 +418,19 @@
A/B test results
});
$(function() {
$("#reveal-button").on('click dblclick', function(e) {
+ var reveal_button = this;
e.preventDefault();
- $(this).attr('disabled', 'disabled');
- $.ajax($(this).attr('href')).done(function(html) {
- $("#apply-info-para").html(html);
+ $(reveal_button).attr('disabled', 'disabled');
+ $('#reveal-button + .loading').removeClass('hidden');
+ $.ajax($(reveal_button).attr('href'), {method: 'POST'}).done(function(html) {
+ $("#apply-info-para").replaceWith(html);
{%- if applyform %}
$("#apply-section").removeClass('hidden');
{%- endif %}
})
.fail(function(msg){
- $(this).removeAttr("disabled");
+ $('#reveal-button + .loading').addClass('hidden');
+ $(reveal_button).removeAttr('disabled');
});
return false;
});
@@ -469,13 +455,7 @@
A/B test results
{{ ajaxform('rejectform', request, force=true) }}
{{ ajaxform('pinnedform', request, force=true) }}
{{ ajaxform('moderateform', request, force=true) }}
-{% if applyform %}
- {{ ajaxform('applyform', request, force=true) }}
- {% assets "js_tinymce" %}{% endassets %}
-
-{% endif %}
+{% assets "js_tinymce" %}{% endassets %}
{%- if is_siteadmin or post.admin_is(g.user) or (g.user and g.user.flags.is_employer_month) %}{% with stats = post.viewstats[1], max = stats.max|tojson %}
{%- endif %}
diff --git a/hasjob/templates/jobpost_reveal.html b/hasjob/templates/jobpost_reveal.html
new file mode 100644
index 000000000..2c6e29015
--- /dev/null
+++ b/hasjob/templates/jobpost_reveal.html
@@ -0,0 +1,15 @@
+{% from "baseframe/forms.html" import ajaxform -%}
+
{{ instructions }}
+{%- if job_application %}
+
You have applied for this position
+
+ Name: {{ job_application.fullname }}
+ Email: {{ job_application.email }}
+ Phone: {{ job_application.phone }}
+
+ {{ job_application.message|safe }}
+{%- else %}
+ {%- if applyform %}
+ {% include "inc/applyform.html" %}
+ {% endif %}
+{%- endif %}
diff --git a/hasjob/views/listing.py b/hasjob/views/listing.py
index 601c8e52e..f7585257c 100644
--- a/hasjob/views/listing.py
+++ b/hasjob/views/listing.py
@@ -54,9 +54,6 @@ def jobdetail(domain, hashid):
is_siteadmin = lastuser.has_permission('siteadmin')
query = JobPost.query.filter_by(hashid=hashid).options(
db.subqueryload('locations'), db.subqueryload('taglinks'))
- # if g.user:
- # query = query.outerjoin(UserJobView,
- # db.and_(UserJobView.user_id == g.user.id, UserJobView.jobpost_id == JobPost.id))
post = query.first_or_404()
# If we're on a board (that's not 'www') and this post isn't on this board,
@@ -123,17 +120,7 @@ def jobdetail(domain, hashid):
pinnedform = forms.PinnedForm(obj=post.link_to_board(g.board))
else:
pinnedform = forms.PinnedForm(obj=post)
- applyform = None # User isn't allowed to apply unless non-None
- if g.user:
- 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
- elif g.kiosk and g.peopleflow_url:
- applyform = forms.KioskApplicationForm()
- job_application = None
- else:
- job_application = None
+
if reportform.validate_on_submit():
if g.user:
if report is None:
@@ -178,7 +165,7 @@ def jobdetail(domain, hashid):
headline = post.headlineb if is_bgroup and post.headlineb else post.headline
return render_template('detail.html', post=post, headline=headline, reportform=reportform, rejectform=rejectform,
- pinnedform=pinnedform, applyform=applyform, job_application=job_application,
+ pinnedform=pinnedform,
jobview=jobview, report=report, moderateform=moderateform,
domain_mismatch=domain_mismatch, header_campaign=header_campaign,
is_bgroup=is_bgroup, is_siteadmin=is_siteadmin
@@ -235,48 +222,53 @@ def starjob(domain, hashid):
return response
-@app.route('/
//reveal', subdomain='')
-@app.route('///reveal')
-@app.route('/reveal/', defaults={'domain': None}, subdomain='')
-@app.route('/reveal/', defaults={'domain': None})
+@csrf.exempt
+@app.route('///reveal', methods=['POST'], subdomain='')
+@app.route('///reveal', methods=['POST'])
+@app.route('/reveal/', methods=['POST'], defaults={'domain': None}, subdomain='')
+@app.route('/reveal/', methods=['POST'], defaults={'domain': None})
@lastuser.requires_login
def revealjob(domain, hashid):
"""
- This view is a GET request and that is intentional.
+ Reveal job application form
"""
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]:
+ 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)
- 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()
+ 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.
- post.viewcounts # Re-populate cache
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)
- 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)
+
+ 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)
@csrf.exempt