summaryrefslogtreecommitdiffstats
path: root/todolists
diff options
context:
space:
mode:
authoreliott <eliott@cactuswax.net>2007-12-30 00:34:02 +0100
committereliott <eliott@cactuswax.net>2007-12-30 00:34:02 +0100
commit15ceff77fef19819cba43e866938311aeffd0732 (patch)
tree16903554adbb32300aad9a5b3d647679710e9302 /todolists
parentd1cc0f54a490e5eacf07107e461672979266f461 (diff)
downloadarchweb-15ceff77fef19819cba43e866938311aeffd0732.tar.gz
archweb-15ceff77fef19819cba43e866938311aeffd0732.tar.xz
Modified render_template and renamed it to render_response (consistent with
archweb_pub conventions). Moved pkgmaint_guide to a template.
Diffstat (limited to 'todolists')
-rw-r--r--todolists/views.py77
1 files changed, 38 insertions, 39 deletions
diff --git a/todolists/views.py b/todolists/views.py
index 757a35a..225da15 100644
--- a/todolists/views.py
+++ b/todolists/views.py
@@ -2,7 +2,7 @@ from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.contrib.auth.decorators import login_required, user_passes_test
from django.contrib.auth.models import User
-from archweb_dev.utils import render_template
+from archweb_dev.lib.utils import render_response
from archweb_dev.todolists.models import Todolist, TodolistPkg
from archweb_dev.packages.models import Package
@@ -13,52 +13,51 @@ IntegrityError = django.db.backend.Database.IntegrityError
@login_required
#@is_maintainer
def flag(request, listid, pkgid):
- list = get_object_or_404(Todolist, id=listid)
- pkg = get_object_or_404(TodolistPkg, id=pkgid)
- pkg.complete = not pkg.complete
- pkg.save()
- return HttpResponseRedirect('/todo/%s/' % (listid))
+ list = get_object_or_404(Todolist, id=listid)
+ pkg = get_object_or_404(TodolistPkg, id=pkgid)
+ pkg.complete = not pkg.complete
+ pkg.save()
+ return HttpResponseRedirect('/todo/%s/' % (listid))
@login_required
def view(request, listid):
- list = get_object_or_404(Todolist, id=listid)
- pkgs = TodolistPkg.objects.filter(list=list.id).order_by('pkg')
- return render_template('todolists/view.html', request, {'list':list,'pkgs':pkgs})
+ list = get_object_or_404(Todolist, id=listid)
+ pkgs = TodolistPkg.objects.filter(list=list.id).order_by('pkg')
+ return render_response(request, 'todolists/view.html', {'list':list,'pkgs':pkgs})
@login_required
def list(request):
- lists = Todolist.objects.order_by('-date_added')
- for l in lists:
- l.complete = TodolistPkg.objects.filter(list=l.id,complete=False).count() == 0
- return render_template('todolists/list.html', request, {'lists':lists})
+ lists = Todolist.objects.order_by('-date_added')
+ for l in lists:
+ l.complete = TodolistPkg.objects.filter(list=l.id,complete=False).count() == 0
+ return render_response(request, 'todolists/list.html', {'lists':lists})
@login_required
#@is_maintainer
@user_passes_test(lambda u: u.has_perm('todolists.add_todolist'))
def add(request):
- if request.POST:
- try:
- m = User.objects.get(username=request.user.username)
- except User.DoesNotExist:
- return render_template('error_page.html', request,
- {'errmsg': 'Cannot find a maintainer record for you!'})
- # create the list
- todo = Todolist(
- creator = m,
- name = request.POST.get('name'),
- description = request.POST.get('description'))
- todo.save()
- # now link in packages
- for p in request.POST.get('packages').split("\n"):
- for pkg in Package.objects.filter(pkgname=p.strip()):
- todopkg = TodolistPkg(
- list = todo,
- pkg = pkg)
- try:
- todopkg.save()
- except IntegrityError, (num, desc):
- if num == 1062: # duplicate entry aka dupe package on list
- pass
- return HttpResponseRedirect('/todo/')
-
- return render_template('todolists/add.html', request)
+ if request.POST:
+ try:
+ m = User.objects.get(username=request.user.username)
+ except User.DoesNotExist:
+ return render_response(request, 'error_page.html',
+ {'errmsg': 'Cannot find a maintainer record for you!'})
+ # create the list
+ todo = Todolist(
+ creator = m,
+ name = request.POST.get('name'),
+ description = request.POST.get('description'))
+ todo.save()
+ # now link in packages
+ for p in request.POST.get('packages').split("\n"):
+ for pkg in Package.objects.filter(pkgname=p.strip()):
+ todopkg = TodolistPkg(
+ list = todo,
+ pkg = pkg)
+ try:
+ todopkg.save()
+ except IntegrityError, (num, desc):
+ if num == 1062: # duplicate entry aka dupe package on list
+ pass
+ return HttpResponseRedirect('/todo/')
+ return render_response(request, 'todolists/add.html')