summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-02-01 00:52:08 +0100
committerDan McGee <dan@archlinux.org>2010-02-01 00:52:08 +0100
commita16b4d9ecd2a3fa1676e8bc1d69de5e5d41d0d18 (patch)
treeb8e6d39d0513819c1d7fe4ff9eaf777de0ea5440
parenta32eb2dce6e19445492528f0b93bf3850389c41a (diff)
downloadarchweb-a16b4d9ecd2a3fa1676e8bc1d69de5e5d41d0d18.tar.gz
archweb-a16b4d9ecd2a3fa1676e8bc1d69de5e5d41d0d18.tar.xz
Make marking out of date actually work
And honor the packager's notify flag, as Pierre pointed out. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--devel/views.py8
-rw-r--r--packages/views.py39
2 files changed, 25 insertions, 22 deletions
diff --git a/devel/views.py b/devel/views.py
index 78c466a..582df76 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -32,11 +32,9 @@ def index(request):
def change_notify(request):
maint = User.objects.get(username=request.user.username)
notify = request.POST.get('notify', 'no')
- try:
- maint.get_profile().notify = notify == 'yes'
- except UserProfile.DoesNotExist:
- UserProfile(user_id=maint.id ,notify=notify == 'yes').save()
- maint.get_profile().save()
+ pf = maint.get_profile()
+ pf.notify = (notify == 'yes')
+ pf.save()
return HttpResponseRedirect('/devel/')
class ProfileForm(forms.Form):
diff --git a/packages/views.py b/packages/views.py
index 28d458a..a514617 100644
--- a/packages/views.py
+++ b/packages/views.py
@@ -1,7 +1,8 @@
import urllib
from django import forms
+from django.core.mail import send_mail
from django.shortcuts import render_to_response
-from django.template import RequestContext
+from django.template import loader, Context, RequestContext
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.contrib.auth.models import User
@@ -250,6 +251,7 @@ def flag(request, pkgid):
if request.POST:
form = FlagForm(request.POST)
if form.is_valid() and form.cleaned_data['website'] == '':
+ send_email = True
# flag all architectures
pkgs = Package.objects.filter(
pkgname=pkg.pkgname, repo=pkg.repo)
@@ -260,23 +262,28 @@ def flag(request, pkgid):
if not pkg.maintainer:
toemail = 'arch-notifications@archlinux.org'
subject = 'Orphan %s package [%s] marked out-of-date' % (pkg.repo.name, pkg.pkgname)
- else:
+ elif pkg.maintainer.get_profile().notify == True:
toemail = pkg.maintainer.email
subject = '%s package [%s] marked out-of-date' % (pkg.repo.name, pkg.pkgname)
+ else:
+ # no need to send any email, packager didn't want notification
+ send_email = False
+
+ if send_email:
+ # send notification email to the maintainer
+ t = loader.get_template('packages/outofdate.txt')
+ c = Context({
+ 'email': form.cleaned_data['email'],
+ 'message': form.cleaned_data['usermessage'],
+ 'pkg': pkg,
+ 'weburl': 'http://www.archlinux.org'+ pkg.get_absolute_url()
+ })
+ send_mail(subject,
+ t.render(c),
+ 'Arch Website Notification <nobody@archlinux.org>',
+ [toemail],
+ fail_silently=True)
- # send notification email to the maintainer
- t = loader.get_template('packages/outofdate.txt')
- c = Context({
- 'email': form.cleaned_data['email'],
- 'message': form.cleaned_data['usermessage'],
- 'pkg': pkg,
- 'weburl': 'http://www.archlinux.org'+ pkg.get_absolute_url()
- })
- send_mail(subject,
- t.render(c),
- 'Arch Website Notification <nobody@archlinux.org>',
- [toemail],
- fail_silently=True)
context['confirmed'] = True
else:
form = FlagForm()
@@ -285,7 +292,5 @@ def flag(request, pkgid):
return render_to_response('packages/flag.html', context)
-
-
# vim: set ts=4 sw=4 et: