diff --git a/entities.py b/entities.py index 3e708b97e86770a3c4841b1f8b52532e14e611d4_ZW50aXRpZXMucHk=..d6f708a74260b08a4cdc62389867065f843a83d0_ZW50aXRpZXMucHk= 100644 --- a/entities.py +++ b/entities.py @@ -9,7 +9,32 @@ from cubicweb.utils import todate from cubicweb.entities import AnyEntity, fetch_config -from cubicweb.interfaces import ICalendarViews, ICalendarable, ISiocItem, ISiocContainer +from cubicweb.interfaces import (ICalendarViews, ICalendarable, + ISiocItem, ISiocContainer) + + +class Blog(AnyEntity): + """customized class for Blog entities""" + + id = 'Blog' + __implements__ = AnyEntity.__implements__ + (ISiocContainer,) + + def rss_feed_url(self): + if self.rss_url: + return self.rss_url + rql = ('Any E ORDERBY D DESC ' + 'WHERE E is BlogEntry, E entry_of X, X eid %s, E creation_date D' + return self.build_url(rql=rql % self.eid, vid='rss', + vtitle=self.dc_title()) + + # isioc interface ########################################################## + + def isioc_type(self): + return 'Weblog' + + def isioc_items(self): + return self.reverse_entry_of + class BlogEntry(AnyEntity): """customized class for BlogEntry entities""" @@ -24,7 +49,11 @@ def dc_description(self, format='text/plain'): return self.printable_value('content', format=format) - ## calendar interfaces #################################################### + def parent(self): + return self.entry_of and self.entry_of[0] or None + + # calendar interfaces ###################################################### + @property def start(self): return self.creation_date @@ -48,8 +77,9 @@ descr = u'%s %s' % (_('posted on'), self.format_date(self.creation_date)) return descr - # isioc interface + # isioc interface ########################################################## + def isioc_content(self): return self.content def isioc_container(self): @@ -52,12 +82,10 @@ def isioc_content(self): return self.content def isioc_container(self): - rset = self.related('entry_of') - entity = rset.get_entity(0, 0) - return entity + return self.parent() def isioc_type(self): return 'BlogPost' def isioc_replies(self): @@ -59,8 +87,9 @@ def isioc_type(self): return 'BlogPost' def isioc_replies(self): + # XXX link to comments return [] def isioc_topics(self): @@ -64,4 +93,5 @@ return [] def isioc_topics(self): + # XXX link to tags, folders? return [] @@ -67,23 +97,1 @@ return [] - - -class Blog(AnyEntity): - """customized class for Blog entities""" - - id = 'Blog' - __implements__ = AnyEntity.__implements__ + (ISiocContainer,) - - def rss_feed_url(self): - if self.rss_url: - return self.rss_url - rql = 'Any E ORDERBY D DESC WHERE E is BlogEntry, E entry_of X, X eid %s, E creation_date D' % self.eid - return self.build_url(rql=rql, vid='rss', vtitle=self.dc_title()) - - # isioc interface - def isioc_type(self): - return 'Weblog' - - def isioc_items(self): - return self.reverse_entry_of - -