You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

65 lines
3.0 KiB

# -*- coding: utf-8 -*-
from django.core.context_processors import csrf
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.views.generic import TemplateView
from django.conf import settings
from exposition.models import Exposition
from theme.models import Theme
from news.models import News
from article.models import Article
from functions.cache_mixin import JitterCacheMixin, CacheMixin
from functions.forms import ThemeSearch, PlaceSearch
from functions.search_forms import EventSearchForm, ExpositionSearchForm
from functions.custom_views import ExpoListView
from accounts.forms import RegistrationCompleteForm
def expo_context(request):
banners_themes = [24, 34, 4]
banner_tags = [141, 142, 143, 156, 206, 231, 232, 390, 391, 400, 457, 500, 536, 537, 539, 457, 500, 686, 715, 765, 766, 857, 927, 964, 971, 972, 987, 1009, 1010, 1021, 2508, 2509, 2516, 2518, 2536, 2568, 2583, 2585, 3811, 3940, 4130, 4192, 4236, 4512, 4841, 5353, 5532, 5854, 106, 107, 195, 380, 930, 931, 932, 3845, 3846, 3863, 3873, 4141, 4142, 4343, 4344, 4347, 211, 212, 277, 631]
cont = {'theme_search_form': ThemeSearch(), 'expo_catalog': Exposition.catalog,
'book_aid': settings.BOOKING_AID, 'blogs': Article.objects.main_page_blogs(),
'news_list': Article.objects.main_page_news(), 'sng_countries': settings.SNG_COUNTRIES,
'banner_themes' : banners_themes, 'banner_tags' : banner_tags
}
user = request.user
if not user.is_anonymous() and not user.url:
cont.update({'reg_complete': RegistrationCompleteForm(instance=user)})
if not request.GET:
cont.update({'search_form': ExpositionSearchForm()})
return cont
def error404(request):
context = {}
expo_themes = Theme.active.expo_themes_with_count()
conf_themes = Theme.active.conference_themes_with_count()
context.update({'expo_themes': expo_themes, 'conf_themes': conf_themes})
return render_to_response('client/404.html', context, context_instance=RequestContext(request))
class MainPageView(JitterCacheMixin,TemplateView):
cache_range = settings.CACHE_RANGE
template_name = 'index.html'
def get_context_data(self, **kwargs):
context = super(MainPageView, self).get_context_data(**kwargs)
events = Exposition.objects.language().select_related('country', 'city', 'place').filter(main_page__gte=1).order_by('-main_page')
exposition_themes = Theme.objects.language().order_by('-main_page').filter(types=Theme.types.exposition)[:6]
conference_themes = Theme.objects.language().order_by('-main_page').filter(types=Theme.types.conference)[:6]
args = {'events': events, 'exposition_themes': exposition_themes, 'conference_themes': conference_themes,
'search_form': ExpositionSearchForm, 'search_action': '/expo/search/'}
context.update(args)
return context
class AdvertisingView(TemplateView):
template_name = 'simple_pages/advertising.html'
class AboutView(TemplateView):
template_name = 'simple_pages/about.html'