|
|
|
|
@ -40,6 +40,17 @@ class ArticleManager(TranslationManager): |
|
|
|
|
cache.set(key, news, self.cache_time) |
|
|
|
|
return news |
|
|
|
|
|
|
|
|
|
def every_page_blogs(self, cached=True): |
|
|
|
|
lang = translation.get_language() |
|
|
|
|
key = 'every_page_blogs_%s' % lang |
|
|
|
|
if cached and key in cache: |
|
|
|
|
cached_blogs = cache.get(key) |
|
|
|
|
return cached_blogs |
|
|
|
|
else: |
|
|
|
|
blogs = list(self.blogs().filter(publish_date__isnull=False).order_by('-publish_date')[:3]) |
|
|
|
|
cache.set(key, blogs, self.cache_time) |
|
|
|
|
return blogs |
|
|
|
|
|
|
|
|
|
def main_page_blogs(self, cached=True): |
|
|
|
|
lang = translation.get_language() |
|
|
|
|
key = 'main_page_blogs_%s' % lang |
|
|
|
|
@ -47,6 +58,6 @@ class ArticleManager(TranslationManager): |
|
|
|
|
cached_blogs = cache.get(key) |
|
|
|
|
return cached_blogs |
|
|
|
|
else: |
|
|
|
|
blogs = list(self.blogs().filter(publish_date__isnull=False).order_by('-publish_date')[:3]) |
|
|
|
|
blogs = list(self.blogs().filter(publish_date__isnull=False, main_page=True).order_by('-publish_date')[:3]) |
|
|
|
|
cache.set(key, blogs, self.cache_time) |
|
|
|
|
return blogs |
|
|
|
|
|