1374: Этап №4 - Управление главной страницей

remotes/origin/mobile_from_stage4
Alexander Burdeiny 10 years ago
parent 5d125ea8e4
commit 4254662a5f
  1. 13
      article/managers.py
  2. 5
      fabfile.py
  3. 4
      proj/views.py
  4. 3
      settings/management/commands/update_views_cache.py
  5. 4
      templates/client/includes/index/blogs.html

@ -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

5
fabfile.py vendored

@ -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):

@ -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)}

@ -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)
cache.set(key, result, CACHE_TIME)

@ -7,7 +7,7 @@
<div class="more-link"><a class="more" href="/blogs/">{% trans 'Все обзоры' %}</a></div>
</header>
<ul>
{% for blog in blogs %}
{% for blog in main_page_blogs %}
<li>
<a href="{{ blog.get_permanent_url }}">
<span class="mpr-pict">
@ -18,4 +18,4 @@
</li>
{% endfor %}
</ul>
</div>
</div>

Loading…
Cancel
Save