ticket #343091, add missing schema synchronization related to BlogEntry permissions changes stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 23 Mar 2010 18:38:17 +0100
branchstable
changeset 177 1d783e846e87
parent 176 51f55a77be20
child 178 6762f7334915
ticket #343091, add missing schema synchronization related to BlogEntry permissions changes
hooks.py
migration/1.7.2_Any.py
test/unittest_blog.py
--- a/hooks.py	Tue Mar 23 13:05:48 2010 +0100
+++ b/hooks.py	Tue Mar 23 18:38:17 2010 +0100
@@ -1,9 +1,11 @@
-from cubicweb.selectors import implements
-from cubicweb.sobjects.notification import ContentAddedView
+from cubicweb.selectors import implements, score_entity
+from cubicweb.sobjects.notification import NotificationView, StatusChangeMixIn
 
-class BlogEntryAddedView(ContentAddedView):
-    """get notified from new blogs"""
-    __select__ = implements('BlogEntry',)
+class BlogEntryPublishedView(StatusChangeMixIn, NotificationView):
+    """get notified from published blogs"""
+    __select__ = (implements('BlogEntry',)
+                  & score_entity(lambda x: x.latest_trinfo().new_state.name == 'published')
+                  )
     content_attr = 'content'
 
     def subject(self):
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/migration/1.7.2_Any.py	Tue Mar 23 18:38:17 2010 +0100
@@ -0,0 +1,1 @@
+sync_schema_props_perm('BlogEntry')
--- a/test/unittest_blog.py	Tue Mar 23 13:05:48 2010 +0100
+++ b/test/unittest_blog.py	Tue Mar 23 18:38:17 2010 +0100
@@ -21,9 +21,15 @@
         self.execute('SET E entry_of B WHERE B eid %(beid)s, E eid %(eeid)s' % {'beid' :cubicweb_blog.eid, 'eeid' : blog_entry_2.eid})
         self.assertEquals(len(MAILBOX), 0)
         self.commit()
-        self.assertEquals(len(MAILBOX), 2)
+        self.assertEquals(len(MAILBOX), 0)
+        blog_entry_1.fire_transition('publish')
+        self.commit()
+        self.assertEquals(len(MAILBOX), 1)
         mail = MAILBOX[0]
         self.assertEquals(mail.subject, '[data] hop')
+        blog_entry_2.fire_transition('publish')
+        self.commit()
+        self.assertEquals(len(MAILBOX), 2)
         mail = MAILBOX[1]
         self.assertEquals(mail.subject, '[data] yes')