количество событий у мест

remotes/origin/HEAD
Slava Kyrachevsky 9 years ago
parent 88184cfb2d
commit 39c115a3a0
  1. 5
      apps/place_conference/models.py
  2. 5
      apps/place_exposition/models.py
  3. 21
      apps/place_exposition/views.py
  4. 2
      templates/client/includes/meta.html
  5. 101
      templates/client/includes/place/place_list.html
  6. 2
      templates/client/place/place_detail.html

@ -2,6 +2,7 @@
from django.db import models
from django.contrib.contenttypes import generic
from django.db.models.signals import post_save, pre_save
from django.utils import timezone
from hvad.models import TranslatableModel, TranslatedFields, TranslationManager
from functions.custom_fields import EnumField
from functions.custom_fields import LocationField
@ -107,8 +108,8 @@ class PlaceConference(TranslatableModel, ExpoMixin):
return '/places'
def get_events_number(self):
exp = Conference.objects.filter(place=self)
return len(exp)
return Conference.objects.filter(place=self,
data_begin__gt=timezone.now()).count()
def events(self):
events = Conference.objects.filter(place=self)[:6]

@ -4,6 +4,7 @@ from django.db.models import Q
from django.contrib.contenttypes import generic
from django.db.models.signals import post_save, pre_save
from django.utils.translation import ugettext as _
from django.utils import timezone
from functools import partial
from django.conf import settings
from django.core.urlresolvers import reverse
@ -255,8 +256,8 @@ class PlaceExposition(TranslatableModel, ExpoMixin):
return duplicate
def get_events_number(self):
exp = Exposition.objects.filter(place=self)
return len(exp)
return Exposition.objects.filter(place=self,
data_begin__gt=timezone.now()).count()
class Hall(TranslatableModel):

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

@ -32,6 +32,6 @@
{% else %}
<title>{% block title_head %}{% trans 'Expomap — выставки, конференции, семинары' %}{% endblock %}</title>
<meta name="keywords" content="">
<meta name="description" content="">
<meta name="description" content="">
{% endif %}

@ -1,61 +1,56 @@
{% load static %}
{% load i18n %}
{% load static i18n %}
{% with objects=object_list %}
{% include 'client/includes/banners/tops.html' %}
<ul class="cat-list cl-places">
{% for object in object_list %}
<li class="cl-item">
<div class="cl-item-wrap clearfix">
<a target="_blank" href="{{ object.get_permanent_url }}">
<div class="cli-pict">
{% with obj=object %}
{% include 'client/includes/show_logo.html' %}
{% endwith %}
</div>
</a>
<div class="cli-info">
<div class="cli-top clearfix">
{% include 'client/includes/banners/tops.html' %}
<ul class="cat-list cl-places">
{% for object in object_list %}
<li class="cl-item">
<div class="cl-item-wrap clearfix">
<a target="_blank" href="{{ object.get_permanent_url }}">
<div class="cli-pict">
{% include 'client/includes/show_logo.html' with obj=object %}
</div>
</a>
<div class="cli-info">
<div class="cli-top clearfix">
<header>
<div class="cli-title"><a target="_blank" href="{{ object.get_permanent_url }}">{{ object.name|safe }}</a></div>
<!--<div class="cli-rate">{{ object.rating }}</div>-->
</header>
<header>
<div class="cli-title"><a target="_blank" href="{{ object.get_permanent_url }}">{{ object.name|safe }}</a></div>
{# <div class="cli-rate">{{ object.rating }}</div>#}
</header>
<div class="cli-descr">{{ object.get_type }}</div>
</div>
<div class="cli-descr">{{ object.get_type }}</div>
</div>
<div class="cli-bot clearfix">
{% if object.total_area %}
<div class="cli-dim">{{ object.total_area }} м2</div>
{% endif %}
<div class="cli-place"><a href="/places/country/{{ object.country.url }}/">{{ object.country }}</a>, <a href="/places/city/{{ object.city.url }}/">{{ object.city }}</a>
</div>
</div>
<div class="cli-bot clearfix">
{% if object.total_area %}
<div class="cli-dim">{{ object.total_area }} м2</div>
{% endif %}
<div class="cli-place"><a href="/places/country/{{ object.country.url }}/">{{ object.country }}</a>, <a href="/places/city/{{ object.city.url }}/">{{ object.city }}</a>
</div>
</div>
</div>
<div class="cli-buttons clearfix">
<div class="cli-m-buttons">
<a class="button icon-info" href="{{ object.get_permanent_url }}">{% trans 'описание' %}</a>
{% if object.get_events_number %}
<a class="button green icon-list" href="#">{% trans 'события' %} ({{ object.get_events_number }})</a>
{% endif %}
{% if object.photogallery %}
<a class="button blue icon-photo" href="{{ object.get_permanent_url }}photo/">{% trans 'фото' %}</a>
{% endif %}
</div>
<div class="cli-s-buttons">
<a class="button blue2 lc" target="_blank" href="http://www.booking.com/searchresults.html?aid={{ book_aid }}&city={{ object.city.id }}">{% trans 'Найти отели поблизости' %}</a>
</div>
<div class="cli-buttons clearfix">
<div class="cli-m-buttons">
<a class="button icon-info" href="{{ object.get_permanent_url }}">{% trans 'описание' %}</a>
{% if object.get_events_number %}
<a class="button green icon-list" href="{% url 'place_exposition_list' object.url %}">{% trans 'события' %} ({{ object.get_events_number }})</a>
{% endif %}
{% if object.photogallery %}
<a class="button blue icon-photo" href="{{ object.get_permanent_url }}photo/">{% trans 'фото' %}</a>
{% endif %}
</div>
<div class="cli-s-buttons">
<a class="button blue2 lc" target="_blank" href="http://www.booking.com/searchresults.html?aid={{ book_aid }}&city={{ object.city.id }}">{% trans 'Найти отели поблизости' %}</a>
</div>
</li>
{% if forloop.counter == 5 or objects|length < 5 %}
{% include 'client/includes/banners/catalog_inner_2.html' %}
{% endif %}
</div>
</li>
{% if forloop.counter == 5 or object_list|length < 5 %}
{% include 'client/includes/banners/catalog_inner_2.html' %}
{% endif %}
{% if forloop.counter == 10 %}
{% include 'client/includes/banners/catalog_inner.html' %}
{%endif %}
{% endfor %}
</ul>
{% endwith %}
{% if forloop.counter == 10 %}
{% include 'client/includes/banners/catalog_inner.html' %}
{%endif %}
{% endfor %}
</ul>

@ -114,7 +114,7 @@
</div>
{% endif %}
{# TODO: request optization #}
{# TODO: request optimization #}
{% if object.halls.count %}
<div class="eni-areas clearfix">
<div class="enis-col">

Loading…
Cancel
Save