fix nosy list configuration stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 16 Sep 2010 15:17:26 +0200
branchstable
changeset 625 ee0c4b4eb8e0
parent 624 b8c11c296fc0
child 626 a04d3b5e2738
fix nosy list configuration * drop User interested_in TC relation * don't propagate on has_apycot_environment * don't propagate on existing TE when some user is added/removed from the nosylist
hooks.py
migration/2.0.1_Any.py
schema.py
test/unittest_hooks.py
--- a/hooks.py	Thu Sep 16 15:12:59 2010 +0200
+++ b/hooks.py	Thu Sep 16 15:17:26 2010 +0200
@@ -267,5 +267,15 @@
 else:
     # XXX that does not mean the nosylist cube is used by the instance, but it
     # shouldn't matter anyway
-    nosylist.S_RELS |= set(('has_apycot_environment',))
-    nosylist.O_RELS |= set(('use_environment', 'using_config'))
+    nosylist.O_RELS |= set(('using_environment',))
+    # do not propagate from Project to PE, should ask explicitly for apycot notifications
+    #nosylist.S_RELS |= set(('has_apycot_environment',))
+
+    # don't propagate to existing environment when a user is added/removed from the
+    # nosylist
+    try:
+        nosylist.NosyListAddPropagationHook.skip_object_relations.add('using_environment')
+    except AttributeError:
+        nosylist.NosyListAddPropagationHook.skip_object_relations = skip = set()
+        nosylist.NosyListDelPropagationHook.skip_object_relations = skip
+        skip.add('using_environment')
--- a/migration/2.0.1_Any.py	Thu Sep 16 15:12:59 2010 +0200
+++ b/migration/2.0.1_Any.py	Thu Sep 16 15:17:26 2010 +0200
@@ -2,6 +2,8 @@
     ask_confirm=True)
 commit()
 
-
-
-
+rql('SET U interested_in PE WHERE TC use_environment PE, '
+    'U interested_in TC, NOT U interested_in PE',
+    ask_confirm=True)
+drop_relation_definition('CWUser', 'interested_in', 'TestConfig')
+drop_relation_definition('TestConfig', 'nosy_list', 'CWUser')
--- a/schema.py	Thu Sep 16 15:12:59 2010 +0200
+++ b/schema.py	Thu Sep 16 15:17:26 2010 +0200
@@ -49,10 +49,10 @@
     class interested_in(RelationDefinition):
         '''users to notify of changes concerning this entity'''
         subject = 'CWUser'
-        object = ('ProjectEnvironment', 'TestConfig')
+        object = 'ProjectEnvironment'
 
     class nosy_list(RelationDefinition):
-        subject = ('ProjectEnvironment', 'TestConfig', 'TestExecution')
+        subject = ('ProjectEnvironment', 'TestExecution')
         object = 'CWUser'
 
 
--- a/test/unittest_hooks.py	Thu Sep 16 15:12:59 2010 +0200
+++ b/test/unittest_hooks.py	Thu Sep 16 15:17:26 2010 +0200
@@ -80,6 +80,17 @@
 
 URL: http://testing.fr/cubicweb/projectenvironment/lgce/lgc/<EID>''')
 
+    def test_nosy_list_propagation(self):
+        self.login('narval', password='narval0')
+        plan = self.start_lgc_tests()
+        self.commit()
+        self.restore_connection()
+        self.execute('SET X interested_in PE WHERE X login "anon", PE eid %(pe)s',
+                     {'pe': self.lgce.eid})
+        self.commit()
+        # do not propagate to existing test execution
+        self.failIf('anon' in [u.login for u in plan.nosy_list])
+
 
 HGREPO = os.path.join(INPUTS_DIR, u'hgrepo')
 def setup_module(*args, **kwargs):