Skip to content

Commit 24f1ae1

Browse files
author
Erik Forsberg
committed
Automatically find out author of property-only changes...
...and add that information in the header of the generated message, replacing "System Message".
1 parent edf82b6 commit 24f1ae1

File tree

2 files changed

+54
-14
lines changed

2 files changed

+54
-14
lines changed

roundup/roundupdb.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1717
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1818
#
19-
# $Id: roundupdb.py,v 1.131 2007-09-05 06:13:56 a1s Exp $
19+
# $Id: roundupdb.py,v 1.132 2007-09-10 19:18:31 forsberg Exp $
2020

2121
"""Extending hyperdb with types specific to issue-tracking.
2222
"""
@@ -283,15 +283,12 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None,
283283
# figure author information
284284
if msgid:
285285
authid = messages.get(msgid, 'author')
286-
authname = users.get(authid, 'realname')
287-
if not authname:
288-
authname = users.get(authid, 'username', '')
289-
authaddr = users.get(authid, 'address', '')
290286
else:
291-
# "system message"
292-
authid = None
293-
authname = 'admin'
294-
authaddr = self.db.config.ADMIN_EMAIL
287+
authid = self.db.getuid()
288+
authname = users.get(authid, 'realname')
289+
if not authname:
290+
authname = users.get(authid, 'username', '')
291+
authaddr = users.get(authid, 'address', '')
295292

296293
if authaddr and self.db.config.MAIL_ADD_AUTHOREMAIL:
297294
authaddr = " <%s>" % straddr( ('',authaddr) )
@@ -311,12 +308,11 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None,
311308

312309
m.append(_("New submission from %(authname)s%(authaddr)s:")
313310
% locals())
314-
else:
311+
elif msgid:
315312
m.append(_("%(authname)s%(authaddr)s added the comment:")
316313
% locals())
317-
m.append('')
318-
elif self.db.config.MAIL_ADD_AUTHORINFO:
319-
m.append(_("System message:"))
314+
else:
315+
m.append(_("Change by %(authname)s%(authaddr)s:") % locals())
320316
m.append('')
321317

322318
# add the content

test/test_mailgw.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# but WITHOUT ANY WARRANTY; without even the implied warranty of
99
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1010
#
11-
# $Id: test_mailgw.py,v 1.87 2007-09-01 16:30:11 forsberg Exp $
11+
# $Id: test_mailgw.py,v 1.88 2007-09-10 19:18:39 forsberg Exp $
1212

1313
# TODO: test bcc
1414

@@ -439,6 +439,50 @@ def testFollowup(self):
439439
_______________________________________________________________________
440440
''')
441441

442+
def testPropertyChangeOnly(self):
443+
self.doNewIssue()
444+
oldvalues = self.db.getnode('issue', '1').copy()
445+
oldvalues['assignedto'] = None
446+
self.db.issue.set('1', assignedto=self.chef_id)
447+
self.db.commit()
448+
self.db.issue.nosymessage('1', None, oldvalues)
449+
450+
451+
new_mail = ""
452+
for line in self._get_mail().split("\n"):
453+
if "Message-Id: " in line:
454+
continue
455+
if "Date: " in line:
456+
continue
457+
new_mail+=line+"\n"
458+
459+
self.compareMessages(new_mail, """
460+
461+
TO: [email protected], richard@test
462+
Content-Type: text/plain; charset=utf-8
463+
Subject: [issue1] Testing...
464+
To: [email protected], richard@test
465+
From: "Bork, Chef" <[email protected]>
466+
X-Roundup-Name: Roundup issue tracker
467+
X-Roundup-Loop: hello
468+
X-Roundup-Version: 1.3.3
469+
MIME-Version: 1.0
470+
Reply-To: Roundup issue tracker <[email protected]>
471+
Content-Transfer-Encoding: quoted-printable
472+
473+
474+
Change by Bork, Chef <[email protected]>:
475+
476+
477+
----------
478+
assignedto: -> Chef
479+
480+
_______________________________________________________________________
481+
Roundup issue tracker <[email protected]>
482+
<http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1>
483+
_______________________________________________________________________
484+
""")
485+
442486

443487
#
444488
# FOLLOWUP TITLE MATCH

0 commit comments

Comments
 (0)