Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a page for groups

  • Loading branch information...
commit acc61ac64bbd61824d8abb2324318b9fb6179e6c 1 parent 3469420
@mdiep authored
View
2  poplar/templates/poplar/base.html
@@ -19,7 +19,7 @@
<h3>Groups</h3>
<ul class='links'>
{% for group in groups %}
- <li>{{ group }}</li>
+ <li><a href='{% url group group.slug %}'>{{ group }}</a></li>
{% endfor %}
</ul>
{% endblock %}
View
4 poplar/templates/poplar/everyone.html → poplar/templates/poplar/person_list.html
@@ -1,9 +1,9 @@
{% extends "poplar/base.html" %}
-{% block title %}Everyone {{ block.super }}{% endblock %}
+{% block title %}{{ title }} {{ block.super }}{% endblock %}
{% block content %}
-<h1>Everyone</h1>
+<h1>{{ title }}</h1>
<ul class='people'>
{% for person in people %}
<li><a href='{% url person person.id %}'>{{ person }}</a></li>
View
7 poplar/urls.py
@@ -2,7 +2,8 @@
from django.conf.urls.defaults import patterns, url
urlpatterns = patterns('poplar.views',
- url('^$', 'activity_feed', name='activity-feed'),
- url('^people/?$', 'everyone', name='everyone'),
- url('^people/(\d+)/?$', 'person', name='person'),
+ url('^$', 'activity_feed', name='activity-feed'),
+ url('^people/?$', 'everyone', name='everyone'),
+ url('^people/(\d+)/?$', 'person', name='person'),
+ url('^groups/([\w-]+)/?$', 'group', name='group'),
)
View
16 poplar/views.py
@@ -13,11 +13,7 @@ def activity_feed(request):
context_instance=RequestContext(request))
def everyone(request):
- people = Person.objects.all()
- groups = Group.objects.all()
- site = get_current_site(request)
- return render_to_response('poplar/everyone.html', locals(),
- context_instance=RequestContext(request))
+ return person_list(request, people=Person.objects.all(), title='Everyone')
def person(request, id):
person = get_object_or_404(Person, id=id)
@@ -25,3 +21,13 @@ def person(request, id):
site = get_current_site(request)
return render_to_response('poplar/person.html', locals(),
context_instance=RequestContext(request))
+
+def person_list(request, people, title):
+ groups = Group.objects.all()
+ site = get_current_site(request)
+ return render_to_response('poplar/person_list.html', locals(),
+ context_instance=RequestContext(request))
+
+def group(request, slug):
+ group = get_object_or_404(Group, slug=slug)
+ return person_list(request, people=group.people.all(), title=group.name)
Please sign in to comment.
Something went wrong with that request. Please try again.