diff --git a/.gitignore b/.gitignore index 8ab0817d3..a7113d91f 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ baseframe-packed.css editor.packed.css uploads/ search/ +hasjob/static/gen diff --git a/hasjob/forms.py b/hasjob/forms.py index 4d62195ab..c166cfc3b 100644 --- a/hasjob/forms.py +++ b/hasjob/forms.py @@ -6,7 +6,7 @@ from flask import g, request, Markup from baseframe.forms import (Form, ValidEmail, ValidUrl, AllUrlsValid, TinyMce4Field, UserSelectMultiField, - AnnotatedTextField, FormField, NullTextField, ValidName) + AnnotatedTextField, FormField, NullTextField, ValidName, NoObfuscatedEmail) from baseframe.forms.sqlalchemy import AvailableName from wtforms import (TextField, TextAreaField, RadioField, FileField, BooleanField, ValidationError, validators) @@ -68,7 +68,8 @@ class ListingForm(Form): job_headline = TextField("Headline", description="A single-line summary. This goes to the front page and across the network", validators=[validators.Required("A headline is required"), - validators.Length(min=1, max=100, message="%(max)d characters maximum")]) + validators.Length(min=1, max=100, message="%(max)d characters maximum"), + NoObfuscatedEmail(u"Do not include contact information in the listing")]) job_type = RadioField("Type", coerce=int, validators=[validators.Required("The job type must be specified")]) job_category = RadioField("Category", coerce=int, validators=[validators.Required("Select a category")]) job_location = TextField("Location", @@ -80,13 +81,15 @@ class ListingForm(Form): content_css=content_css, description=u"Don’t just describe the job, tell a compelling story for why someone should work for you", validators=[validators.Required("A description of the job is required"), - AllUrlsValid(invalid_urls=invalid_urls)], + AllUrlsValid(invalid_urls=invalid_urls), + NoObfuscatedEmail(u"Do not include contact information in the listing")], tinymce_options={'convert_urls': True}) job_perks = BooleanField("Job perks are available") job_perks_description = TinyMce4Field("Describe job perks", content_css=content_css, description=u"Stock options, free lunch, free conference passes, etc", - validators=[AllUrlsValid(invalid_urls=invalid_urls)]) + validators=[AllUrlsValid(invalid_urls=invalid_urls), + NoObfuscatedEmail(u"Do not include contact information in the listing")]) job_pay_type = RadioField("What does this job pay?", coerce=int, choices=PAY_TYPE.items()) job_pay_currency = ListingPayCurrencyField("Currency", choices=[("INR", "INR"), ("USD", "USD"), ("EUR", "EUR")]) @@ -100,8 +103,9 @@ class ListingForm(Form): u"We now require candidates to apply through the job board only. " u"Do not include any contact information here. Candidates CANNOT " u"attach resumes or other documents, so do not ask for that", - validators=[validators.Required(u"We do not offer screening services. " - u"Please specify what candidates should submit")]) + validators=[ + validators.Required(u"We do not offer screening services. Please specify what candidates should submit"), + NoObfuscatedEmail(u"Do not include contact information in the listing")]) company_name = TextField("Name", description=u"The name of the organization where the position is. " u"No intermediaries or unnamed stealth startups. Use your own real name if the organization isn’t named " @@ -168,8 +172,6 @@ def validate_company_logo(form, field): raise ValidationError("Unsupported file format. We accept JPEG, PNG and GIF") def validate_job_headline(form, field): - if EMAIL_RE.search(field.data) is not None: - raise ValidationError(u"Do not include contact information in the listing") if simplify_text(field.data) in ( 'awesome coder wanted at awesome company', 'pragmatic programmer wanted at outstanding organisation', @@ -194,18 +196,6 @@ def validate_job_location(form, field): if small == 0 or caps / float(small) > 0.5: raise ValidationError("Surely this location isn't named in uppercase?") - def validate_job_description(form, field): - if EMAIL_RE.search(field.data) is not None: - raise ValidationError(u"Do not include contact information in the listing") - - def validate_job_perks_description(form, field): - if EMAIL_RE.search(field.data) is not None: - raise ValidationError(u"Do not include contact information in the listing") - - def validate_job_how_to_apply(form, field): - if EMAIL_RE.search(field.data) is not None or URL_RE.search(field.data) is not None: - raise ValidationError(u"Do not include contact information in the listing") - def validate_job_pay_cash_min(form, field): if form.job_pay_type.data in (PAY_TYPE.ONETIME, PAY_TYPE.RECURRING): data = field.data.strip() diff --git a/hasjob/templates/index.html b/hasjob/templates/index.html index 2da2f889a..510207731 100644 --- a/hasjob/templates/index.html +++ b/hasjob/templates/index.html @@ -115,6 +115,13 @@ $("#newpost_details").hide().removeClass('jshidden'); $("#newpost_headline").focus(function() { $("#newpost_details").slideDown(); + }).keypress(function(event) { + if(event.which == '13') { + $(this).closest("form").submit(); + return false; + } + }).blur(function() { + $(this).val($(this).val().replace(/(\r\n|\n|\r)/gm," ").replace(/\s+/g," ")); }); }); diff --git a/hasjob/views/listing.py b/hasjob/views/listing.py index 7dbb5398e..aab565f46 100644 --- a/hasjob/views/listing.py +++ b/hasjob/views/listing.py @@ -703,7 +703,7 @@ def editjob(hashid, key, form=None, post=None, validated=False): session.permanent = True return redirect(url_for('jobdetail', hashid=post.hashid), code=303) elif request.method == 'POST': - flash("Please correct the indicated errors", category='interactive') + flash("Please review the indicated issues", category='interactive') elif request.method == 'GET': # Populate form from model form.job_headline.data = post.headline