diff options
author | Dusty Phillips <buchuki@gmail.com> | 2008-07-01 18:43:37 -0400 |
---|---|---|
committer | Dusty Phillips <buchuki@gmail.com> | 2008-07-01 18:43:37 -0400 |
commit | 94740a101678944e44f4b29d9805e85c3cf50d45 (patch) | |
tree | 862ef3bebcd6a68a0935938bb8b90fe8c9c28da2 /todolists | |
parent | 19ee71a9aa7363922a3d9eefb0b6703cec6126ef (diff) |
add reminder e-mails to todo lists
Diffstat (limited to 'todolists')
-rw-r--r-- | todolists/views.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/todolists/views.py b/todolists/views.py index 2931d9bb..e06478ad 100644 --- a/todolists/views.py +++ b/todolists/views.py @@ -5,6 +5,7 @@ from django.template import RequestContext from django.shortcuts import get_object_or_404 from django.contrib.auth.decorators import permission_required from django.contrib.auth.models import User +from django.template import Context, loader from archweb_dev.main.utils import render_response from archweb_dev.main.models import Todolist, TodolistPkg, Package from archweb_dev.main.models import Arch, Repo @@ -62,7 +63,8 @@ def add(request): name = form.clean_data['name'], description = form.clean_data['description']) for pkg in form.clean_data['packages']: - TodolistPkg.objects.create(list = todo, pkg = pkg) + todo = TodolistPkg.objects.create(list = todo, pkg = pkg) + send_todolist_email(todo) return HttpResponseRedirect('/todo/') else: form = TodoListForm() @@ -94,7 +96,9 @@ def edit(request, list_id): # now add any packages not in the old list for pkg in form.clean_data['packages']: if pkg not in packages: - TodolistPkg.objects.create(list = todo_list, pkg = pkg) + todo = TodolistPkg.objects.create( + list = todo_list, pkg = pkg) + send_todolist_email(todo) return HttpResponseRedirect('/todo/%d/' % todo_list.id) else: @@ -111,6 +115,25 @@ def edit(request, list_id): return render_response(request, 'general_form.html', page_dict) +def send_todolist_email(todo): + '''Sends an e-mail to the maintainer of a package notifying them that the + package has been added to a to-do list''' + if todo.pkg.maintainer_id == 0: + return + page_dict = { + 'pkg': todo.pkg, + 'todolist': todo.list, + 'weburl': 'http://www.archlinux.org/packages/%s/' % (todo.pkg.id) + } + t = loader.get_template('todolists/addedtotodolist') + c = Context(page_dict) + send_mail('arch: Package [%s] added to Todolist' % todo.pkg.pkgname, + t.render(c), + 'Arch Website Notification <nobody@archlinux.org>', + [pkg.maintainer.email], + fail_silently=True) + + # vim: set ts=4 sw=4 et: |