diff options
author | Ismael Carnales <icarnales@gmail.com> | 2009-10-30 22:08:37 +0100 |
---|---|---|
committer | Ismael Carnales <icarnales@gmail.com> | 2009-11-10 01:24:43 +0100 |
commit | 046b4543a4ceaf4cfe6736443d4a7e453b5bf14b (patch) | |
tree | aa707c627d484b1d3f27f1d2c8368cd81b9909d0 | |
parent | 680d9d30dffeb82db6feb26f3f10a7c8645ec879 (diff) | |
download | archweb-046b4543a4ceaf4cfe6736443d4a7e453b5bf14b.tar.gz archweb-046b4543a4ceaf4cfe6736443d4a7e453b5bf14b.tar.xz |
made every public view return a RequestContext
RequestContexts are needed to check if the user is logged in
NOTE: Generic views as direct_to_template and object_list always return
a request context, so is good to use them :)
Later will add a render_template shortcut that adds the RequestContext
automatically
-rw-r--r-- | public/views.py | 30 | ||||
-rw-r--r-- | templates/public/projects.html | 2 |
2 files changed, 19 insertions, 13 deletions
diff --git a/public/views.py b/public/views.py index a1010b4..30fb290 100644 --- a/public/views.py +++ b/public/views.py @@ -14,17 +14,21 @@ def index(request): '-last_update')[:15], 'repos': Repo.objects.all() } - return render_to_response('public/index.html', RequestContext(request, - context)) + return render_to_response('public/index.html', context, + context_instance=RequestContext(request)) + def projects(request): - projects = ExternalProject.objects.all() - return render_to_response('public/projects.html', {'projects': projects}) + return list_detail.object_list(request, + ExternalProject.objects.all(), + template_name="public/projects.html", + template_object_name="project") def developers(request): devs = User.objects.filter(is_active=True).exclude(userprofile_user__roles="Trusted User").order_by('username') tus = User.objects.filter(is_active=True, userprofile_user__roles="Trusted User").order_by('username') - return render_to_response('public/developers.html', - {'developers': devs, 'tus': tus}) + return render_to_response('public/developers.html', + {'developers': devs, 'tus': tus}, + context_instance=RequestContext(request)) def fellows(request): return list_detail.object_list(request, @@ -40,12 +44,14 @@ def donate(request): donor_count = Donor.objects.count() donors = Donor.objects.order_by('name') splitval = donor_count / 4 - slice1 = donors[:splitval] - slice2 = donors[(splitval):(splitval*2)] - slice3 = donors[(splitval*2):(donor_count-splitval)] - slice4 = donors[(donor_count-splitval):donor_count] - return render_to_response('public/donate.html', - {'slice1':slice1,'slice2':slice2,'slice3':slice3,'slice4':slice4}) + context = { + 'slice1': donors[:splitval], + 'slice2': donors[(splitval):(splitval*2)], + 'slice3': donors[(splitval*2):(donor_count-splitval)], + 'slice4': donors[(donor_count-splitval):donor_count], + } + return render_to_response('public/donate.html', context, + context_instance=RequestContext(request)) def download(request): qset = MirrorUrl.objects.filter( diff --git a/templates/public/projects.html b/templates/public/projects.html index c6ff271..5fd1fa2 100644 --- a/templates/public/projects.html +++ b/templates/public/projects.html @@ -7,7 +7,7 @@ <p>There are a few Arch-based projects or communities that have sprung up over the years. Here's a list of the ones we know about.</p> <table cellspacing="20"> - {% for project in projects %} + {% for project in project_list %} <tr> <td><a href="{{project.url}}">{{project.name}}</a></td> <td>{{project.description}}</td> |