diff options
Diffstat (limited to 'todolists')
-rw-r--r-- | todolists/urls.py | 7 | ||||
-rw-r--r-- | todolists/views.py | 14 |
2 files changed, 11 insertions, 10 deletions
diff --git a/todolists/urls.py b/todolists/urls.py index 187d4820..8814d65e 100644 --- a/todolists/urls.py +++ b/todolists/urls.py @@ -1,4 +1,7 @@ from django.conf.urls.defaults import patterns +from django.contrib.auth.decorators import permission_required + +from .views import DeleteTodolist urlpatterns = patterns('todolists.views', (r'^$', 'list'), @@ -6,8 +9,8 @@ urlpatterns = patterns('todolists.views', (r'^add/$', 'add'), (r'^edit/(?P<list_id>\d+)/$', 'edit'), (r'^flag/(\d+)/(\d+)/$', 'flag'), - (r'^delete/(?P<object_id>\d+)/$', - 'delete_todolist'), + (r'^delete/(?P<pk>\d+)/$', + permission_required('main.delete_todolist')(DeleteTodolist.as_view())), ) # vim: set ts=4 sw=4 et: diff --git a/todolists/views.py b/todolists/views.py index 6bd456ae..a2029be0 100644 --- a/todolists/views.py +++ b/todolists/views.py @@ -7,7 +7,7 @@ from django.contrib.auth.decorators import login_required, permission_required from django.db import transaction from django.db.models import Count from django.views.decorators.cache import never_cache -from django.views.generic.create_update import delete_object +from django.views.generic import DeleteView from django.views.generic.simple import direct_to_template from django.template import Context, loader from django.utils import simplejson @@ -109,13 +109,11 @@ def edit(request, list_id): } return direct_to_template(request, 'general_form.html', page_dict) -@permission_required('main.delete_todolist') -@never_cache -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/') - +class DeleteTodolist(DeleteView): + model = Todolist + # model in main == assumes name 'main/todolist_confirm_delete.html' + template_name = 'todolists/todolist_confirm_delete.html' + success_url = '/todo/' @transaction.commit_on_success def create_todolist_packages(form, creator=None): |