Skip to content

Commit 9487c3f

Browse files
committed
unified all three projects list views
1 parent 2a52d56 commit 9487c3f

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

anthill/projects/urls.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99

1010
urlpatterns += patterns('anthill.projects.views',
1111
url(r'^$', 'projects_and_ideas', name='projects_and_ideas'),
12-
url(r'^all/$', 'archive', name='projects_archive'),
13-
url(r'^official/$', 'official_projects', name='official_projects'),
12+
url(r'^all/$', 'archive', name='all_projects'),
13+
url(r'^official/$', 'archive', {'projects':'official'},
14+
name='official_projects'),
15+
url(r'^community/$', 'archive', {'projects':'community'},
16+
name='community_projects'),
1417
url(r'^asks/$', 'ask_list', name='all_project_asks'),
1518
url(r'^new/$', 'new_project', name='new_project'),
1619
url(r'^tag/(?P<tag>[^/]+)/$', 'tag_archive', name='projects_tagged'),

anthill/projects/views.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,17 @@ def projects_and_ideas(request):
2020
return render_to_response('projects/projects_and_ideas.html', context,
2121
context_instance=RequestContext(request))
2222

23-
def archive(request):
23+
def archive(request, projects='all'):
2424
qs = Project.objects.select_related().all()
25+
if projects == 'official':
26+
qs = qs.filter(official=True)
27+
elif projects == 'community':
28+
qs = qs.filter(official=False)
2529
if hasattr(qs, '_gatekeeper'):
2630
qs = qs.approved()
2731
return object_list(request, queryset=qs,
2832
template_object_name='project', allow_empty=True,
29-
paginate_by=10)
30-
31-
def official_projects(request):
32-
qs = Project.objects.select_related().filter(official=True)
33-
if hasattr(qs, '_gatekeeper'):
34-
qs = qs.approved()
35-
return object_list(request, queryset=qs,
36-
template_object_name='project', allow_empty=True,
37-
extra_context={'official':True}, paginate_by=10)
33+
extra_context={'projects':projects}, paginate_by=10)
3834

3935
def tag_archive(request, tag):
4036
qs = Project.objects.select_related()

0 commit comments

Comments
 (0)