Skip to content

Commit d0a501b

Browse files
author
Richard Jones
committed
allow additional control over the roundupdb email sending...
...explicit cc addresses, different from address and different nosy list property. (thanks John Rouillard)
1 parent a8cc641 commit d0a501b

File tree

5 files changed

+89
-27
lines changed

5 files changed

+89
-27
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ are given with the most recent entry first.
55
- better hyperlinking in web message texts
66
- support setting of properties on message and file through web and
77
email interface (thanks John Rouillard)
8+
- allow additional control over the roundupdb email sending (explicit
9+
cc addresses, different from address and different nosy list property)
10+
(thanks John Rouillard)
811

912

1013
2003-01-10 0.5.4

doc/customizing.txt

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Customising Roundup
33
===================
44

5-
:Version: $Revision: 1.68 $
5+
:Version: $Revision: 1.69 $
66

77
.. This document borrows from the ZopeBook section on ZPT. The original is at:
88
http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -107,15 +107,25 @@ The configuration variables available are:
107107
The email address that e-mail sent to roundup should go to. Think of it as the
108108
tracker's personal e-mail address.
109109

110-
**TRACKER_WEB** - ``'http://your.tracker.url.example/'``
110+
**TRACKER_WEB** - ``'http://tracker.example/cgi-bin/roundup.cgi/bugs/'``
111111
The web address that the tracker is viewable at. This will be included in
112-
information sent to users of the tracker. The URL must include the cgi-bin
113-
part or anything else that is required to get to the home page of the
114-
tracker. You must include a trailing '/' in the URL.
112+
information sent to users of the tracker. The URL **must** include the
113+
cgi-bin part or anything else that is required to get to the home page of
114+
the tracker. You **must** include a trailing '/' in the URL.
115115

116116
**ADMIN_EMAIL** - ``'roundup-admin@%s'%MAIL_DOMAIN``
117117
The email address that roundup will complain to if it runs into trouble.
118118

119+
**EMAIL_FROM_TAG** - ``''``
120+
Additional text to include in the "name" part of the ``From:`` address used
121+
in nosy messages. If the sending user is "Foo Bar", the ``From:`` line is
122+
usually::
123+
"Foo Bar" <[email protected]>
124+
125+
the EMAIL_FROM_TAG goes inside the "Foo Bar" quotes like so::
126+
127+
"Foo Bar EMAIL_FROM_TAG" <[email protected]>
128+
119129
**MESSAGES_TO_AUTHOR** - ``'yes'`` or``'no'``
120130
Send nosy messages to the author of the message.
121131

@@ -172,12 +182,22 @@ tracker is attempted.::
172182
# The email address that mail to roundup should go to
173183
TRACKER_EMAIL = 'issue_tracker@%s'%MAIL_DOMAIN
174184

175-
# The web address that the tracker is viewable at
176-
TRACKER_WEB = 'http://your.tracker.url.example/'
185+
# The web address that the tracker is viewable at. This will be included in
186+
# information sent to users of the tracker. The URL MUST include the cgi-bin
187+
# part or anything else that is required to get to the home page of the
188+
# tracker. You MUST include a trailing '/' in the URL.
189+
TRACKER_WEB = 'http://tracker.example/cgi-bin/roundup.cgi/bugs/'
177190

178191
# The email address that roundup will complain to if it runs into trouble
179192
ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN
180193

194+
# Additional text to include in the "name" part of the From: address used
195+
# in nosy messages. If the sending user is "Foo Bar", the From: line is
196+
# usually: "Foo Bar" <[email protected]>
197+
# the EMAIL_FROM_TAG goes inside the "Foo Bar" quotes like so:
198+
# "Foo Bar EMAIL_FROM_TAG" <[email protected]>
199+
EMAIL_FROM_TAG = ""
200+
181201
# Send nosy messages to the author of the message
182202
MESSAGES_TO_AUTHOR = 'no' # either 'yes' or 'no'
183203

