|
|
|
@ -10,11 +10,12 @@ from django.template import RequestContext |
|
|
|
from django.utils import translation |
|
|
|
from django.utils import translation |
|
|
|
from django.utils.translation import ugettext as _ |
|
|
|
from django.utils.translation import ugettext as _ |
|
|
|
from django.views.generic import DetailView, FormView |
|
|
|
from django.views.generic import DetailView, FormView |
|
|
|
|
|
|
|
from django.utils import timezone |
|
|
|
from functions.cache_mixin import CacheMixin, JitterCacheMixin |
|
|
|
from functions.cache_mixin import CacheMixin, JitterCacheMixin |
|
|
|
from functions.custom_views import ListView |
|
|
|
from functions.custom_views import ListView |
|
|
|
from meta.views import MetadataMixin |
|
|
|
from meta.views import MetadataMixin |
|
|
|
from place_conference.models import PlaceConference |
|
|
|
from place_conference.models import PlaceConference |
|
|
|
|
|
|
|
from exposition.models import Exposition |
|
|
|
from .models import PlaceExposition |
|
|
|
from .models import PlaceExposition |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -131,15 +132,12 @@ class PlaceList(JitterCacheMixin, MetadataMixin, ListView): |
|
|
|
paginate_by = settings.CLIENT_PAGINATION |
|
|
|
paginate_by = settings.CLIENT_PAGINATION |
|
|
|
template_name = 'client/place/place_list.html' |
|
|
|
template_name = 'client/place/place_list.html' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_queryset(self): |
|
|
|
def get_queryset(self): |
|
|
|
#qs = super(PlaceList, self).get_queryset().order_by('-rating') |
|
|
|
qs = PlaceExposition.objects.language().select_related('country', 'city').order_by('-rating') |
|
|
|
qs= PlaceExposition.objects.language().select_related('country', 'city').all().order_by('-rating') |
|
|
|
conf_qs = PlaceConference.objects.language().select_related('country', 'city') |
|
|
|
conf_qs = PlaceConference.objects.language().all() |
|
|
|
|
|
|
|
return list(qs)+list(conf_qs) |
|
|
|
return list(qs)+list(conf_qs) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PlaceCatalogBy(JitterCacheMixin, MetadataMixin, ListView): |
|
|
|
class PlaceCatalogBy(JitterCacheMixin, MetadataMixin, ListView): |
|
|
|
cache_range = [60*30, 60*60] |
|
|
|
cache_range = [60*30, 60*60] |
|
|
|
template_name = 'client/place/catalog_by.html' |
|
|
|
template_name = 'client/place/catalog_by.html' |
|
|
|
@ -232,20 +230,27 @@ class PlaceCityCatalog(PlaceCatalog): |
|
|
|
return context |
|
|
|
return context |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PlaceExpositionListView(ListView): |
|
|
|
class PlaceExpositionListView(MetadataMixin, JitterCacheMixin, ListView): |
|
|
|
""" |
|
|
|
""" |
|
|
|
Представление перечня событий относительно места. |
|
|
|
Представление перечня событий относительно места. |
|
|
|
Переход на эту страницу происходит со страницы подробного просмотра |
|
|
|
Переход на эту страницу происходит со страницы подробного просмотра |
|
|
|
места, по ссылке "Все события" |
|
|
|
места, по ссылке "Все события" |
|
|
|
""" |
|
|
|
""" |
|
|
|
template_name = 'client/place/place_exposition_list.html' |
|
|
|
template_name = 'client/place/place_exposition_list.html' |
|
|
|
|
|
|
|
cache_range = settings.CACHE_RANGE |
|
|
|
|
|
|
|
|
|
|
|
def get_object(self): |
|
|
|
def get_object(self): |
|
|
|
slug = self.kwargs.get('slug') |
|
|
|
slug = self.kwargs.get('slug') |
|
|
|
return get_object_or_404(PlaceExposition, url=slug) |
|
|
|
return get_object_or_404(PlaceExposition, url=slug) |
|
|
|
|
|
|
|
|
|
|
|
def get_queryset(self): |
|
|
|
def get_queryset(self): |
|
|
|
return self.get_object().exposition_place.all() |
|
|
|
return Exposition.objects.filter( |
|
|
|
|
|
|
|
place=self.get_object(), data_begin__gte=timezone.now() |
|
|
|
|
|
|
|
).select_related( |
|
|
|
|
|
|
|
'country', 'city' |
|
|
|
|
|
|
|
).prefetch_related( |
|
|
|
|
|
|
|
'tag' |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs): |
|
|
|
def get_context_data(self, **kwargs): |
|
|
|
ctx = super(PlaceExpositionListView, self).get_context_data(**kwargs) |
|
|
|
ctx = super(PlaceExpositionListView, self).get_context_data(**kwargs) |
|
|
|
|