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

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.db import models
from django.contrib.contenttypes import generic from django.contrib.contenttypes import generic
from django.db.models.signals import post_save, pre_save from django.db.models.signals import post_save, pre_save
from django.utils import timezone
from hvad.models import TranslatableModel, TranslatedFields, TranslationManager from hvad.models import TranslatableModel, TranslatedFields, TranslationManager
from functions.custom_fields import EnumField from functions.custom_fields import EnumField
from functions.custom_fields import LocationField from functions.custom_fields import LocationField
@ -107,8 +108,8 @@ class PlaceConference(TranslatableModel, ExpoMixin):
return '/places' return '/places'
def get_events_number(self): def get_events_number(self):
exp = Conference.objects.filter(place=self) return Conference.objects.filter(place=self,
return len(exp) data_begin__gt=timezone.now()).count()
def events(self): def events(self):
events = Conference.objects.filter(place=self)[:6] 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.contrib.contenttypes import generic
from django.db.models.signals import post_save, pre_save from django.db.models.signals import post_save, pre_save
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.utils import timezone
from functools import partial from functools import partial
from django.conf import settings from django.conf import settings
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
@ -255,8 +256,8 @@ class PlaceExposition(TranslatableModel, ExpoMixin):
return duplicate return duplicate
def get_events_number(self): def get_events_number(self):
exp = Exposition.objects.filter(place=self) return Exposition.objects.filter(place=self,
return len(exp) data_begin__gt=timezone.now()).count()
class Hall(TranslatableModel): class Hall(TranslatableModel):

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

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

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

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

Loading…
Cancel
Save