From: schlatterbeck Date: Wed, 19 Oct 2011 13:20:22 +0000 (+0000) Subject: Add config-option "nosy" to messages_to_author setting in [nosy] section X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=roundup.git Add config-option "nosy" to messages_to_author setting in [nosy] section of config: This will send a message to the author only in the case where the author is on the nosy-list (either added earlier or via the add_author setting). Current config-options for this setting will send / not send to author without considering the nosy list. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4659 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index e89fdfa..88aef98 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -15,6 +15,12 @@ Features: translation as it used to be (Ralf) - Sending of PGP-Encrypted mail to all users or selected users (via roles) is now working. (Ralf) +- Add config-option "nosy" to messages_to_author setting in [nosy] + section of config: This will send a message to the author only + in the case where the author is on the nosy-list (either added + earlier or via the add_author setting). Current config-options + for this setting will send / not send to author without considering + the nosy list. (Ralf) Fixed: diff --git a/roundup/configuration.py b/roundup/configuration.py index 6b9d05a..f7ae9d7 100644 --- a/roundup/configuration.py +++ b/roundup/configuration.py @@ -831,8 +831,12 @@ SETTINGS = ( "turned on."), ), "OpenPGP mail processing options"), ("nosy", ( - (RunDetectorOption, "messages_to_author", "no", - "Send nosy messages to the author of the message.", + (Option, "messages_to_author", "no", + "Send nosy messages to the author of the message.\n" + "Allowed values: yes, no, new, nosy -- if yes, messages\n" + "are sent to the author even if not on the nosy list, same\n" + "for new (but only for new messages). When set to nosy,\n" + "the nosy list controls sending messages to the author.", ["MESSAGES_TO_AUTHOR"]), (Option, "signature_position", "bottom", "Where to place the email signature.\n" diff --git a/roundup/roundupdb.py b/roundup/roundupdb.py index ddcf0c3..1ce6772 100644 --- a/roundup/roundupdb.py +++ b/roundup/roundupdb.py @@ -285,7 +285,9 @@ class IssueClass: # anonymous if (good_recipient(authid) and (self.db.config.MESSAGES_TO_AUTHOR == 'yes' or - (self.db.config.MESSAGES_TO_AUTHOR == 'new' and not oldvalues))): + (self.db.config.MESSAGES_TO_AUTHOR == 'new' and not oldvalues) or + (self.db.config.MESSAGES_TO_AUTHOR == 'nosy' and authid in + self.get(issueid, whichnosy)))): add_recipient(authid, sendto) if authid: diff --git a/test/test_mailgw.py b/test/test_mailgw.py index fde8c46..9c3936c 100644 --- a/test/test_mailgw.py +++ b/test/test_mailgw.py @@ -290,8 +290,7 @@ Hi there! self.assertEqual(self.db.issue.get(nodeid, 'status'), '3') self.assertEqual(self.db.issue.get(nodeid, 'priority'), '1') - def doNewIssue(self): - nodeid = self._handle_mail('''Content-Type: text/plain; + newmsg = '''Content-Type: text/plain; charset="iso-8859-1" From: Chef To: issue_tracker@your.tracker.email.domain.example @@ -300,7 +299,10 @@ Message-Id: Subject: [issue] Testing... This is a test submission of a new issue. -''') +''' + + def doNewIssue(self): + nodeid = self._handle_mail(self.newmsg) assert not os.path.exists(SENDMAILDEBUG) l = self.db.issue.get(nodeid, 'nosy') l.sort() @@ -312,20 +314,25 @@ This is a test submission of a new issue. def testNewIssueNosy(self): self.instance.config.ADD_AUTHOR_TO_NOSY = 'yes' - nodeid = self._handle_mail('''Content-Type: text/plain; - charset="iso-8859-1" -From: Chef -To: issue_tracker@your.tracker.email.domain.example -Cc: richard@test.test -Message-Id: -Subject: [issue] Testing... + nodeid = self.doNewIssue() + m = self.db.issue.get(nodeid, 'messages') + self.assertEqual(len(m), 1) + recv = self.db.msg.get(m[0], 'recipients') + self.assertEqual(recv, [self.richard_id]) -This is a test submission of a new issue. -''') + def testNewIssueNosyAuthor(self): + self.instance.config.ADD_AUTHOR_TO_NOSY = 'no' + self.instance.config.MESSAGES_TO_AUTHOR = 'nosy' + nodeid = self._handle_mail(self.newmsg) assert not os.path.exists(SENDMAILDEBUG) l = self.db.issue.get(nodeid, 'nosy') l.sort() - self.assertEqual(l, [self.chef_id, self.richard_id]) + self.assertEqual(l, [self.richard_id]) + m = self.db.issue.get(nodeid, 'messages') + self.assertEqual(len(m), 1) + recv = self.db.msg.get(m[0], 'recipients') + recv.sort() + self.assertEqual(recv, [self.richard_id]) def testAlternateAddress(self): self._handle_mail('''Content-Type: text/plain; @@ -356,7 +363,6 @@ This is a test submission of a new issue. assert not os.path.exists(SENDMAILDEBUG) def testNewIssueAuthMsg(self): - # TODO: fix the damn config - this is apalling self.db.config.MESSAGES_TO_AUTHOR = 'yes' self._handle_mail('''Content-Type: text/plain; charset="iso-8859-1" @@ -1453,11 +1459,7 @@ Subject: Re: Testing... This is a followup '''), nodeid) - - def testFollowupNosyAuthor(self): - self.doNewIssue() - self.db.config.ADD_AUTHOR_TO_NOSY = 'yes' - self._handle_mail('''Content-Type: text/plain; + simple_followup = '''Content-Type: text/plain; charset="iso-8859-1" From: john@test.test To: issue_tracker@your.tracker.email.domain.example @@ -1466,8 +1468,12 @@ In-Reply-To: Subject: [issue1] Testing... This is a followup -''') +''' + def testFollowupNosyAuthor(self): + self.doNewIssue() + self.db.config.ADD_AUTHOR_TO_NOSY = 'yes' + self._handle_mail(self.simple_followup) self.compareMessages(self._get_mail(), '''FROM: roundup-admin@your.tracker.email.domain.example TO: chef@bork.bork.bork, richard@test.test @@ -1505,7 +1511,7 @@ _______________________________________________________________________ self.doNewIssue() self.db.config.ADD_RECIPIENTS_TO_NOSY = 'yes' self._handle_mail('''Content-Type: text/plain; - charset="iso-8859-1" + charset="iso-8859-1" From: richard@test.test To: issue_tracker@your.tracker.email.domain.example Cc: john@test.test @@ -1552,16 +1558,45 @@ _______________________________________________________________________ self.doNewIssue() self.db.config.ADD_AUTHOR_TO_NOSY = 'yes' self.db.config.MESSAGES_TO_AUTHOR = 'yes' - self._handle_mail('''Content-Type: text/plain; - charset="iso-8859-1" -From: john@test.test -To: issue_tracker@your.tracker.email.domain.example + self._handle_mail(self.simple_followup) + self.compareMessages(self._get_mail(), +'''FROM: roundup-admin@your.tracker.email.domain.example +TO: chef@bork.bork.bork, john@test.test, richard@test.test +Content-Type: text/plain; charset="utf-8" +Subject: [issue1] Testing... +To: chef@bork.bork.bork, john@test.test, richard@test.test +From: John Doe +Reply-To: Roundup issue tracker + +MIME-Version: 1.0 Message-Id: In-Reply-To: -Subject: [issue1] Testing... +X-Roundup-Name: Roundup issue tracker +X-Roundup-Loop: hello +X-Roundup-Issue-Status: chatting +Content-Transfer-Encoding: quoted-printable + + +John Doe added the comment: This is a followup + +---------- +nosy: +john +status: unread -> chatting + +_______________________________________________________________________ +Roundup issue tracker + +_______________________________________________________________________ + ''') + + def testFollowupNosyAuthorNosyCopy(self): + self.doNewIssue() + self.db.config.ADD_AUTHOR_TO_NOSY = 'yes' + self.db.config.MESSAGES_TO_AUTHOR = 'nosy' + self._handle_mail(self.simple_followup) self.compareMessages(self._get_mail(), '''FROM: roundup-admin@your.tracker.email.domain.example TO: chef@bork.bork.bork, john@test.test, richard@test.test @@ -1598,16 +1633,44 @@ _______________________________________________________________________ def testFollowupNoNosyAuthor(self): self.doNewIssue() self.instance.config.ADD_AUTHOR_TO_NOSY = 'no' - self._handle_mail('''Content-Type: text/plain; - charset="iso-8859-1" -From: john@test.test -To: issue_tracker@your.tracker.email.domain.example + self._handle_mail(self.simple_followup) + self.compareMessages(self._get_mail(), +'''FROM: roundup-admin@your.tracker.email.domain.example +TO: chef@bork.bork.bork, richard@test.test +Content-Type: text/plain; charset="utf-8" +Subject: [issue1] Testing... +To: chef@bork.bork.bork, richard@test.test +From: John Doe +Reply-To: Roundup issue tracker + +MIME-Version: 1.0 Message-Id: In-Reply-To: -Subject: [issue1] Testing... +X-Roundup-Name: Roundup issue tracker +X-Roundup-Loop: hello +X-Roundup-Issue-Status: chatting +Content-Transfer-Encoding: quoted-printable + + +John Doe added the comment: This is a followup + +---------- +status: unread -> chatting + +_______________________________________________________________________ +Roundup issue tracker + +_______________________________________________________________________ + ''') + + def testFollowupNoNosyAuthorNoCopy(self): + self.doNewIssue() + self.instance.config.ADD_AUTHOR_TO_NOSY = 'no' + self.instance.config.MESSAGES_TO_AUTHOR = 'nosy' + self._handle_mail(self.simple_followup) self.compareMessages(self._get_mail(), '''FROM: roundup-admin@your.tracker.email.domain.example TO: chef@bork.bork.bork, richard@test.test @@ -1626,6 +1689,45 @@ X-Roundup-Issue-Status: chatting Content-Transfer-Encoding: quoted-printable +John Doe added the comment: + +This is a followup + +---------- +status: unread -> chatting + +_______________________________________________________________________ +Roundup issue tracker + +_______________________________________________________________________ + +''') + + # this is a pathological case where the author is *not* on the nosy + # list but gets the message; test documents existing behaviour + def testFollowupNoNosyAuthorButCopy(self): + self.doNewIssue() + self.instance.config.ADD_AUTHOR_TO_NOSY = 'no' + self.instance.config.MESSAGES_TO_AUTHOR = 'yes' + self._handle_mail(self.simple_followup) + self.compareMessages(self._get_mail(), +'''FROM: roundup-admin@your.tracker.email.domain.example +TO: chef@bork.bork.bork, john@test.test, richard@test.test +Content-Type: text/plain; charset="utf-8" +Subject: [issue1] Testing... +To: chef@bork.bork.bork, john@test.test, richard@test.test +From: John Doe +Reply-To: Roundup issue tracker + +MIME-Version: 1.0 +Message-Id: +In-Reply-To: +X-Roundup-Name: Roundup issue tracker +X-Roundup-Loop: hello +X-Roundup-Issue-Status: chatting +Content-Transfer-Encoding: quoted-printable + + John Doe added the comment: This is a followup