objects = translations.TranslatedObjectManager()
+ def entries_count(self):
+ return self.blogentries.count()
+
def __unicode__(self):
trans = translations.TranslatedObjectMixin.__unicode__(self)
return trans or _('Unnamed category')
-
class CategoryTranslation(translations.Translation(Category)):
"""
Category translation
return self.title
def get_absolute_url(self):
- return reverse('cloudcmsblog_entries_archive', 'cloudcmsblog.urls', (), {
+ r = reverse('cloudcmsblog_entries_archive', 'cloudcmsblog.urls', (), {
'category': self.slug,
})
+ # ugly hack to fix proper application reverse url
+ BLOG_URL = ""
+ try:
+ BLOG_URL = get_blog_page().get_navigation_url()
+ except Exception, e:
+ print e
+
+ if r.startswith(BLOG_URL):
+ return r
+ else:
+ return BLOG_URL + r.lstrip('/')
+
+
def save(self, *args, **kwargs):
if not self.slug:
self.slug = slugify(self.title)
def back_url(self):
return get_blog_page().get_navigation_url()
-
# Feincms navigation extension
class BlogCategoriesNavigationExtension(NavigationExtension):
"""
url=url,
lft=0,
rght=0,
+ level=page.level + 1, # blog categories are nested, assign correct level
slug=category.translation.slug,
)