Skip to content

Commit

Permalink
Displaying the form and validating errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fsouza committed Apr 28, 2011
1 parent a983e2e commit b2127bf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion dojomap/templates/new_dojo.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
{% endblock %}

{% block content %}
{% from '/macros.html' import render_field %}
<form action="" id="new-dojo" method="post" accept-charset="utf-8">
<p><input type="submit" value="Save"/></p>
{{ form.hidden_tag() }}
{{ render_field(form.name) }}
{{ render_field(form.description) }}
{{ render_field(form.address) }}
<div><input type="submit" value="Save"/></div>
</form>
{% endblock %}
3 changes: 2 additions & 1 deletion dojomap/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

@app.route('/dojo/new')
def new_dojo():
return render_template("new_dojo.html")
form = DojoForm()
return render_template("new_dojo.html", form=form)

@app.route('/dojo/new', methods=['POST'])
def create_dojo():
Expand Down
6 changes: 6 additions & 0 deletions tests/acceptance/test_add_dojo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ def test_form_add_dojo(self):
"Should show a form on /dojo/new url"
self.browser.visit(get_url("/dojo/new"))
assert self.browser.is_element_present_by_css('form#new-dojo')

def test_unable_to_save_with_invalid_data(self):
"Should be unable to save a dojo when providing invalid data"
self.browser.visit(get_url("/dojo/new"))
self.browser.find_by_css('input[type=submit]').first.click()
assert self.browser.is_element_present_by_css('.validation-errors')

0 comments on commit b2127bf

Please sign in to comment.