Skip to content

Commit 9ab7e56

Browse files
committed
- issue2550926 - Original author adding a second message shouldn't set
status to 'chatting'. Updates to jinja and classic tracker's statusauditor.py and new config.ini for the detectors. Also updated upgrading.txt. Tested classic tracker using demo.py. Test cases: value set to false: second update sets to chatting value set to true: update by new user sets to chatting, update by creator of issues leaves it at unread. missing config value in config.ini: error about missing value value set to non-boolean: error message reports bad value with valid values.
1 parent 6f55cf8 commit 9ab7e56

File tree

6 files changed

+168
-7
lines changed

6 files changed

+168
-7
lines changed

CHANGES.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ Features:
2020
needs to be marked as urgent or similar, e.g., Outlook uses an
2121
"Importance" header, when set to "high" it highlights the message.
2222
(Ralf Schlatterbeck)
23-
23+
- issue2550926 - Original author adding a second message shouldn't set
24+
status to 'chatting'. See upgrading.txt for details. (John Rouillard)
2425
Fixed:
2526

2627
- issue2550996 - Give better error message when running with -c

doc/upgrading.txt

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,68 @@ minutes. Using whoosh took about 2 hours. Using xapian took about 6
151151
hours. All examples were with Python 2. Anecdotal evidence shows
152152
Python 3 is faster, but YMMV.
153153

154+
Merge improvements in statusauditor.py
155+
--------------------------------------
156+
157+
By default the detector statusauditor.py will change the status from
158+
"unread" to "chatting" when a second message is added to an issue.
159+
The distributed classic and jinja templates implement this feature in
160+
their copies of ``detectors/statusauditor.py``.
161+
162+
This can be a problem. Consider a person sending email to create an
163+
issue. Then the person sends a followup message to add some additional
164+
information to the issue. The followup message will trigger the status
165+
change from "unread" to "chatting". This is misleading since the
166+
person is "chatting" with themselves.
167+
168+
Statusauditor.py has been enhanced to prevent the status from changing
169+
to "chatting" until a second user (person) adds a message. If you
170+
want this functionality, you need to merge the distributed
171+
statusauditor.py with your tracker's statusauditor.py. If you have not
172+
customized your tracker's statusauditor.py, copy the one from the
173+
distibuted template. In addition to the python file, you also must
174+
copy/merge the distributed ``detectors/config.ini`` into your
175+
tracker's detectors directory. Most people can copy
176+
``detectors/config.ini`` from the distributed templates as they won't
177+
have a ``detectors/config.ini`` file. (Note this is
178+
``detectors/config.ini`` do not confuse it with the main
179+
``config.ini`` file at the root of the tracker home.)
180+
181+
This enhancement is disabled by default. Enable it by changing the
182+
value in ``detectors/config.ini`` from:
183+
184+
chatting_requires_two_users = False
185+
186+
to
187+
188+
chatting_requires_two_users = True
189+
190+
(the values ``no`` and ``yes`` can also be used). Restart the tracker
191+
to enable the change.
192+
193+
If you don't do this quite right you will see one of two error
194+
messages in the web interface when you try to update an issue with a
195+
message::
196+
197+
Edit Error: Unsupported configuration option: Option
198+
STATUSAUDITOR_CHATTING_REQUIRES_TWO_USERS not found in
199+
detectors/config.ini.
200+
Contact tracker admin to fix.
201+
202+
This happens if detectors/config.ini is not found or is missing the
203+
``chatting_requires_two_users`` option in the ``statusauditor``
204+
section.
205+
206+
If you have an incorrect value (say you use ``T`` rather than
207+
``True``) you see a different error::
208+
209+
Edit Error: Invalid value for
210+
DETECTOR::STATUSAUDITOR_CHATTING_REQUIRES_TWO_USERS: 'T'
211+
Allowed values: yes, no
212+
213+
to fix this set the value to ``yes`` (True) or ``no`` (False).
214+
215+
154216
Migrating from 1.5.1 to 1.6.0
155217
=============================
156218

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[statusauditor]
2+
# Options for statusauditor.py
3+
#
4+
# Option: chatting_requires_two_users
5+
# Assume an issue has a status of unread and was created by the
6+
# demo user.
7+
# If False, a new message on the issue sets status to chatting.
8+
# If True, a new message sets the status to chatting only if the
9+
# author of the new message is not demo. A message sent by demo
10+
# keeps the issue status at unread. As a result a user can open
11+
# a new message and add information without setting the status
12+
# to chatting.
13+
chatting_requires_two_users = False

share/roundup/templates/classic/detectors/statusauditor.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,32 @@
1919
# SOFTWARE.
2020
#
2121

22+
from roundup.configuration import BooleanOption, InvalidOptionError
23+
2224
def chatty(db, cl, nodeid, newvalues):
23-
''' If the issue is currently 'unread', 'resolved', 'done-cbb' or None,
24-
then set it to 'chatting'
25+
''' If the issue is currently 'resolved', 'done-cbb' or None,
26+
then set it to 'chatting'. If issue is 'unread' and
27+
chatting_requires_two_users is true, set state
28+
to 'chatting' if the person adding the new message is not
29+
the same as the person who created the issue. This allows
30+
somebody to submit multiple emails describing the problem
31+
without changing it to 'chatting'. 'chatting' should
32+
indicate at least two people are 'chatting'.
2533
'''
34+
# If set to true, change state from 'unread' to 'chatting' only
35+
# if the author of the update is not the person who created the
36+
# first message (and thus the issue). If false (default ini file
37+
# setting) set 'chatting' when the second message is received.
38+
try:
39+
chatting_requires_two_users = BooleanOption(None,
40+
"detector::Statusauditor",
41+
"CHATTING_REQUIRES_TWO_USERS").str2value(
42+
db.config.detectors[
43+
'STATUSAUDITOR_CHATTING_REQUIRES_TWO_USERS' ]
44+
)
45+
except InvalidOptionError:
46+
raise InvalidOptionError("Option STATUSAUDITOR_CHATTING_REQUIRES_TWO_USERS not found in detectors/config.ini. Contact tracker admin to fix.")
47+
2648
# don't fire if there's no new message (ie. chat)
2749
if 'messages' not in newvalues:
2850
return
@@ -52,8 +74,22 @@ def chatty(db, cl, nodeid, newvalues):
5274
except KeyError:
5375
pass
5476

77+
unread = fromstates[0] # grab the 'unread' state which is first
78+
5579
# ok, there's no explicit change, so check if we are in a state that
56-
# should be changed
80+
# should be changed. First see if we should set 'chatting' based on
81+
# who opened the issue.
82+
if current_status == unread and chatting_requires_two_users:
83+
# find creator of issue and compare to currentuser making
84+
# update. If the creator is same as initial author don't
85+
# change to 'chatting'.
86+
issue_creator = cl.get(nodeid, 'creator')
87+
if issue_creator == db.getuid():
88+
# person is chatting with themselves, don't set 'chatting'
89+
return
90+
91+
# Current author is not the initiator of the issue so
92+
# we are 'chatting'.
5793
if current_status in fromstates + [None]:
5894
# yep, we're now chatting
5995
newvalues['status'] = chatting_id
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[statusauditor]
2+
# Options for statusauditor.py
3+
#
4+
# Option: chatting_requires_two_users
5+
# Assume an issue has a status of unread and was created by the
6+
# demo user.
7+
# If False, a new message on the issue sets status to chatting.
8+
# If True, a new message sets the status to chatting only if the
9+
# author of the new message is not demo. A message sent by demo
10+
# keeps the issue status at unread. As a result a user can open
11+
# a new message and add information without setting the status
12+
# to chatting.
13+
chatting_requires_two_users = False

share/roundup/templates/jinja2/detectors/statusauditor.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,32 @@
1919
# SOFTWARE.
2020
#
2121

22+
from roundup.configuration import BooleanOption, InvalidOptionError
23+
2224
def chatty(db, cl, nodeid, newvalues):
23-
''' If the issue is currently 'unread', 'resolved', 'done-cbb' or None,
24-
then set it to 'chatting'
25+
''' If the issue is currently 'resolved', 'done-cbb' or None,
26+
then set it to 'chatting'. If issue is 'unread' and
27+
chatting_requires_two_users is true, set state
28+
to 'chatting' if the person adding the new message is not
29+
the same as the person who created the issue. This allows
30+
somebody to submit multiple emails describing the problem
31+
without changing it to 'chatting'. 'chatting' should
32+
indicate at least two people are 'chatting'.
2533
'''
34+
# If set to true, change state from 'unread' to 'chatting' only
35+
# if the author of the update is not the person who created the
36+
# first message (and thus the issue). If false (default ini file
37+
# setting) set 'chatting' when the second message is received.
38+
try:
39+
chatting_requires_two_users = BooleanOption(None,
40+
"detector::Statusauditor",
41+
"CHATTING_REQUIRES_TWO_USERS").str2value(
42+
db.config.detectors[
43+
'STATUSAUDITOR_CHATTING_REQUIRES_TWO_USERS' ]
44+
)
45+
except InvalidOptionError:
46+
raise InvalidOptionError("Option STATUSAUDITOR_CHATTING_REQUIRES_TWO_USERS not found in detectors/config.ini. Contact tracker admin to fix.")
47+
2648
# don't fire if there's no new message (ie. chat)
2749
if 'messages' not in newvalues:
2850
return
@@ -52,8 +74,22 @@ def chatty(db, cl, nodeid, newvalues):
5274
except KeyError:
5375
pass
5476

77+
unread = fromstates[0] # grab the 'unread' state which is first
78+
5579
# ok, there's no explicit change, so check if we are in a state that
56-
# should be changed
80+
# should be changed. First see if we should set 'chatting' based on
81+
# who opened the issue.
82+
if current_status == unread and chatting_requires_two_users:
83+
# find creator of issue and compare to currentuser making
84+
# update. If the creator is same as initial author don't
85+
# change to 'chatting'.
86+
issue_creator = cl.get(nodeid, 'creator')
87+
if issue_creator == db.getuid():
88+
# person is chatting with themselves, don't set 'chatting'
89+
return
90+
91+
# Current author is not the initiator of the issue so
92+
# we are 'chatting'.
5793
if current_status in fromstates + [None]:
5894
# yep, we're now chatting
5995
newvalues['status'] = chatting_id

0 commit comments

Comments
 (0)