diff options
-rw-r--r-- | templates/todolists/addedtotodolist | 16 | ||||
-rw-r--r-- | todolists/views.py | 27 |
2 files changed, 41 insertions, 2 deletions
diff --git a/templates/todolists/addedtotodolist b/templates/todolists/addedtotodolist new file mode 100644 index 00000000..55ba8ea2 --- /dev/null +++ b/templates/todolists/addedtotodolist @@ -0,0 +1,16 @@ + +* Note: this is an automated message + +The following package: + + Package Name: {{ pkg.pkgname }} + Architecture: {{ pkg.arch.name }} + Repository: {{ pkg.repo.name }} + ({{ weburl }}) + +has been added to this to-do list: + +Creator: {{todolist.creator.get_full_name}} +Name: {{todolist.name}} +Description: +{{description|wordwrap:69}} 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: |