diff --git a/article/managers.py b/article/managers.py index c1be6975..2de5ea6d 100644 --- a/article/managers.py +++ b/article/managers.py @@ -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 diff --git a/fabfile.py b/fabfile.py index c0cbc327..f111c53b 100644 --- a/fabfile.py +++ b/fabfile.py @@ -138,11 +138,6 @@ def stage4_firstrun(): run('python manage.py syncdb') -def stage4(): - with cd(REMOTE_HOME_DIR): - run('python manage.py syncdb') - - def ticket1395(): # stage4 with cd(REMOTE_HOME_DIR): diff --git a/proj/views.py b/proj/views.py index 10e246f3..b0a1af87 100644 --- a/proj/views.py +++ b/proj/views.py @@ -39,7 +39,9 @@ def add_seo(request): def expo_context(request): cont = {'theme_search_form': ThemeSearch(), 'expo_catalog': Exposition.catalog, - 'book_aid': settings.BOOKING_AID, 'blogs': Article.objects.main_page_blogs(), + 'book_aid': settings.BOOKING_AID, + 'main_page_blogs': Article.objects.main_page_blogs(), + 'blogs': Article.objects.every_page_blogs(), 'news_list': Article.objects.main_page_news(), 'sng_countries': settings.SNG_COUNTRIES, 'seo_text': add_seo(request), 'announce_subscribe': SubscribeAssideForm(), 'NO_EXTERNAL_JS': getattr(settings, 'NO_EXTERNAL_JS', False)} diff --git a/settings/management/commands/update_views_cache.py b/settings/management/commands/update_views_cache.py index 1a4577ce..6b63198b 100644 --- a/settings/management/commands/update_views_cache.py +++ b/settings/management/commands/update_views_cache.py @@ -18,6 +18,7 @@ update_keys = {'expo_main_page_key_%s': Exposition.objects.expo_main, 'conf_main_page_key_%s': Conference.objects.conf_main, 'main_page_news_%s': Article.objects.main_page_news, 'main_page_blogs_%s': Article.objects.main_page_blogs, + 'every_page_blogs_%s': Article.objects.every_page_blogs, 'used_expo_cities_%s': City.used.expo_cities, 'used_expo_cities_count_%s': City.used.expo_cities_with_count, 'used_conference_cities_count_%s': City.used.conference_cities_with_count, @@ -45,4 +46,4 @@ class Command(BaseCommand): key = k % lang print(key) result = func(cached=False) - cache.set(key, result, CACHE_TIME) \ No newline at end of file + cache.set(key, result, CACHE_TIME) diff --git a/templates/client/includes/index/blogs.html b/templates/client/includes/index/blogs.html index 3ef7f143..63ccb6e9 100644 --- a/templates/client/includes/index/blogs.html +++ b/templates/client/includes/index/blogs.html @@ -7,7 +7,7 @@ - \ No newline at end of file +