Merge lp:~lifeless/python-oops-tools/report-recipient into lp:python-oops-tools

Proposed by Robert Collins
Status: Merged
Approved by: Robert Collins
Approved revision: 38
Merged at revision: 37
Proposed branch: lp:~lifeless/python-oops-tools/report-recipient
Merge into: lp:python-oops-tools
Diff against target: 143 lines (+46/-12)
6 files modified
buildout-templates/src/oopstools/settings.py.in (+1/-0)
src/oopstools/NEWS.txt (+3/-0)
src/oopstools/README.txt (+6/-7)
src/oopstools/oops/migrations/0022_report_email_address.py (+27/-0)
src/oopstools/oops/models.py (+1/-0)
src/oopstools/scripts/report.py (+8/-5)
To merge this branch: bzr merge lp:~lifeless/python-oops-tools/report-recipient
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+116999@code.launchpad.net

Commit message

Allow a custom email address on each report.

Description of the change

Allow a custom email address on each report, permitting U1 reports to go to U1 etc.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'buildout-templates/src/oopstools/settings.py.in'
2--- buildout-templates/src/oopstools/settings.py.in 2011-12-12 06:11:11 +0000
3+++ buildout-templates/src/oopstools/settings.py.in 2012-07-27 04:36:20 +0000
4@@ -101,6 +101,7 @@
5
6 SUMMARY_URI = "${configuration:summary-uri}"
7 SUMMARY_DIR = "${configuration:summary-dir}"
8+# Deprecated: set in the report admin UI instead.
9 REPORT_TO_ADDRESS = "${configuration:report-to-address}"
10 REPORT_FROM_ADDRESS = "${configuration:report-from-address}"
11
12
13=== modified file 'src/oopstools/NEWS.txt'
14--- src/oopstools/NEWS.txt 2012-02-01 05:01:13 +0000
15+++ src/oopstools/NEWS.txt 2012-07-27 04:36:20 +0000
16@@ -5,6 +5,9 @@
17 NEXT
18 ====
19
20+* Reports have a per-report email address that can be set, to allow different
21+ reports to go to different addresses. (Robert Collins)
22+
23 0.6.2
24 =====
25
26
27=== modified file 'src/oopstools/README.txt'
28--- src/oopstools/README.txt 2011-12-12 06:11:11 +0000
29+++ src/oopstools/README.txt 2012-07-27 04:36:20 +0000
30@@ -105,13 +105,13 @@
31
32 Create a new cluster for lpoops:
33
34- $ LC_ALL=C sudo pg_createcluster 8.4 lpoops --encoding UNICODE --port 5433
35+ $ LC_ALL=C sudo pg_createcluster 9.1 lpoops --encoding UNICODE --port 5433
36
37-Apply the following patch to /etc/postgresql/8.4/lpoops/pg_hba.conf. Note that
38+Apply the following patch to /etc/postgresql/9.1/lpoops/pg_hba.conf. Note that
39 this configuration change needs to be before the "DO NOT DISABLE!" line in the
40 pg_hba.conf file.
41
42- sudo patch /etc/postgresql/8.4/lpoops/pg_hba.conf <<'EOF'
43+ sudo patch /etc/postgresql/9.1/lpoops/pg_hba.conf <<'EOF'
44 --- pg_hba.conf 2005-11-02 17:33:08.000000000 -0800
45 +++ /tmp/pg_hba.conf 2005-11-03 07:32:46.932400423 -0800
46 @@ -58,7 +58,9 @@
47@@ -132,17 +132,16 @@
48
49 Start the cluster.
50
51- $ sudo pg_ctlcluster 8.4 lpoops start
52+ $ sudo pg_ctlcluster 9.1 lpoops start
53
54 Add your own user to the cluster:
55
56- $ sudo -u postgres /usr/lib/postgresql/8.4/bin/createuser -a -d $USER --port
57- 5433
58+ $ sudo -u postgres createuser -a -d $USER --port 5433
59
60 To create the new db:
61
62 $ createuser lpoops --createdb --no-superuser --no-createrole --port 5433
63- $ createdb -O lpoops lpoops --host localhost --port 5433
64+ $ createdb -O lpoops lpoops --port 5433
65
66 Note that this command creates a password-less database. Use --password to
67 create a db with a password.
68
69=== added file 'src/oopstools/oops/migrations/0022_report_email_address.py'
70--- src/oopstools/oops/migrations/0022_report_email_address.py 1970-01-01 00:00:00 +0000
71+++ src/oopstools/oops/migrations/0022_report_email_address.py 2012-07-27 04:36:20 +0000
72@@ -0,0 +1,27 @@
73+# Copyright 2012 Canonical Ltd. All rights reserved.
74+#
75+# This program is free software: you can redistribute it and/or modify
76+# it under the terms of the GNU Affero General Public License as published by
77+# the Free Software Foundation, either version 3 of the License, or
78+# (at your option) any later version.
79+#
80+# This program is distributed in the hope that it will be useful,
81+# but WITHOUT ANY WARRANTY; without even the implied warranty of
82+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
83+# GNU Affero General Public License for more details.
84+#
85+# You should have received a copy of the GNU Affero General Public License
86+# along with this program. If not, see <http://www.gnu.org/licenses/>.
87+
88+from django.db import models
89+from south.v2 import DataMigration
90+from south.db import db
91+
92+
93+class Migration(DataMigration):
94+
95+ def forwards(self, orm):
96+ db.add_column('oops_report', 'recipient', models.EmailField(max_length=254, null=True))
97+
98+ def backwards(self, orm):
99+ db.delete_column('oops_report', 'recipient')
100
101=== modified file 'src/oopstools/oops/models.py'
102--- src/oopstools/oops/models.py 2012-07-25 14:25:48 +0000
103+++ src/oopstools/oops/models.py 2012-07-27 04:36:20 +0000
104@@ -162,6 +162,7 @@
105 summary = models.CharField(max_length=20, choices=SUMMARY_CHOICES)
106 prefixes = models.ManyToManyField(Prefix)
107 active = models.BooleanField(default=False)
108+ recipient = models.EmailField(max_length=254, null=True)
109
110 def __unicode__(self):
111 return unicode(self.name)
112
113=== modified file 'src/oopstools/scripts/report.py'
114--- src/oopstools/scripts/report.py 2011-10-13 20:18:51 +0000
115+++ src/oopstools/scripts/report.py 2012-07-27 04:36:20 +0000
116@@ -33,14 +33,17 @@
117 smtp_server = smtplib.SMTP()
118
119
120-def send_oops_report_email(report_title, date, body_text):
121+def send_oops_report_email(report, date, body_text):
122 # Construct the email.
123 msg = MIMEText(body_text, 'plain', 'utf8')
124- msg['Subject'] = "%s Errors for %s" % (report_title, date)
125+ msg['Subject'] = "%s Errors for %s" % (report.title, date)
126 from_addr = "OOPS Summaries <%s>" % settings.REPORT_FROM_ADDRESS
127 msg['From'] = from_addr
128- msg['Reply-To'] = settings.REPORT_TO_ADDRESS
129- msg['To'] = settings.REPORT_TO_ADDRESS
130+ to_addr = report.recipient
131+ if not to_addr:
132+ to_addr = settings.REPORT_TO_ADDRESS
133+ msg['Reply-To'] = to_addr
134+ msg['To'] = to_addr
135
136 # Send the email.
137 smtp_server.connect()
138@@ -86,4 +89,4 @@
139 report.title, yesterday_string)
140
141 # Send email report
142- send_oops_report_email(report.title, yesterday_string, body_text)
143+ send_oops_report_email(report, yesterday_string, body_text)

Subscribers

People subscribed via source and target branches

to all changes: