Mercurial > p > roundup > code
changeset 5971:e5acd1843517
- 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.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 07 Nov 2019 18:35:33 -0500 |
| parents | 11a9c5b2efd4 |
| children | ae35daa5baab |
| files | CHANGES.txt doc/upgrading.txt share/roundup/templates/classic/detectors/config.ini share/roundup/templates/classic/detectors/statusauditor.py share/roundup/templates/jinja2/detectors/config.ini share/roundup/templates/jinja2/detectors/statusauditor.py |
| diffstat | 6 files changed, 168 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Tue Nov 05 13:22:20 2019 +0100 +++ b/CHANGES.txt Thu Nov 07 18:35:33 2019 -0500 @@ -20,7 +20,8 @@ needs to be marked as urgent or similar, e.g., Outlook uses an "Importance" header, when set to "high" it highlights the message. (Ralf Schlatterbeck) - +- issue2550926 - Original author adding a second message shouldn't set + status to 'chatting'. See upgrading.txt for details. (John Rouillard) Fixed: - issue2550996 - Give better error message when running with -c
--- a/doc/upgrading.txt Tue Nov 05 13:22:20 2019 +0100 +++ b/doc/upgrading.txt Thu Nov 07 18:35:33 2019 -0500 @@ -151,6 +151,68 @@ hours. All examples were with Python 2. Anecdotal evidence shows Python 3 is faster, but YMMV. +Merge improvements in statusauditor.py +-------------------------------------- + +By default the detector statusauditor.py will change the status from +"unread" to "chatting" when a second message is added to an issue. +The distributed classic and jinja templates implement this feature in +their copies of ``detectors/statusauditor.py``. + +This can be a problem. Consider a person sending email to create an +issue. Then the person sends a followup message to add some additional +information to the issue. The followup message will trigger the status +change from "unread" to "chatting". This is misleading since the +person is "chatting" with themselves. + +Statusauditor.py has been enhanced to prevent the status from changing +to "chatting" until a second user (person) adds a message. If you +want this functionality, you need to merge the distributed +statusauditor.py with your tracker's statusauditor.py. If you have not +customized your tracker's statusauditor.py, copy the one from the +distibuted template. In addition to the python file, you also must +copy/merge the distributed ``detectors/config.ini`` into your +tracker's detectors directory. Most people can copy +``detectors/config.ini`` from the distributed templates as they won't +have a ``detectors/config.ini`` file. (Note this is +``detectors/config.ini`` do not confuse it with the main +``config.ini`` file at the root of the tracker home.) + +This enhancement is disabled by default. Enable it by changing the +value in ``detectors/config.ini`` from: + + chatting_requires_two_users = False + +to + + chatting_requires_two_users = True + +(the values ``no`` and ``yes`` can also be used). Restart the tracker +to enable the change. + +If you don't do this quite right you will see one of two error +messages in the web interface when you try to update an issue with a +message:: + + Edit Error: Unsupported configuration option: Option + STATUSAUDITOR_CHATTING_REQUIRES_TWO_USERS not found in + detectors/config.ini. + Contact tracker admin to fix. + +This happens if detectors/config.ini is not found or is missing the +``chatting_requires_two_users`` option in the ``statusauditor`` +section. + +If you have an incorrect value (say you use ``T`` rather than +``True``) you see a different error:: + + Edit Error: Invalid value for + DETECTOR::STATUSAUDITOR_CHATTING_REQUIRES_TWO_USERS: 'T' + Allowed values: yes, no + +to fix this set the value to ``yes`` (True) or ``no`` (False). + + Migrating from 1.5.1 to 1.6.0 =============================
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/roundup/templates/classic/detectors/config.ini Thu Nov 07 18:35:33 2019 -0500 @@ -0,0 +1,13 @@ +[statusauditor] +# Options for statusauditor.py +# +# Option: chatting_requires_two_users +# Assume an issue has a status of unread and was created by the +# demo user. +# If False, a new message on the issue sets status to chatting. +# If True, a new message sets the status to chatting only if the +# author of the new message is not demo. A message sent by demo +# keeps the issue status at unread. As a result a user can open +# a new message and add information without setting the status +# to chatting. +chatting_requires_two_users = False
--- a/share/roundup/templates/classic/detectors/statusauditor.py Tue Nov 05 13:22:20 2019 +0100 +++ b/share/roundup/templates/classic/detectors/statusauditor.py Thu Nov 07 18:35:33 2019 -0500 @@ -19,10 +19,32 @@ # SOFTWARE. # +from roundup.configuration import BooleanOption, InvalidOptionError + def chatty(db, cl, nodeid, newvalues): - ''' If the issue is currently 'unread', 'resolved', 'done-cbb' or None, - then set it to 'chatting' + ''' If the issue is currently 'resolved', 'done-cbb' or None, + then set it to 'chatting'. If issue is 'unread' and + chatting_requires_two_users is true, set state + to 'chatting' if the person adding the new message is not + the same as the person who created the issue. This allows + somebody to submit multiple emails describing the problem + without changing it to 'chatting'. 'chatting' should + indicate at least two people are 'chatting'. ''' + # If set to true, change state from 'unread' to 'chatting' only + # if the author of the update is not the person who created the + # first message (and thus the issue). If false (default ini file + # setting) set 'chatting' when the second message is received. + try: + chatting_requires_two_users = BooleanOption(None, + "detector::Statusauditor", + "CHATTING_REQUIRES_TWO_USERS").str2value( + db.config.detectors[ + 'STATUSAUDITOR_CHATTING_REQUIRES_TWO_USERS' ] + ) + except InvalidOptionError: + raise InvalidOptionError("Option STATUSAUDITOR_CHATTING_REQUIRES_TWO_USERS not found in detectors/config.ini. Contact tracker admin to fix.") + # don't fire if there's no new message (ie. chat) if 'messages' not in newvalues: return @@ -52,8 +74,22 @@ except KeyError: pass + unread = fromstates[0] # grab the 'unread' state which is first + # ok, there's no explicit change, so check if we are in a state that - # should be changed + # should be changed. First see if we should set 'chatting' based on + # who opened the issue. + if current_status == unread and chatting_requires_two_users: + # find creator of issue and compare to currentuser making + # update. If the creator is same as initial author don't + # change to 'chatting'. + issue_creator = cl.get(nodeid, 'creator') + if issue_creator == db.getuid(): + # person is chatting with themselves, don't set 'chatting' + return + + # Current author is not the initiator of the issue so + # we are 'chatting'. if current_status in fromstates + [None]: # yep, we're now chatting newvalues['status'] = chatting_id
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/roundup/templates/jinja2/detectors/config.ini Thu Nov 07 18:35:33 2019 -0500 @@ -0,0 +1,13 @@ +[statusauditor] +# Options for statusauditor.py +# +# Option: chatting_requires_two_users +# Assume an issue has a status of unread and was created by the +# demo user. +# If False, a new message on the issue sets status to chatting. +# If True, a new message sets the status to chatting only if the +# author of the new message is not demo. A message sent by demo +# keeps the issue status at unread. As a result a user can open +# a new message and add information without setting the status +# to chatting. +chatting_requires_two_users = False
--- a/share/roundup/templates/jinja2/detectors/statusauditor.py Tue Nov 05 13:22:20 2019 +0100 +++ b/share/roundup/templates/jinja2/detectors/statusauditor.py Thu Nov 07 18:35:33 2019 -0500 @@ -19,10 +19,32 @@ # SOFTWARE. # +from roundup.configuration import BooleanOption, InvalidOptionError + def chatty(db, cl, nodeid, newvalues): - ''' If the issue is currently 'unread', 'resolved', 'done-cbb' or None, - then set it to 'chatting' + ''' If the issue is currently 'resolved', 'done-cbb' or None, + then set it to 'chatting'. If issue is 'unread' and + chatting_requires_two_users is true, set state + to 'chatting' if the person adding the new message is not + the same as the person who created the issue. This allows + somebody to submit multiple emails describing the problem + without changing it to 'chatting'. 'chatting' should + indicate at least two people are 'chatting'. ''' + # If set to true, change state from 'unread' to 'chatting' only + # if the author of the update is not the person who created the + # first message (and thus the issue). If false (default ini file + # setting) set 'chatting' when the second message is received. + try: + chatting_requires_two_users = BooleanOption(None, + "detector::Statusauditor", + "CHATTING_REQUIRES_TWO_USERS").str2value( + db.config.detectors[ + 'STATUSAUDITOR_CHATTING_REQUIRES_TWO_USERS' ] + ) + except InvalidOptionError: + raise InvalidOptionError("Option STATUSAUDITOR_CHATTING_REQUIRES_TWO_USERS not found in detectors/config.ini. Contact tracker admin to fix.") + # don't fire if there's no new message (ie. chat) if 'messages' not in newvalues: return @@ -52,8 +74,22 @@ except KeyError: pass + unread = fromstates[0] # grab the 'unread' state which is first + # ok, there's no explicit change, so check if we are in a state that - # should be changed + # should be changed. First see if we should set 'chatting' based on + # who opened the issue. + if current_status == unread and chatting_requires_two_users: + # find creator of issue and compare to currentuser making + # update. If the creator is same as initial author don't + # change to 'chatting'. + issue_creator = cl.get(nodeid, 'creator') + if issue_creator == db.getuid(): + # person is chatting with themselves, don't set 'chatting' + return + + # Current author is not the initiator of the issue so + # we are 'chatting'. if current_status in fromstates + [None]: # yep, we're now chatting newvalues['status'] = chatting_id
