web/hosts/issues/detectors nosyreaction.py,1.2,1.3

Tobias Hunger <[email protected]> Mon, 25 Aug 2003 11:28:57 -0500
Newsgroups gmane.comp.video.fresco.cvs
Message-ID <[email protected]>
Update of /cvs/fresco/web/hosts/issues/detectors
In directory purcel:/tmp/cvs-serv15538/detectors

Modified Files:
	nosyreaction.py 
Log Message:
Add users to nosy list if they are interessted in the category of the bug.
You could set this up for a while, now it will work for any bug that
has it's category set/changed.


Index: nosyreaction.py
===================================================================
RCS file: /cvs/fresco/web/hosts/issues/detectors/nosyreaction.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- nosyreaction.py	23 Oct 2002 01:51:19 -0000	1.2
+++ nosyreaction.py	25 Aug 2003 16:28:54 -0000	1.3
@@ -111,11 +111,27 @@
     # that's it, save off the new nosy list
     newvalues['nosy'] = current.keys()
 
+def add_defaults(db, cl, nodeid, newvalues):
+    if newvalues.has_key('components'):
+        users = [ ]
+        if newvalues.has_key('nosy'):
+            users = newvalues['nosy']
+	elif not nodeid is None:
+	    users = cl.get(nodeid, 'nosy');
+        for u in db.user.list():
+            for c in newvalues['components']:
+                if c in db.user.get(u, 'add_to_all_nosy_lists') and not u in users:
+	            users.append(u)
+		    break
+        if users:
+            newvalues['nosy'] = users;
+    updatenosy(db, cl, nodeid, newvalues)
+
 def init(db):
     db.bug.react('create', nosyreaction)
     db.bug.react('set', nosyreaction)
-    db.bug.audit('create', updatenosy)
-    db.bug.audit('set', updatenosy)
+    db.bug.audit('create', add_defaults)
+    db.bug.audit('set', add_defaults)
 
     db.task.react('create', nosyreaction)
     db.task.react('set', nosyreaction)