launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #10332
[Merge] lp:~lifeless/python-oops-tools/report-recipient into lp:python-oops-tools
Robert Collins has proposed merging lp:~lifeless/python-oops-tools/report-recipient into lp:python-oops-tools.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~lifeless/python-oops-tools/report-recipient/+merge/116999
Allow a custom email address on each report, permitting U1 reports to go to U1 etc.
--
https://code.launchpad.net/~lifeless/python-oops-tools/report-recipient/+merge/116999
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/python-oops-tools/report-recipient into lp:python-oops-tools.
=== modified file 'buildout-templates/src/oopstools/settings.py.in'
--- buildout-templates/src/oopstools/settings.py.in 2011-12-12 06:11:11 +0000
+++ buildout-templates/src/oopstools/settings.py.in 2012-07-27 04:36:20 +0000
@@ -101,6 +101,7 @@
SUMMARY_URI = "${configuration:summary-uri}"
SUMMARY_DIR = "${configuration:summary-dir}"
+# Deprecated: set in the report admin UI instead.
REPORT_TO_ADDRESS = "${configuration:report-to-address}"
REPORT_FROM_ADDRESS = "${configuration:report-from-address}"
=== modified file 'src/oopstools/NEWS.txt'
--- src/oopstools/NEWS.txt 2012-02-01 05:01:13 +0000
+++ src/oopstools/NEWS.txt 2012-07-27 04:36:20 +0000
@@ -5,6 +5,9 @@
NEXT
====
+* Reports have a per-report email address that can be set, to allow different
+ reports to go to different addresses. (Robert Collins)
+
0.6.2
=====
=== modified file 'src/oopstools/README.txt'
--- src/oopstools/README.txt 2011-12-12 06:11:11 +0000
+++ src/oopstools/README.txt 2012-07-27 04:36:20 +0000
@@ -105,13 +105,13 @@
Create a new cluster for lpoops:
- $ LC_ALL=C sudo pg_createcluster 8.4 lpoops --encoding UNICODE --port 5433
+ $ LC_ALL=C sudo pg_createcluster 9.1 lpoops --encoding UNICODE --port 5433
-Apply the following patch to /etc/postgresql/8.4/lpoops/pg_hba.conf. Note that
+Apply the following patch to /etc/postgresql/9.1/lpoops/pg_hba.conf. Note that
this configuration change needs to be before the "DO NOT DISABLE!" line in the
pg_hba.conf file.
- sudo patch /etc/postgresql/8.4/lpoops/pg_hba.conf <<'EOF'
+ sudo patch /etc/postgresql/9.1/lpoops/pg_hba.conf <<'EOF'
--- pg_hba.conf 2005-11-02 17:33:08.000000000 -0800
+++ /tmp/pg_hba.conf 2005-11-03 07:32:46.932400423 -0800
@@ -58,7 +58,9 @@
@@ -132,17 +132,16 @@
Start the cluster.
- $ sudo pg_ctlcluster 8.4 lpoops start
+ $ sudo pg_ctlcluster 9.1 lpoops start
Add your own user to the cluster:
- $ sudo -u postgres /usr/lib/postgresql/8.4/bin/createuser -a -d $USER --port
- 5433
+ $ sudo -u postgres createuser -a -d $USER --port 5433
To create the new db:
$ createuser lpoops --createdb --no-superuser --no-createrole --port 5433
- $ createdb -O lpoops lpoops --host localhost --port 5433
+ $ createdb -O lpoops lpoops --port 5433
Note that this command creates a password-less database. Use --password to
create a db with a password.
=== added file 'src/oopstools/oops/migrations/0022_report_email_address.py'
--- src/oopstools/oops/migrations/0022_report_email_address.py 1970-01-01 00:00:00 +0000
+++ src/oopstools/oops/migrations/0022_report_email_address.py 2012-07-27 04:36:20 +0000
@@ -0,0 +1,27 @@
+# Copyright 2012 Canonical Ltd. All rights reserved.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from django.db import models
+from south.v2 import DataMigration
+from south.db import db
+
+
+class Migration(DataMigration):
+
+ def forwards(self, orm):
+ db.add_column('oops_report', 'recipient', models.EmailField(max_length=254, null=True))
+
+ def backwards(self, orm):
+ db.delete_column('oops_report', 'recipient')
=== modified file 'src/oopstools/oops/models.py'
--- src/oopstools/oops/models.py 2012-07-25 14:25:48 +0000
+++ src/oopstools/oops/models.py 2012-07-27 04:36:20 +0000
@@ -162,6 +162,7 @@
summary = models.CharField(max_length=20, choices=SUMMARY_CHOICES)
prefixes = models.ManyToManyField(Prefix)
active = models.BooleanField(default=False)
+ recipient = models.EmailField(max_length=254, null=True)
def __unicode__(self):
return unicode(self.name)
=== modified file 'src/oopstools/scripts/report.py'
--- src/oopstools/scripts/report.py 2011-10-13 20:18:51 +0000
+++ src/oopstools/scripts/report.py 2012-07-27 04:36:20 +0000
@@ -33,14 +33,17 @@
smtp_server = smtplib.SMTP()
-def send_oops_report_email(report_title, date, body_text):
+def send_oops_report_email(report, date, body_text):
# Construct the email.
msg = MIMEText(body_text, 'plain', 'utf8')
- msg['Subject'] = "%s Errors for %s" % (report_title, date)
+ msg['Subject'] = "%s Errors for %s" % (report.title, date)
from_addr = "OOPS Summaries <%s>" % settings.REPORT_FROM_ADDRESS
msg['From'] = from_addr
- msg['Reply-To'] = settings.REPORT_TO_ADDRESS
- msg['To'] = settings.REPORT_TO_ADDRESS
+ to_addr = report.recipient
+ if not to_addr:
+ to_addr = settings.REPORT_TO_ADDRESS
+ msg['Reply-To'] = to_addr
+ msg['To'] = to_addr
# Send the email.
smtp_server.connect()
@@ -86,4 +89,4 @@
report.title, yesterday_string)
# Send email report
- send_oops_report_email(report.title, yesterday_string, body_text)
+ send_oops_report_email(report, yesterday_string, body_text)