summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDusty Phillips <buchuki@gmail.com>2008-10-11 00:00:35 +0200
committerDusty Phillips <buchuki@gmail.com>2008-10-11 00:00:35 +0200
commit82edf2d07b5c8d9122fca2a6901df81fb510be5b (patch)
tree3f3ab1d4d081fd4ad352fbb0bc799ad8fbf8a62c
parentd5cb786f44580c1389093e341d14e1407aac23f0 (diff)
downloadarchweb-82edf2d07b5c8d9122fca2a6901df81fb510be5b.tar.gz
archweb-82edf2d07b5c8d9122fca2a6901df81fb510be5b.tar.xz
port to django 1.0
-rw-r--r--todolists/views.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/todolists/views.py b/todolists/views.py
index 4553114..cd02c86 100644
--- a/todolists/views.py
+++ b/todolists/views.py
@@ -4,14 +4,11 @@ from django.http import HttpResponseRedirect
from django.core.mail import send_mail
from django.shortcuts import get_object_or_404
from django.contrib.auth.decorators import permission_required
+from django.views.generic.create_update import delete_object
from django.template import Context, loader
from archweb_dev.main.utils import render_response
from archweb_dev.main.models import Todolist, TodolistPkg, Package
-# FIXME: ugly hackery. http://code.djangoproject.com/ticket/3450
-import django.db
-IntegrityError = django.db.backend.Database.IntegrityError
-
class TodoListForm(forms.Form):
name = forms.CharField(max_length=255,
widget=forms.TextInput(attrs={'size': '30'}))
@@ -23,7 +20,7 @@ class TodoListForm(forms.Form):
def clean_packages(self):
package_names = [s.strip() for s in
- self.clean_data['packages'].split("\n")]
+ self.cleaned_data['packages'].split("\n")]
package_names = set(package_names)
packages = Package.objects.filter(
pkgname__in=package_names).exclude(repo__name="Testing").order_by('arch')
@@ -58,10 +55,10 @@ def add(request):
if form.is_valid():
todo = Todolist.objects.create(
creator = request.user,
- name = form.clean_data['name'],
- description = form.clean_data['description'])
+ name = form.cleaned_data['name'],
+ description = form.cleaned_data['description'])
- for pkg in form.clean_data['packages']:
+ for pkg in form.cleaned_data['packages']:
tpkg = TodolistPkg.objects.create(list = todo, pkg = pkg)
send_todolist_email(tpkg)
@@ -82,19 +79,19 @@ def edit(request, list_id):
if request.POST:
form = TodoListForm(request.POST)
if form.is_valid():
- todo_list.name = form.clean_data['name']
- todo_list.description = form.clean_data['description']
+ todo_list.name = form.cleaned_data['name']
+ todo_list.description = form.cleaned_data['description']
todo_list.save()
packages = [p.pkg for p in todo_list.packages]
# first delete any packages not in the new list
for p in todo_list.packages:
- if p.pkg not in form.clean_data['packages']:
+ if p.pkg not in form.cleaned_data['packages']:
p.delete()
# now add any packages not in the old list
- for pkg in form.clean_data['packages']:
+ for pkg in form.cleaned_data['packages']:
if pkg not in packages:
tpkg = TodolistPkg.objects.create(
list = todo_list, pkg = pkg)
@@ -114,6 +111,11 @@ def edit(request, list_id):
}
return render_response(request, 'general_form.html', page_dict)
+@permission_required('main.delete_todolist')
+def delete_todolist(request, object_id):
+ return delete_object(request, object_id=object_id, model=Todolist,
+ template_name="todolists/todolist_confirm_delete.html",
+ post_delete_redirect='/todo/')
def send_todolist_email(todo):
'''Sends an e-mail to the maintainer of a package notifying them that the