예제 #1
0
파일: views.py 프로젝트: mehmadi/comport
def home():
    form = InterestForm(request.form, csrf_enabled=False)
    if request.method == 'POST':
        if form.validate_on_submit():
            Interested.create(
                name=form.name.data,
                agency=form.agency.data,
                location=form.location.data,
                phone=form.phone.data,
                email=form.email.data,
                comments=form.comments.data)
            flash("Thank you. We will be in contact shortly.", 'success')
            return redirect(url_for('public.home'))
        else:
            flash_errors(form)
    return render_template("public/interest_form.html", interest_form=form)
예제 #2
0
def home():
    form = InterestForm(request.form, csrf_enabled=False)
    if request.method == 'POST':
        if form.validate_on_submit():
            Interested.create(name=form.name.data,
                              agency=form.agency.data,
                              location=form.location.data,
                              phone=form.phone.data,
                              email=form.email.data,
                              comments=form.comments.data)
            # send a slack notification
            send_slack_message('New Interest Form Submission!', [
                form.name.data, form.agency.data, form.location.data,
                form.phone.data, form.email.data, form.comments.data
            ])
            flash("Thank you. We will be in contact shortly.", 'success')
            return redirect(url_for('public.home'))
        else:
            flash_errors(form)
    return render_template("public/interest_form.html", interest_form=form)
예제 #3
0
 def test_comments_not_required(self):
     ''' The form does not require a non-None comment.
     '''
     form = InterestForm(name="Jean Weaver", agency="Clinton Police Department", location="Clinton, OK", phone="580-970-3338", email="*****@*****.**", comments=None)
     assert form.validate() is True
예제 #4
0
 def test_email_valid(self):
     ''' The form requires a valid email.
     '''
     form = InterestForm(name="Jean Weaver", agency="Clinton Police Department", location="Clinton, OK", phone="580-970-3338", email="jean.weaverexample.com", comments="I'm interested in Comport as an open-source tool!")
     assert form.validate() is False
     assert 'Invalid email address.' in form.email.errors
예제 #5
0
 def test_email_required(self):
     ''' The form requires a non-None email.
     '''
     form = InterestForm(name="Jean Weaver", agency="Clinton Police Department", location="Clinton, OK", phone="580-970-3338", email=None, comments="I'm interested in Comport as an open-source tool!")
     assert form.validate() is False
     assert 'This field is required.' in form.email.errors
예제 #6
0
 def test_phone_required(self):
     ''' The form requires a non-None phone.
     '''
     form = InterestForm(name="Jean Weaver", agency="Clinton Police Department", location="Clinton, OK", phone=None, email="*****@*****.**", comments="I'm interested in Comport as an open-source tool!")
     assert form.validate() is False
     assert 'This field is required.' in form.phone.errors
예제 #7
0
 def test_agency_required(self):
     ''' The form requires a non-None agency.
     '''
     form = InterestForm(name="Jean Weaver", agency=None, location="Clinton, OK", phone="580-970-3338", email="*****@*****.**", comments="I'm interested in Comport as an open-source tool!")
     assert form.validate() is False
     assert 'This field is required.' in form.agency.errors
예제 #8
0
 def test_validate_success(self):
     ''' The form validates when properly filled out.
     '''
     form = InterestForm(name="Jean Weaver", agency="Clinton Police Department", location="Clinton, OK", phone="580-970-3338", email="*****@*****.**", comments="I'm interested in Comport as an open-source tool!")
     assert form.validate() is True