# HG changeset patch # User Sylvain Thénault <sylvain.thenault@logilab.fr> # Date 1269365897 -3600 # Tue Mar 23 18:38:17 2010 +0100 # Branch stable # Node ID 1d783e846e875c74d8d33df7f15490c0c8806aa0 # Parent 51f55a77be208a4c24dce1431c7d8ee10a20fba3 ticket #343091, add missing schema synchronization related to BlogEntry permissions changes diff --git a/hooks.py b/hooks.py --- a/hooks.py +++ b/hooks.py @@ -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): diff --git a/migration/1.7.2_Any.py b/migration/1.7.2_Any.py new file mode 100644 --- /dev/null +++ b/migration/1.7.2_Any.py @@ -0,0 +1,1 @@ +sync_schema_props_perm('BlogEntry') diff --git a/test/unittest_blog.py b/test/unittest_blog.py --- a/test/unittest_blog.py +++ b/test/unittest_blog.py @@ -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')