From 0e58a2e49f59fe41a27afa7bf8f9b3c77405c6d1 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 4 Oct 2010 16:35:31 -0500 Subject: Todo list minor fixes and comments for later When we show the edit todo list page, use a sorted list retrieved straight from the database instead of a unordered set() we create at the application level. Also add some comments for potential later improvements on transaction boundaries and async emailing. Signed-off-by: Dan McGee --- todolists/views.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'todolists') diff --git a/todolists/views.py b/todolists/views.py index 2518624..519fae9 100644 --- a/todolists/views.py +++ b/todolists/views.py @@ -68,6 +68,7 @@ def list(request): return direct_to_template(request, 'todolists/list.html', {'lists': lists}) +# TODO: this calls for transaction management and async emailing @permission_required('main.add_todolist') @never_cache def add(request): @@ -80,7 +81,7 @@ def add(request): description = form.cleaned_data['description']) for pkg in form.cleaned_data['packages']: - tpkg = TodolistPkg.objects.create(list = todo, pkg = pkg) + tpkg = TodolistPkg.objects.create(list=todo, pkg=pkg) send_todolist_email(tpkg) return redirect('/todo/') @@ -91,9 +92,10 @@ def add(request): 'title': 'Add Todo List', 'form': form, 'submit_text': 'Create List' - } + } return direct_to_template(request, 'general_form.html', page_dict) +# TODO: this calls for transaction management and async emailing @permission_required('main.change_todolist') @never_cache def edit(request, list_id): @@ -116,7 +118,7 @@ def edit(request, list_id): for pkg in form.cleaned_data['packages']: if pkg not in packages: tpkg = TodolistPkg.objects.create( - list = todo_list, pkg = pkg) + list=todo_list, pkg=pkg) send_todolist_email(tpkg) return redirect(todo_list) @@ -124,13 +126,13 @@ def edit(request, list_id): form = TodoListForm(initial={ 'name': todo_list.name, 'description': todo_list.description, - 'packages': todo_list.package_names, - }) + 'packages': '\n'.join(todo_list.package_names), + }) page_dict = { 'title': 'Edit Todo List: %s' % todo_list.name, 'form': form, 'submit_text': 'Save List' - } + } return direct_to_template(request, 'general_form.html', page_dict) @permission_required('main.delete_todolist') -- cgit v1.2.3-24-g4f1b