Commit a96489fa authored by Claude Paroz's avatar Claude Paroz

Replace people list view by a class-based view and add test for it

parent 22a96363
......@@ -28,6 +28,13 @@ from people import forms
class PeopleTestCase(TestCase):
def _create_person(self):
pn = Person(first_name='John', last_name='Nothing',
email='', username= 'jn')
return pn
def test_register(self):
response ='register'),
{'username': u'test01', 'password1': u'1234567',
......@@ -35,11 +42,14 @@ class PeopleTestCase(TestCase):
self.assertRedirects(response, reverse('register_success'))
self.assertEqual(Person.objects.filter(username=u'test01').count(), 1)
def test_person_list(self): = self._create_person()
response = self.client.get(reverse('people'))
self.assertContains(response, "GNOME is being developed by following people:")
self.assertContains(response, "John Nothing")
def test_edit_details(self): = Person(first_name='John', last_name='Nothing',
email='', username= 'jn')'password') = self._create_person()
self.client.login(username='jn', password='password')
post_data = {
'first_name': "Johnny", 'last_name': "Nothing", 'email': u'',
from django.conf.urls.defaults import *
from people.models import Person
info_dict_list = {
'queryset': Person.objects.all(),
'template_object_name': 'person',
'extra_context': {
'pageSection': "teams"
from people.views import PeopleListView
# Regex order is really important here
urlpatterns = patterns('people.views',
......@@ -38,10 +32,6 @@ urlpatterns = patterns('people.views',
urlpatterns += patterns('django.views.generic.list_detail',
regex = r'^$',
view = 'object_list',
kwargs = dict(info_dict_list),
name = 'people'),
urlpatterns += patterns('',
url(r'^$', PeopleListView.as_view(), name='people'),
......@@ -33,12 +33,23 @@ from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from django.utils import formats
from django.utils.translation import ugettext_lazy, ugettext as _
from django.views.generic import ListView
from people.models import Person
from teams.models import Team, Role
from people.forms import TeamJoinForm, DetailForm
from vertimus.models import StateDb
class PeopleListView(ListView):
model = Person
def get_context_data(self, **kwargs):
context = super(PeopleListView, self).get_context_data(**kwargs)
context['pageSection'] = "teams"
return context
def person_detail(request, person_id=None, person_username=None):
if person_id:
person = get_object_or_404(Person, pk=person_id)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment