|
|
|
|
@ -1,14 +1,38 @@ |
|
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
from django.core.management.base import BaseCommand, CommandError |
|
|
|
|
from django.test.client import RequestFactory |
|
|
|
|
from django.core.management.base import BaseCommand |
|
|
|
|
from django.utils import translation |
|
|
|
|
from django.conf import settings |
|
|
|
|
from exposition.views import ExpositionByCity |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from django.core.cache import cache |
|
|
|
|
from exposition.models import Exposition |
|
|
|
|
from conference.models import Conference |
|
|
|
|
from article.models import Article |
|
|
|
|
from city.models import City |
|
|
|
|
from country.models import Country, Area |
|
|
|
|
from theme.models import Theme, Tag |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CACHE_TIME = 300 |
|
|
|
|
update_keys = {'expo_main_page_key_%s': Exposition.objects.expo_main, |
|
|
|
|
'country_area_all_%s': Area.objects.all_sorted, |
|
|
|
|
'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, |
|
|
|
|
'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, |
|
|
|
|
'used_conference_cities_%s': City.used.conference_cities, |
|
|
|
|
'used_cities_%s': City.used.cities, |
|
|
|
|
'used_expo_countries_%s': Country.objects.expo_countries, |
|
|
|
|
'used_expo_countries_count_%s': Country.objects.expo_countries_with_count, |
|
|
|
|
'used_conference_countries_count_%s': Country.objects.conference_countries_with_count, |
|
|
|
|
'used_conference_countries_%s': Country.objects.conference_countries, |
|
|
|
|
'used_expo_themes_%s': Theme.active.expo_themes, |
|
|
|
|
'used_expo_themes_count_%s': Theme.active.expo_themes_with_count, |
|
|
|
|
'used_conference_themes_count_%s': Theme.active.conference_themes_with_count, |
|
|
|
|
'used_conference_tags_%s': Tag.active.conference_tags, |
|
|
|
|
'used_expo_tags_count_%s': Tag.active.expo_themes_with_count, |
|
|
|
|
'used_conference_tags_count_%s': Tag.active.conference_themes_with_count} |
|
|
|
|
|
|
|
|
|
class Command(BaseCommand): |
|
|
|
|
def handle(self, *args, **options): |
|
|
|
|
@ -16,11 +40,18 @@ class Command(BaseCommand): |
|
|
|
|
|
|
|
|
|
for lang in langs: |
|
|
|
|
translation.activate(lang) |
|
|
|
|
for k, func in update_keys.iteritems(): |
|
|
|
|
|
|
|
|
|
key = k % lang |
|
|
|
|
print(key) |
|
|
|
|
if key in cache: |
|
|
|
|
print('exist') |
|
|
|
|
else: |
|
|
|
|
print('not exist') |
|
|
|
|
result = func() |
|
|
|
|
cache.set(key, result, CACHE_TIME) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
request = RequestFactory().get('/expo/city/') |
|
|
|
|
view = ExpositionByCity.as_view() |
|
|
|
|
response = view(request) |
|
|
|
|
print(lang) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print('success') |
|
|
|
|
|