@@ -208,6 +228,14 @@ tracker is attempted.::
208228
MAIL_DEFAULT_CLASS = 'issue' # use "issue" class by default
209229
#MAIL_DEFAULT_CLASS = '' # disable (or just comment the var out)
210230

231+
#
232+
# SECURITY DEFINITIONS
233+
#
234+
# define the Roles that a user gets when they register with the tracker
235+
# these are a comma-separated string of role names (e.g. 'Admin,User')
236+
NEW_WEB_USER_ROLES = 'User'
237+
NEW_EMAIL_USER_ROLES = 'User'
238+
211239
Tracker Schema
212240
==============
213241

roundup/roundupdb.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: roundupdb.py,v 1.75 2002-12-11 01:52:20 richard Exp $
18+
# $Id: roundupdb.py,v 1.76 2003-01-12 00:41:26 richard Exp $
1919

2020
__doc__ = """
2121
Extending hyperdb with types specific to issue-tracking.
@@ -87,7 +87,8 @@ def addmessage(self, nodeid, summary, text):
8787
appended to the "messages" field of the specified issue.
8888
"""
8989

90-
def nosymessage(self, nodeid, msgid, oldvalues):
90+
def nosymessage(self, nodeid, msgid, oldvalues, whichnosy='nosy',
91+
from_address=[], cc=[], bcc=[]):
9192
"""Send a message to the members of an issue's nosy list.
9293
9394
The message is sent only to users on the nosy list who are not
@@ -115,8 +116,16 @@ def nosymessage(self, nodeid, msgid, oldvalues):
115116
sendto.append(authid)
116117
r[authid] = 1
117118

119+
# now deal with cc people.
120+
for cc_userid in cc :
121+
if r.has_key(cc_userid):
122+
continue
123+
# send it to them
124+
sendto.append(cc_userid)
125+
recipients.append(cc_userid)
126+
118127
# now figure the nosy people who weren't recipients
119-
nosy = self.get(nodeid, 'nosy')
128+
nosy = self.get(nodeid, whichnosy)
120129
for nosyid in nosy:
121130
# Don't send nosy mail to the anonymous user (that user
122131
# shouldn't appear in the nosy list, but just in case they
@@ -144,12 +153,12 @@ def nosymessage(self, nodeid, msgid, oldvalues):
144153
messages.set(msgid, recipients=recipients)
145154

146155
# send the message
147-
self.send_message(nodeid, msgid, note, sendto)
156+
self.send_message(nodeid, msgid, note, sendto, from_address)
148157

149158
# backwards compatibility - don't remove
150159
sendmessage = nosymessage
151160

152-
def send_message(self, nodeid, msgid, note, sendto):
161+
def send_message(self, nodeid, msgid, note, sendto, from_address=None):
153162
'''Actually send the nominated message from this node to the sendto
154163
recipients, with the note appended.
155164
'''
@@ -220,16 +229,23 @@ def send_message(self, nodeid, msgid, note, sendto):
220229
# make sure the To line is always the same (for testing mostly)
221230
sendto.sort()
222231

232+
# make sure we have a from address
233+
if from_address is None:
234+
from_address = self.db.config.TRACKER_EMAIL
235+
236+
# additional bit for after the From: "name"
237+
from_tag = getattr(self.db.config, 'EMAIL_FROM_TAG', '')
238+
if from_tag:
239+
from_tag = ' ' + from_tag
240+
223241
# create the message
224242
message = cStringIO.StringIO()
225243
writer = MimeWriter.MimeWriter(message)
226244
writer.addheader('Subject', '[%s%s] %s'%(cn, nodeid, title))
227245
writer.addheader('To', ', '.join(sendto))
228-
writer.addheader('From', straddr(
229-
(authname, self.db.config.TRACKER_EMAIL) ) )
230-
writer.addheader('Reply-To', straddr(
231-
(self.db.config.TRACKER_NAME,
232-
self.db.config.TRACKER_EMAIL) ) )
246+
writer.addheader('From', straddr((authname + from_tag, from_address)))
247+
writer.addheader('Reply-To', straddr((self.db.config.TRACKER_NAME,
248+
from_address)))
233249
writer.addheader('Date', time.strftime("%a, %d %b %Y %H:%M:%S +0000",
234250
time.gmtime()))
235251
writer.addheader('MIME-Version', '1.0')
@@ -282,7 +298,7 @@ def send_message(self, nodeid, msgid, note, sendto):
282298

283299
# now try to send the message
284300
if SENDMAILDEBUG:
285-
open(SENDMAILDEBUG, 'w').write('FROM: %s\nTO: %s\n%s\n'%(
301+
open(SENDMAILDEBUG, 'a').write('FROM: %s\nTO: %s\n%s\n'%(
286302
self.db.config.ADMIN_EMAIL,
287303
', '.join(sendto),message.getvalue()))
288304
else:

roundup/templates/classic/config.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: config.py,v 1.6 2002-12-13 22:20:10 richard Exp $
18+
# $Id: config.py,v 1.7 2003-01-12 00:41:27 richard Exp $
1919

2020
import os
2121

@@ -49,13 +49,13 @@
4949
# The email address that roundup will complain to if it runs into trouble
5050
ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN
5151

52-
#
53-
# SECURITY DEFINITIONS
54-
#
55-
# define the Roles that a user gets when they register with the tracker
56-
# these are a comma-separated string of role names (e.g. 'Admin,User')
57-
NEW_WEB_USER_ROLES = 'User'
58-
NEW_EMAIL_USER_ROLES = 'User'
52+
# Additional text to include in the "name" part of the From: address used
53+
# in nosy messages. If the sending user is "Foo Bar", the From: line is
54+
# usually:
55+
# "Foo Bar" <issue_tracker@tracker.example>
56+
# the EMAIL_FROM_TAG goes inside the "Foo Bar" quotes like so:
57+
# "Foo Bar EMAIL_FROM_TAG" <[email protected]>
58+
EMAIL_FROM_TAG = ""
5959

6060
# Send nosy messages to the author of the message
6161
MESSAGES_TO_AUTHOR = 'no' # either 'yes' or 'no'
@@ -89,4 +89,12 @@
8989
MAIL_DEFAULT_CLASS = 'issue' # use "issue" class by default
9090
#MAIL_DEFAULT_CLASS = '' # disable (or just comment the var out)
9191

92+
#
93+
# SECURITY DEFINITIONS
94+
#
95+
# define the Roles that a user gets when they register with the tracker
96+
# these are a comma-separated string of role names (e.g. 'Admin,User')
97+
NEW_WEB_USER_ROLES = 'User'
98+
NEW_EMAIL_USER_ROLES = 'User'
99+
92100
# vim: set filetype=python ts=4 sw=4 et si

roundup/templates/minimal/config.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: config.py,v 1.4 2002-12-13 22:20:10 richard Exp $
18+
# $Id: config.py,v 1.5 2003-01-12 00:41:27 richard Exp $
1919

2020
import os
2121

@@ -49,6 +49,13 @@
4949
# The email address that roundup will complain to if it runs into trouble
5050
ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN
5151

52+
# Additional text to include in the "name" part of the From: address used
53+
# in nosy messages. If the sending user is "Foo Bar", the From: line is
54+
# usually: "Foo Bar" <[email protected]>
55+
# the EMAIL_FROM_TAG goes inside the "Foo Bar" quotes like so:
56+
# "Foo Bar EMAIL_FROM_TAG" <[email protected]>
57+
EMAIL_FROM_TAG = ""
58+
5259
#
5360
# SECURITY DEFINITIONS
5461
#

0 commit comments

Comments
 (0)