bgneal@81: """
bgneal@81: Views for the forums application.
bgneal@81: """
bgneal@81: from django.shortcuts import render_to_response
bgneal@81: from django.template import RequestContext
bgneal@81: 
bgneal@81: from forums.models import Forum
bgneal@81: 
bgneal@81: 
bgneal@81: def index(request):
bgneal@81:     forums = Forum.objects.all().select_related()
bgneal@81:     cats = {}
bgneal@81:     for forum in forums:
bgneal@81:         cat = cats.setdefault(forum.category.id, {
bgneal@81:             'cat': forum.category,
bgneal@81:             'forums': [],
bgneal@81:             })
bgneal@81:         cat['forums'].append(forum)
bgneal@81: 
bgneal@81:     cmpdef = lambda a, b: cmp(a['cat'].position, b['cat'].position)
bgneal@81:     cats = sorted(cats.values(), cmpdef)
bgneal@81: 
bgneal@81:     return render_to_response('forums/index.html', {
bgneal@81:         'cats': cats,
bgneal@81:         },
bgneal@81:         context_instance=RequestContext(request))
bgneal@81: 
bgneal@81: def forum_index(request, slug):
bgneal@81:     pass