From: Magnus Hagander Date: Mon, 28 Apr 2014 16:19:46 +0000 (+0200) Subject: Show warning when trying to send email to zero recipients X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=bed83a3309ca72294e756e3f2b7ec04157fc5b09;p=pgcommitfest2.git Show warning when trying to send email to zero recipients --- diff --git a/pgcommitfest/commitfest/templatetags/commitfest.py b/pgcommitfest/commitfest/templatetags/commitfest.py index ae5af0c..07b5ea4 100644 --- a/pgcommitfest/commitfest/templatetags/commitfest.py +++ b/pgcommitfest/commitfest/templatetags/commitfest.py @@ -24,6 +24,8 @@ def field_class(value, arg): def alertmap(value): if value == 'error': return 'alert-danger' + elif value == 'warning': + return 'alert-warning' elif value == 'success': return 'alert-success' else: diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index 2556cc3..f34fd54 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -456,6 +456,10 @@ def send_email(request, cfid): else: reviewers = [] + if len(authors)==0 and len(reviewers)==0: + messages.add_message(request, messages.WARNING, "No recipients specified, cannot send email") + return HttpResponseRedirect('..') + messages.add_message(request, messages.INFO, "Email will be sent from: %s" % request.user.email) def _user_and_mail(u): return "%s %s (%s)" % (u.first_name, u.last_name, u.email)