"Fossies" - the Fresh Open Source Software Archive
Member "roundup-2.0.0/share/roundup/templates/jinja2/detectors/statusauditor.py" (7 Nov 2019, 4705 Bytes) of package /linux/www/roundup-2.0.0.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard
) with prefixed line numbers.
Alternatively you can here view
the uninterpreted source code file.
See also the latest Fossies "Diffs"
side-by-side code changes report for "statusauditor.py": 1.6.1_vs_2.0.0
1 # Copyright (c) 2002 ekit.com Inc (http://www.ekit-inc.com/)
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to deal
5 # in the Software without restriction, including without limitation the rights
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 # copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 # SOFTWARE.
22 from roundup.configuration import BooleanOption, InvalidOptionError
24 def chatty(db, cl, nodeid, newvalues):
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'.
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.
39 chatting_requires_two_users = BooleanOption(None,
43 'STATUSAUDITOR_CHATTING_REQUIRES_TWO_USERS' ]
45 except InvalidOptionError:
46 raise InvalidOptionError("Option STATUSAUDITOR_CHATTING_REQUIRES_TWO_USERS not found in detectors/config.ini. Contact tracker admin to fix.")
48 # don't fire if there's no new message (ie. chat)
49 if 'messages' not in newvalues:
51 if newvalues['messages'] == cl.get(nodeid, 'messages'):
54 # get the chatting state ID
56 chatting_id = db.status.lookup('chatting')
57 except KeyError:
58 # no chatting state, ignore all this stuff
61 # get the current value
62 current_status = cl.get(nodeid, 'status')
64 # see if there's an explicit change in this transaction
65 if 'status' in newvalues:
66 # yep, skip
69 # determine the id of 'unread', 'resolved' and 'chatting'
70 fromstates = 
71 for state in 'unread resolved done-cbb'.split():
74 except KeyError:
77 unread = fromstates # grab the 'unread' state which is first
79 # ok, there's no explicit change, so check if we are in a state that
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'
91 # Current author is not the initiator of the issue so
92 # we are 'chatting'.
93 if current_status in fromstates + [None]:
94 # yep, we're now chatting
95 newvalues['status'] = chatting_id
98 def presetunread(db, cl, nodeid, newvalues):
99 ''' Make sure the status is set on new issues
101 if 'status' in newvalues and newvalues['status']:
104 # get the unread state ID
106 unread_id = db.status.lookup('unread')
107 except KeyError:
108 # no unread state, ignore all this stuff
111 # ok, do it
112 newvalues['status'] = unread_id
115 def init(db):
116 # fire before changes are made
117 db.issue.audit('set', chatty)
118 db.issue.audit('create', presetunread)
120 # vim: set filetype=python ts=4 sw=4 et si