backport stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 14 Apr 2010 10:51:56 +0200
changeset 189 76aa7a5c4a2d
parent 175 df29eff84bec (current diff)
parent 188 0e9f94ed3b8c (diff)
child 190 73bef0889adc
backport stable
--- a/__pkginfo__.py	Fri Feb 26 17:43:41 2010 +0100
+++ b/__pkginfo__.py	Wed Apr 14 10:51:56 2010 +0200
@@ -4,7 +4,7 @@
 modname = 'blog'
 distname = "cubicweb-%s" % modname
 
-numversion = (1, 7, 1)
+numversion = (1, 7, 2)
 version = '.'.join(str(num) for num in numversion)
 
 license = 'LGPL'
@@ -13,7 +13,7 @@
 author_email = "contact@logilab.fr"
 web = 'http://www.cubicweb.org/project/%s' % distname
 
-short_desc = "blog component for the CubicWeb framework"
+short_desc = "blogging component for the CubicWeb framework"
 long_desc = """\
 Summary
 -------
@@ -34,13 +34,13 @@
 Specific boxes provided by this cube:
 
 - `BlogEntryArchiveBox`, displays a box with the total number of blog entries
-submitted by month for the last twelve months.
+  submitted by month for the last twelve months.
 
 - `BlogEntryListBox`, displays a box with the latest five blog entries
-published in your application as well as link to subscribe to a RSS feed.
+  published in your application as well as link to subscribe to a RSS feed.
 
 - `BlogEntrySummary`, displays a box with the list of users who submitted
-blog entries and the total number of blog entries they submitted.
+  blog entries and the total number of blog entries they submitted.
 
 This cube also provides some web services such as:
 
@@ -67,7 +67,7 @@
     ]
 
 __depends_cubes__ = {}
-__depends__ = {'cubicweb': '>= 3.6.0'}
+__depends__ = {'cubicweb': '>= 3.7.3'}
 __use__ = tuple(__depends_cubes__)
 
 # package ###
--- a/data/cubes.blog.css	Fri Feb 26 17:43:41 2010 +0100
+++ b/data/cubes.blog.css	Wed Apr 14 10:51:56 2010 +0200
@@ -4,14 +4,18 @@
 }
 
 div.post h1 {
-  font-size: 1.3em;
+  font-size: 1.7em;
   position: relative;
   border-bottom: none;
+  font-weight: normal;
 }
 
+div.entry h3, h3.title {
+  font-size: 1.0em;
+}
 div.post div.postmetadata {
   background:transparent url(postdatabg.jpg) no-repeat scroll left bottom;
-  font-size: 0.92em;
+  font-size: 0.98em;
   padding-bottom: 12px;
   padding-left: 10px;
   padding-top: 10px;
@@ -52,3 +56,14 @@
  float:right;
 }
 
+span.author {
+ float:right;
+ font-size: 1.2em;
+}
+
+div.creation_date {
+ font-size:1.2em;
+ border-bottom-style: ridge;
+ border-bottom-color: #CCC;
+ border-bottom-width: thin;
+}
--- a/debian/changelog	Fri Feb 26 17:43:41 2010 +0100
+++ b/debian/changelog	Wed Apr 14 10:51:56 2010 +0200
@@ -1,3 +1,9 @@
+cubicweb-blog (1.7.2-1) unstable; urgency=low
+
+  * new upstream release
+
+ -- Sandrine Ribeau <sandrine.ribeau@logilab.fr>  Tue, 23 Mar 2010 11:08:45 -0700
+
 cubicweb-blog (1.7.1-1) unstable; urgency=low
 
   * new upstream release
--- a/debian/control	Fri Feb 26 17:43:41 2010 +0100
+++ b/debian/control	Wed Apr 14 10:51:56 2010 +0200
@@ -9,9 +9,7 @@
 
 Package: cubicweb-blog
 Architecture: all
-Conflicts: erudi-blog, erudi-blog-server, erudi-blog-client, erudi-blog-comp
-Replaces: erudi-blog, erudi-blog-server, erudi-blog-client, erudi-blog-comp
-Depends: cubicweb-common (>= 3.6.0)
+Depends: cubicweb-common (>= 3.7.3)
 Description: blog component for the CubicWeb framework
  This CubicWeb component provides blogging functionnalities.
  .
--- a/hooks.py	Fri Feb 26 17:43:41 2010 +0100
+++ b/hooks.py	Wed Apr 14 10:51:56 2010 +0200
@@ -1,9 +1,9 @@
-from cubicweb.selectors import implements
-from cubicweb.sobjects.notification import ContentAddedView
+from cubicweb.selectors import implements, is_in_state
+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',) & is_in_state('published')
     content_attr = 'content'
 
     def subject(self):
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/migration/1.7.2_Any.py	Wed Apr 14 10:51:56 2010 +0200
@@ -0,0 +1,1 @@
+sync_schema_props_perms('BlogEntry')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/migration/1.7.3_Any.py	Wed Apr 14 10:51:56 2010 +0200
@@ -0,0 +1,4 @@
+# add group "owners" in transition "publish" of BlogEntry workflow permissions
+rql('SET T require_group G WHERE G name "owners", T transition_of W, '
+    'T name "publish", W workflow_of ET, ET name "BlogEntry"')
+commit()
--- a/migration/postcreate.py	Fri Feb 26 17:43:41 2010 +0100
+++ b/migration/postcreate.py	Wed Apr 14 10:51:56 2010 +0200
@@ -7,5 +7,5 @@
 published = bwf.add_state(_('published'))
 
 publish = bwf.add_transition(_('publish'), draft, published,
-                             ('managers',))
+                             ('managers', 'owners'))
 
--- a/test/unittest_blog.py	Fri Feb 26 17:43:41 2010 +0100
+++ b/test/unittest_blog.py	Wed Apr 14 10:51:56 2010 +0200
@@ -1,29 +1,31 @@
 """Blog unit tests"""
-import re
 
-from logilab.common.testlib import unittest_main, mock_object
+from logilab.common.testlib import unittest_main
 from cubicweb.devtools.testlib import CubicWebTC, MAILBOX
 
-from email.Header import decode_header
-from cubicweb.sobjects.notification import RenderAndSendNotificationView
-from cubicweb.server.hookhelper import SendMailOp
-
 
 class BlogTestsCubicWebTC(CubicWebTC):
     """test blog specific behaviours"""
 
     def test_notifications(self):
         req = self.request()
-        cubicweb_blog = req.create_entity('Blog', title=u'cubicweb', description=u"cubicweb c'est beau")
+        cubicweb_blog = req.create_entity('Blog', title=u'cubicweb',
+                                          description=u"cubicweb c'est beau")
         blog_entry_1 = req.create_entity('BlogEntry', title=u"hop", content=u"cubicweb hop")
-        self.execute('SET E entry_of B WHERE B eid %(beid)s, E eid %(eeid)s' % {'beid' :cubicweb_blog.eid, 'eeid' : blog_entry_1.eid})
+        blog_entry_1.set_relations(entry_of=cubicweb_blog)
         blog_entry_2 = req.create_entity('BlogEntry', title=u"yes",  content=u"cubicweb yes")
-        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})
+        blog_entry_2.set_relations(entry_of=cubicweb_blog)
         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')
 
--- a/views/secondary.py	Fri Feb 26 17:43:41 2010 +0100
+++ b/views/secondary.py	Wed Apr 14 10:51:56 2010 +0200
@@ -16,7 +16,7 @@
 from cubicweb.selectors import paginated_rset, sorted_rset, implements, \
                                authenticated_user
 from cubicweb.web.htmlwidgets import BoxLink, BoxWidget
-from cubicweb.web.views import baseviews, boxes, calendar, navigation
+from cubicweb.web.views import baseviews, boxes, calendar, navigation, workflow
 
 class BlogEntryArchiveView(StartupView):
     """control the view of a blog archive"""
@@ -61,7 +61,7 @@
             self.represent(items, year, month)
         if needmore:
             url = self._cw.build_url('view', vid='blog_archive')
-            link = u'<a href="%s" title="">[see more archives]</a>' % url
+            link = u'<a href="%s" title="">[%s]</a>' % (url, self._cw._('see more archives'))
             items.append( u'<li class="">%s</li>\n' % link )
         self.w(u'<div class="boxFrame">')
         if items:
@@ -203,19 +203,21 @@
         _ = self._cw._
         w(u'<div class="post">')
         w(u'<h1>%s</h1>' % entity.view('incontext'))
-        w(u'%s ' % entity.postinfo_description())
+        w(u'<div class="creation_date">%s</div>' %
+          self._cw.format_date(entity.creation_date))
         creator = entity.creator
         if creator:
             vtitle = _('blog entries created by %s') % creator.name()
             rql = 'Any X ORDERBY D DESC WHERE X is BlogEntry, X created_by Y, '\
                   'Y eid %s, X creation_date D' % creator.eid
             url = self._cw.build_url('view', rql=rql, vtitle=vtitle, page_size=10)
-            w(u'%s <a title="%s" href="%s">%s</a>' % (
+            w(u'<span class="author">%s <a title="%s" href="%s">%s</a></span>' % (
                 _('by'), xml_escape(vtitle), xml_escape(url), creator.name()))
         w(u'<div class="entry">')
         body = entity.printable_value('content')
         w(body)
         w(u'</div>')
+        w(u'<br class="clear"/>')
         w(u'<div class="postmetadata">%s</div>' % entity.view('post-reldata'))
         w(u'</div>')
 
@@ -229,7 +231,8 @@
         _ = lambda ertype, form='': display_name(self._cw, ertype, form)
         reldata = []
         w = reldata.append
-        if 'comments' in self._cw.vreg.schema and 'BlogEntry' in self._cw.vreg.schema.rschema('comments').objects():
+        if 'comments' in self._cw.vreg.schema and \
+               'BlogEntry' in self._cw.vreg.schema.rschema('comments').objects():
             count = self._cw.execute('Any COUNT(C) WHERE C comments B, B eid %(x)s',
                                      {'x': entity.eid}, 'x')[0][0]
             if count:
@@ -237,7 +240,8 @@
                 w(u'<a href="%s">%s %s</a>' % (url, count, _('Comment', 'plural')))
             else:
                 w(u'%s %s' % (count, _('Comment')))
-        if 'tags' in self._cw.vreg.schema and 'BlogEntry' in self._cw.vreg.schema.rschema('tags').objects():
+        if 'tags' in self._cw.vreg.schema and \
+               'BlogEntry' in self._cw.vreg.schema.rschema('tags').objects():
             tag_rset = entity.related('tags', 'object')
             if tag_rset:
                 w(u'%s %s' % (_('tags', 'object'), self._cw.view('csv', tag_rset)))
@@ -254,3 +258,11 @@
     def index_display(self, start, stop):
         return u'%s' % (int(start / self.page_size)+1)
 
+
+# WFHistoryView ###############################################################
+
+class BlogEntryWFHistoryVComponent(workflow.WFHistoryVComponent):
+    __select__ = workflow.WFHistoryVComponent.__select__ & implements('BlogEntry')
+
+    def cell_call(self, row, col, view=None):
+        pass