Skip to content

Commit

Permalink
Merge branch 'master' of github.com:tarsis/djangodash2011
Browse files Browse the repository at this point in the history
  • Loading branch information
fsouza committed Jul 30, 2011
2 parents 06b1ee5 + ee09277 commit 3bfab7c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions manouche_us/project/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ def clean_url(self):
self.instance.url = self.data['url']
if not self.instance.validate_url():
raise ValidationError("Url should be from github.com! I'm a fanboy :D")

return self.cleaned_data['url']
1 change: 1 addition & 0 deletions manouche_us/project/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ <h1>Manouche Us</h1>

<form action="/" method="post" accept-charset="utf-8" class="grid_6 column">
{% csrf_token %}

{{ form.as_p }}
<input type="submit" value="Continue &rarr;"/>
</form>
Expand Down
14 changes: 12 additions & 2 deletions manouche_us/project/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@


class TestViews(unittest.TestCase):
def setUp(self):
self.client = Client()

def test_index_view(self):
request_factory = RequestFactory()
request = request_factory.post("/")
Expand All @@ -14,9 +17,16 @@ def test_index_view(self):

def test_error_when_url_is_not_github(self):
url = "http://foo.com"
client = Client()
response = client.post("/", {"url": url})
response = self.client.post("/", {"url": url})

form_erros = response.context[0].get('form').errors
self.assertEquals(form_erros, {'url': [u"Url should be from github.com! I\'m a fanboy :D"]})

def test_submit_a_project(self):
url = 'http://github.com/tarsis/'
response = self.client.post('/', {"url": url})

location = response.items()[1]
self.assertEquals(302, response.status_code)
self.assertEquals(('Location', 'http://testserver/wait/'), location)

2 changes: 2 additions & 0 deletions manouche_us/project/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.template.response import TemplateResponse
from django.http import HttpResponseRedirect

from project.forms import SubmitProjectForm

Expand All @@ -8,6 +9,7 @@ def index(request):
form = SubmitProjectForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect("/wait/")
else:
form = SubmitProjectForm()

Expand Down

0 comments on commit 3bfab7c

Please sign in to comment.