-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added ability to repost an archived job
- Loading branch information
1 parent
e368b58
commit 03143f2
Showing
4 changed files
with
55 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -354,6 +354,34 @@ def validate(self): | |
self.send_signals() | ||
return success | ||
|
||
def populate(self, post): | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jace
Member
|
||
self.job_headline.data = post.headline | ||
self.job_headlineb.data = post.headlineb | ||
self.job_type.data = post.type_id | ||
self.job_category.data = post.category_id | ||
self.job_location.data = post.location | ||
self.job_relocation_assist.data = post.relocation_assist | ||
self.job_description.data = post.description | ||
self.job_perks.data = True if post.perks else False | ||
self.job_perks_description.data = post.perks | ||
self.job_how_to_apply.data = post.how_to_apply | ||
self.company_name.data = post.company_name | ||
self.company_url.data = post.company_url | ||
self.poster_email.data = post.email | ||
self.twitter.data = post.twitter | ||
self.hr_contact.data = int(post.hr_contact or False) | ||
self.collaborators.data = post.admins | ||
self.job_pay_type.data = post.pay_type | ||
if post.pay_type is None: | ||
# This kludge required because WTForms doesn't know how to handle None in forms | ||
self.job_pay_type.data = -1 | ||
self.job_pay_currency.data = post.pay_currency | ||
self.job_pay_cash_min.data = post.pay_cash_min | ||
self.job_pay_cash_max.data = post.pay_cash_max | ||
self.job_pay_equity.data = bool(post.pay_equity_min and post.pay_equity_max) | ||
self.job_pay_equity_min.data = post.pay_equity_min | ||
self.job_pay_equity_max.data = post.pay_equity_max | ||
|
||
|
||
class ApplicationForm(forms.Form): | ||
apply_email = forms.RadioField("Email", validators=[forms.validators.DataRequired("Pick an email address")], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -886,36 +886,7 @@ def editjob(hashid, key, domain=None, form=None, validated=False, newpost=None): | |
elif request.method == 'POST': | ||
flash("Please review the indicated issues", category='interactive') | ||
elif request.method == 'GET': | ||
# Populate form from model | ||
form.job_headline.data = post.headline | ||
form.job_headlineb.data = post.headlineb | ||
form.job_type.data = post.type_id | ||
form.job_category.data = post.category_id | ||
form.job_location.data = post.location | ||
form.job_relocation_assist.data = post.relocation_assist | ||
form.job_description.data = post.description | ||
form.job_perks.data = True if post.perks else False | ||
form.job_perks_description.data = post.perks | ||
form.job_how_to_apply.data = post.how_to_apply | ||
form.company_name.data = post.company_name | ||
form.company_url.data = post.company_url | ||
# form.poster_name.data = post.fullname # Deprecated 2013-11-20 | ||
form.poster_email.data = post.email | ||
form.twitter.data = post.twitter | ||
form.hr_contact.data = int(post.hr_contact or False) | ||
form.collaborators.data = post.admins | ||
|
||
form.job_pay_type.data = post.pay_type | ||
if post.pay_type is None: | ||
# This kludge required because WTForms doesn't know how to handle None in forms | ||
form.job_pay_type.data = -1 | ||
form.job_pay_currency.data = post.pay_currency | ||
form.job_pay_cash_min.data = post.pay_cash_min | ||
form.job_pay_cash_max.data = post.pay_cash_max | ||
form.job_pay_equity.data = bool(post.pay_equity_min and post.pay_equity_max) | ||
form.job_pay_equity_min.data = post.pay_equity_min | ||
form.job_pay_equity_max.data = post.pay_equity_max | ||
|
||
form.populate(post) | ||
This comment has been minimized.
Sorry, something went wrong. |
||
return render_template('postjob.html', form=form, no_email=no_email) | ||
|
||
|
||
|
@@ -924,6 +895,8 @@ def editjob(hashid, key, domain=None, form=None, validated=False, newpost=None): | |
@app.route('/new', methods=('GET', 'POST')) | ||
def newjob(): | ||
form = forms.ListingForm() | ||
repost = False | ||
This comment has been minimized.
Sorry, something went wrong. |
||
archived_post = None | ||
if not g.user: | ||
if request.method == 'POST' and request.form.get('form.id') == 'newheadline': | ||
session['headline'] = form.job_headline.data | ||
|
@@ -953,6 +926,17 @@ def newjob(): | |
if g.user: | ||
# form.poster_name.data = g.user.fullname # Deprecated 2013-11-20 | ||
form.poster_email.data = g.user.email | ||
|
||
if request.method == 'GET' and request.args.get('template'): | ||
archived_post = JobPost.query.filter_by(hashid=request.args.get('template')).first() | ||
This comment has been minimized.
Sorry, something went wrong. |
||
if not archived_post or not archived_post.admin_is(g.user): | ||
abort(403) | ||
if not archived_post.is_old(): | ||
flash("This listing is already active.") | ||
This comment has been minimized.
Sorry, something went wrong.
jace
Member
|
||
return redirect(archived_post.url_for(), code=303) | ||
form.populate(archived_post) | ||
repost = True | ||
|
||
if request.method == 'POST' and request.form.get('form.id') != 'newheadline' and form.validate(): | ||
# POST request from new job page, with successful validation | ||
# Move it to the editjob page for handling here forward | ||
|
@@ -971,4 +955,4 @@ def newjob(): | |
# 1. GET request, page loaded for the first time | ||
# 2. POST request from main page's Post a Job box | ||
# 3. POST request from this page, with errors | ||
return render_template('postjob.html', form=form, no_removelogo=True) | ||
return render_template('postjob.html', form=form, no_removelogo=True, repost=repost, archived_post=archived_post) |
This method is required only because the form's fields don't have the same names as the model's columns. Good time to ask if we should fix that. Caveat is that in
/new
and/edit
we don't copy all fields as is from form to post and vice versa, so it'll require moving all that validation logic either into the form or the model.