From aa01b8273c935c27b0606f77276e9c7454e2a089 Mon Sep 17 00:00:00 2001 From: Ivan Kovalkovskyi Date: Wed, 23 Sep 2015 15:45:12 +0300 Subject: [PATCH 1/4] calendar indexOutOfRange bug fixed --- core/views.py | 69 +++++++++++++------------ templates/client/accounts/calendar.html | 7 ++- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/core/views.py b/core/views.py index 03e01142..0ec0cb16 100644 --- a/core/views.py +++ b/core/views.py @@ -265,36 +265,39 @@ from django.core.urlresolvers import reverse def download_workbook(request): lang = get_language() data = request.GET - qs = [] - for i,obj in enumerate(data): - if data.get('data[%i][name]'%i) == 'expo': - qs.append(Exposition.objects.language(lang).get(id=data['data[%i][value]'%i])) - elif data.get('data[%i][name]'%i) == 'conf': - qs.append(Conference.objects.language(lang).get(id=data['data[%i][value]'%i])) - - earliest_event = qs[0].data_begin - for i, obj in enumerate(qs, start=1): - if obj.data_begin < earliest_event: - earliest_event = obj.data_begin - setattr(obj, 'number', i) - setattr(obj, 'dates', u'%s - %s'%(obj.data_begin.strftime('%d %B %Y'),obj.data_end.strftime('%d %B %Y'))) - setattr(obj, 'full_place', u'%s, %s, %s' % (obj.country, obj.city, getattr(obj.place, 'name', ''))) - try: - setattr(obj, 'link', u'http://www.expomap.ru%s)'%obj.get_absolute_url()) - except: - setattr(obj, 'link', u'http://www.expomap.ru%s)'%obj.get_permanent_url()) - - columns = ( - 'number', - 'name', - 'dates', - 'main_title', - 'full_place', - 'participation_note', - 'link') - - workbook = queryset_to_workbook(qs, columns, earliest_event) - response = HttpResponse(content_type='application/vnd.ms-excel') - response['Content-Disposition'] = 'attachment; filename="My calendar.xls"' - workbook.save(response) - return response + if data: + qs = [] + for i,obj in enumerate(data): + if data.get('data[%i][name]'%i) == 'expo': + qs.append(Exposition.objects.language(lang).get(id=data['data[%i][value]'%i])) + elif data.get('data[%i][name]'%i) == 'conf': + qs.append(Conference.objects.language(lang).get(id=data['data[%i][value]'%i])) + + earliest_event = qs[0].data_begin + for i, obj in enumerate(qs, start=1): + if obj.data_begin < earliest_event: + earliest_event = obj.data_begin + setattr(obj, 'number', i) + setattr(obj, 'dates', u'%s - %s'%(obj.data_begin.strftime('%d %B %Y'),obj.data_end.strftime('%d %B %Y'))) + setattr(obj, 'full_place', u'%s, %s, %s' % (obj.country, obj.city, getattr(obj.place, 'name', ''))) + try: + setattr(obj, 'link', u'http://www.expomap.ru%s)'%obj.get_absolute_url()) + except: + setattr(obj, 'link', u'http://www.expomap.ru%s)'%obj.get_permanent_url()) + + columns = ( + 'number', + 'name', + 'dates', + 'main_title', + 'full_place', + 'participation_note', + 'link') + + workbook = queryset_to_workbook(qs, columns, earliest_event) + response = HttpResponse(content_type='application/vnd.ms-excel') + response['Content-Disposition'] = 'attachment; filename="My calendar.xls"' + workbook.save(response) + return response + else: + return HttpResponseRedirect(request.META.get('HTTP_REFERER'), "/profile/calendar/") diff --git a/templates/client/accounts/calendar.html b/templates/client/accounts/calendar.html index ad9766c6..d49542e5 100644 --- a/templates/client/accounts/calendar.html +++ b/templates/client/accounts/calendar.html @@ -65,7 +65,12 @@ } console.log(clear_list); var query = $.param({data:clear_list}); - window.location.href = "/profile/calendar/export/?" + query; + if(clear_list.Length > 0){ + window.location.href = "/profile/calendar/export/?" + query; + } + else{ + alert({% trans "Не выбрано ни одного события!" %}) + } }); }) From 515073c6ea01497bd0c03b1922ca10379056e8a9 Mon Sep 17 00:00:00 2001 From: Ivan Kovalkovskyi Date: Wed, 23 Sep 2015 15:46:26 +0300 Subject: [PATCH 2/4] specialist catalog search fixed and improved --- specialist_catalog/admin_urls.py | 16 +++++----- specialist_catalog/forms.py | 2 +- specialist_catalog/models.py | 3 +- specialist_catalog/views.py | 30 ++++++------------ templates/admin/specialist/catalog_all.html | 35 +++++++++++++++------ templates/admin/specialist/catalog_new.html | 10 +++--- 6 files changed, 49 insertions(+), 47 deletions(-) diff --git a/specialist_catalog/admin_urls.py b/specialist_catalog/admin_urls.py index df5e4ea6..d6b0444a 100644 --- a/specialist_catalog/admin_urls.py +++ b/specialist_catalog/admin_urls.py @@ -5,16 +5,14 @@ from .views import * urlpatterns = patterns('', url(r'^specialist/new/$', SpecialistCreateView.as_view(), name='specialist_new'), url(r'^specialist/all/$', SpecialistListView.as_view(), name='specialist_all'), - url(r'^specialist/edit/(?P\d{1,4})/$', SpecialistUpdateView.as_view(), name='specialist_edit'), - url(r'^specialist/delete/(?P\d{1,4})/$', SpecialistDeleteView.as_view(), name='specialist_delete'), + url(r'^specialist/edit/(?P\d{1,6})/$', SpecialistUpdateView.as_view(), name='specialist_edit'), + url(r'^specialist/delete/(?P\d{1,6})/$', SpecialistDeleteView.as_view(), name='specialist_delete'), url(r'^catalog/new/$', CatalogCreateView.as_view(), name='catalog_new'), url(r'^catalog/all/$', CatalogListView.as_view(), name='catalog_all'), - url(r'^catalog/city/$', CatalogCityView.as_view(), name='catalog_city'), - url(r'^catalog/country/$', CatalogCountryView.as_view(), name='catalog_country'), - url(r'^catalog/edit/(?P\d{1,4})/$', CatalogUpdateView.as_view(), name='catalog_edit'), - url(r'^catalog/delete/(?P\d{1,4})/$', CatalogDeleteView.as_view(), name='catalog_delete'), - url(r'^catalog/(?P\d{1,4})/add_feedback/$', FeedbackCreateView.as_view(), name='feedback_new'), + url(r'^catalog/edit/(?P\d{1,6})/$', CatalogUpdateView.as_view(), name='catalog_edit'), + url(r'^catalog/delete/(?P\d{1,6})/$', CatalogDeleteView.as_view(), name='catalog_delete'), + url(r'^catalog/(?P\d{1,6})/add_feedback/$', FeedbackCreateView.as_view(), name='feedback_new'), #url(r'^catalog/(?P\d{1,4})/feedbacks/$', FeedbackListView.as_view(), name='feedback_all'), - url(r'^catalog/(?P\d{1,4})/feedback/(?P\d{1,4})/$', FeedbackUpdateView.as_view(), name='feedback_edit'), - url(r'^feedback/delete/(?P\d{1,4})/$', FeedbackDeleteView.as_view(), name='feedback_delete'), + url(r'^catalog/(?P\d{1,6})/feedback/(?P\d{1,4})/$', FeedbackUpdateView.as_view(), name='feedback_edit'), + url(r'^feedback/delete/(?P\d{1,6})/$', FeedbackDeleteView.as_view(), name='feedback_delete'), ) \ No newline at end of file diff --git a/specialist_catalog/forms.py b/specialist_catalog/forms.py index 5bdb1388..7571b53a 100644 --- a/specialist_catalog/forms.py +++ b/specialist_catalog/forms.py @@ -22,7 +22,7 @@ class SpecialistCatalogForm(TranslatableModelForm): class Meta: model = SpecialistCatalog - fields = ['price', 'currency', 'logo_preview', 'main_descr', 'place_photo', + fields = ['price', 'currency', 'logo', 'main_descr', 'place_photo', 'specialists', 'city', 'country', 'type', 'title', 'benefits', 'big_cities'] widgets = { 'type': forms.Select(choices=(('1', 'Country'), ('2', 'City'))), diff --git a/specialist_catalog/models.py b/specialist_catalog/models.py index 36a7b578..f92a0cd3 100644 --- a/specialist_catalog/models.py +++ b/specialist_catalog/models.py @@ -28,13 +28,14 @@ class Specialist(models.Model): class SpecialistCatalog(TranslatableModel): price = models.IntegerField(verbose_name=u"Цена", default=200) currency = models.CharField(max_length=255, verbose_name=u"Валюта", default=u"EUR") - logo_preview = models.ImageField(verbose_name=u"Логотип", blank=True, upload_to='specialist_catalog/logo_preview/') + logo = models.ImageField(db_column= "logo_preview", verbose_name=u"Логотип", blank=True, upload_to='specialist_catalog/logo_preview/') place_photo = models.ImageField(verbose_name=u"Фото для города", blank=True, upload_to='specialist_catalog/place_photo/') specialists = models.ManyToManyField(Specialist, verbose_name=u"Специалисты", blank=True) city = models.ForeignKey(City, on_delete=models.PROTECT, verbose_name=u"Город", blank=True, null=True) country = models.ForeignKey(Country, on_delete=models.PROTECT, verbose_name=u"Страна", blank=False) type = models.PositiveSmallIntegerField(verbose_name=u"Тип(Страна/Город)", default=2) + objects = TranslationManager() translations = TranslatedFields( title=models.CharField(max_length=255, verbose_name=u"Заголовок"), diff --git a/specialist_catalog/views.py b/specialist_catalog/views.py index b7ed1b44..49ff483d 100644 --- a/specialist_catalog/views.py +++ b/specialist_catalog/views.py @@ -75,30 +75,18 @@ class CatalogListView(ListView): template_name = 'admin/specialist/catalog_all.html' paginate_by = settings.ADMIN_PAGINATION - -class CatalogCityView(ListView): - model = SpecialistCatalog - template_name = 'admin/specialist/catalog_all.html' - paginate_by = settings.ADMIN_PAGINATION - - def get_queryset(self): - query = self.request.GET.get('query', None) - qs = self.model.objects.language().filter(type=2) - if query: - qs = qs.filter(title__icontains=query) - return qs - - -class CatalogCountryView(ListView): - model = SpecialistCatalog - template_name = 'admin/specialist/catalog_all.html' - paginate_by = settings.ADMIN_PAGINATION - def get_queryset(self): - query = self.request.GET.get('query', None) - qs = self.model.objects.language().filter(type=1) + _GET = self.request.GET + query, city, country, only_cntry = _GET.get('query'), _GET.get('city'), _GET.get('country'), _GET.get('only_countries') + qs = self.model.objects.language() + if only_cntry: + qs = qs.filter(type=1) if query: qs = qs.filter(title__icontains=query) + if city: + qs = qs.filter(city__translations__name__icontains=city) + if country: + qs = qs.filter(country__translations__name__icontains=country) return qs diff --git a/templates/admin/specialist/catalog_all.html b/templates/admin/specialist/catalog_all.html index 6adcc0ee..ae0b720e 100644 --- a/templates/admin/specialist/catalog_all.html +++ b/templates/admin/specialist/catalog_all.html @@ -1,5 +1,6 @@ {% extends 'base.html' %} {% load thumbnail %} +{% load i18n %} {% block body %}
@@ -7,24 +8,38 @@
- - + + + + +
- +
-

Все каталоги специалистов

+

{% trans "Все каталоги специалистов" %}

- - + + @@ -34,16 +49,16 @@ - + @@ -51,7 +66,7 @@
Заголовок{% if request.path == "/admin/specialist_catalog/catalog/city/" %}Город{% elif request.path == "/admin/specialist_catalog/catalog/country/" %}Страна{% else %}Страна/Город{% endif %}{% trans "Заголовок" %}{% trans 'Страна/Город' %} Link  
{{ item.title }} {% if item.type == 1%}{{ item.country.name }}{% else %}{{ item.city.name }}{% endif %}на сайте{% trans "на сайте" %} - Изменить + {% trans "Изменить" %} - Удалить + {% trans "Удалить" %}
- Добавить + {% trans "Добавить" %}
{% include 'admin/includes/admin_pagination.html' %} diff --git a/templates/admin/specialist/catalog_new.html b/templates/admin/specialist/catalog_new.html index f938184c..f66f8d09 100644 --- a/templates/admin/specialist/catalog_new.html +++ b/templates/admin/specialist/catalog_new.html @@ -103,12 +103,12 @@ {{ form.specialists.errors }}
- {# logo_preview #} -
- + {# logo #} +
+
- {{ form.logo_preview }} - {{ form.logo_preview.errors }} + {{ form.logo }} + {{ form.logo.errors }}
{# place_photo #} From dde59aee558bed05f27a9d5548c4dfdda7bd17b8 Mon Sep 17 00:00:00 2001 From: Ivan Kovalkovskyi Date: Wed, 23 Sep 2015 18:37:21 +0300 Subject: [PATCH 3/4] banner statistic period search --- expobanner/admin.py | 37 +++++++++++-- templates/admin/expobanner/banner_stat.html | 31 ++++++++++- templates/admin/expobanner/main_stat.html | 36 ++++++++++++- templates/admin/expobanner/paid_stat.html | 31 ++++++++++- templates/client/blank.html | 6 ++- .../client/exposition/exposition_detail.html | 2 +- .../conference/default_description.html | 28 +++++----- .../exposition/default_description.html | 54 +++++++++++-------- 8 files changed, 181 insertions(+), 44 deletions(-) diff --git a/expobanner/admin.py b/expobanner/admin.py index 0fe5c1bc..7d1bf1b1 100644 --- a/expobanner/admin.py +++ b/expobanner/admin.py @@ -110,6 +110,20 @@ class BannerStat(DetailView): model = Banner template_name = 'admin/expobanner/banner_stat.html' + def get_context_data(self, **kwargs): + context = super(BannerStat, self).get_context_data(**kwargs) + obj = self.object + qs = obj.banner_stat.all() + date_from, date_to = self.request.GET.get('date_from'), self.request.GET.get('date_to') + if date_from: + date_from = datetime.strptime(date_from, "%d.%m.%Y") + qs = qs.filter(date__gt=date_from) + if date_to: + date_to = datetime.strptime(date_to, "%d.%m.%Y") + qs = qs.filter(date__lt=date_to) + context['stats'] = qs + return context + class PaidList(ListView): model = Exposition @@ -177,9 +191,17 @@ class PaidStat(DetailView): participation=Sum('participation_clicks'), catalog=Sum('catalog_clicks') ) + qs = obj.paidstat_set.all() + date_from, date_to = self.request.GET.get('date_from'), self.request.GET.get('date_to') + if date_from: + date_from = datetime.strptime(date_from, "%d.%m.%Y") + qs = qs.filter(date__gt=date_from) + if date_to: + date_to = datetime.strptime(date_to, "%d.%m.%Y") + qs = qs.filter(date__lt=date_to) + context['stats'] = qs return context - # ---------------------------------- class MainList(ListView): model = Exposition @@ -222,7 +244,7 @@ def main_turn(request, pk, status): main.save() return HttpResponseRedirect('/admin/expobanners/main/list/') - +from datetime import datetime class MainStat(DetailView): model = MainPage @@ -231,13 +253,22 @@ class MainStat(DetailView): def get_context_data(self, **kwargs): context = super(MainStat, self).get_context_data(**kwargs) obj = self.object - context['stats'] = obj.link.banner_stat.all() + context['all'] = obj.link.banner_stat.aggregate( views=Sum('view'), clicks=Sum('click'), unique_clicks=Sum('unique_click'), unique_views=Sum('unique_view') ) + qs = obj.link.banner_stat.all() + date_from, date_to = self.request.GET.get('date_from'), self.request.GET.get('date_to') + if date_from: + date_from = datetime.strptime(date_from, "%d.%m.%Y") + qs = qs.filter(date__gt=date_from) + if date_to: + date_to = datetime.strptime(date_to, "%d.%m.%Y") + qs = qs.filter(date__lt=date_to) + context['stats'] = qs return context # ------------------------------------ diff --git a/templates/admin/expobanner/banner_stat.html b/templates/admin/expobanner/banner_stat.html index 15d51bc2..6de23537 100644 --- a/templates/admin/expobanner/banner_stat.html +++ b/templates/admin/expobanner/banner_stat.html @@ -1,5 +1,6 @@ {% extends 'base.html' %} {% load static %} +{% load i18n %} {% block scripts %} {% endblock %} @@ -12,6 +13,20 @@

{{ object }} (Пароль: {{ object.stat_pswd }})

+ + +
+
+
+ + + + + +
+
+
+ @@ -23,7 +38,7 @@ - {% with stats=object.banner_stat.all %} + {% with stats=stats %} {% for stat in stats %} @@ -39,5 +54,19 @@ + {% endblock %} \ No newline at end of file diff --git a/templates/admin/expobanner/main_stat.html b/templates/admin/expobanner/main_stat.html index 6c593bb7..d186b92f 100644 --- a/templates/admin/expobanner/main_stat.html +++ b/templates/admin/expobanner/main_stat.html @@ -1,7 +1,14 @@ {% extends 'admin/base.html' %} {% load static %} +{% load i18n %} {% block scripts %} - + {# datetimepicker #} + + + {% endblock %} @@ -16,6 +23,19 @@
Линк на статистику: {{ request.get_host }}/expo-b/banner/{{ object.link.id }}/stat/
Пароль: {{ object.link.stat_pswd }}
+ +
+
+
+ + + + + +
+ +
+
{{ stat.date|date:"Y-m-d" }}
@@ -52,5 +72,19 @@ + {% endblock %} \ No newline at end of file diff --git a/templates/admin/expobanner/paid_stat.html b/templates/admin/expobanner/paid_stat.html index 86bbc620..1d0244ea 100644 --- a/templates/admin/expobanner/paid_stat.html +++ b/templates/admin/expobanner/paid_stat.html @@ -1,4 +1,5 @@ {% extends 'base.html' %} +{% load i18n %} {% load static %} {% block scripts %} @@ -16,6 +17,20 @@
Линк на статистику: {{ request.get_host }}/expo-b/paid/{{ object.id }}/stat/
Пароль: {{ object.stat_pswd }}
+ + +
+
+
+ + + + + +
+ +
+
@@ -34,7 +49,7 @@ - {% with stats=object.paidstat_set.all %} + {% with stats=stats %} {% for stat in stats %} @@ -50,5 +65,19 @@ + {% endblock %} \ No newline at end of file diff --git a/templates/client/blank.html b/templates/client/blank.html index ee88ffa4..9d78fc79 100644 --- a/templates/client/blank.html +++ b/templates/client/blank.html @@ -89,7 +89,11 @@ This template include basic anf main styles and js files, '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-P5C6GR'); - + diff --git a/templates/client/exposition/exposition_detail.html b/templates/client/exposition/exposition_detail.html index f95b6dc3..4750c1c4 100644 --- a/templates/client/exposition/exposition_detail.html +++ b/templates/client/exposition/exposition_detail.html @@ -1,4 +1,4 @@ -{% extends 'base_catalog.html' %} +{% extends 'client/base_catalog.html' %} {% load i18n %} {% load template_filters %} diff --git a/templates/client/includes/conference/default_description.html b/templates/client/includes/conference/default_description.html index a6addeeb..255c9745 100644 --- a/templates/client/includes/conference/default_description.html +++ b/templates/client/includes/conference/default_description.html @@ -1,21 +1,21 @@ +{% load i18n %}
-Конференция {{conf.name}} проходит {% include 'client/includes/show_date_block.html' with obj=conf %} в городе {{conf.city.name}}, {{conf.country.name}}. +{% blocktrans with name=conf.name%} +

Конференция {{name}} проходит {% endblocktrans %}{% include 'client/includes/show_date_block.html' with obj=conf %} +{% blocktrans with city=conf.name country=country.name name=conf.name id=conf.city.id code=request.LANGUAGE_CODE date1=conf.data_begin|date:'j' date2=conf.data_begin|date:'Y' date3=conf.data_begin|date:'n' date4=conf.data_end|date:'j' date5=conf.data_end|date:'Y' date6=conf.data_end|date:'n' %} + в городе {{city}}, {{country}}. Посмотреть, как проехать в место проведения конференции, можно на сайте конгрессной площадки. -Деловая программа {{conf.name}} разбита на секции по дням и размещается на сайте мероприятия с подробным списком -докладчиков конференции. Спикеров конференции {{conf.name}} обычно окончательно утверждают за 1-2 месяца до начала конференции. -
-

Ваши деловые контакты на {{conf.name}}

-
-Добавьте конференцию {{conf.name}} в расписание, чтобы не потерять важное событие, +Деловая программа {{name}} разбита на секции по дням и размещается на сайте мероприятия с подробным списком +докладчиков конференции. Спикеров конференции {{name}} обычно окончательно утверждают за 1-2 месяца до начала конференции.

+

Ваши деловые контакты на {{name}}

+

Добавьте конференцию {{name}} в расписание, чтобы не потерять важное событие, где встречаются профессионалы нужной Вам отрасли. Создавайте свой календарь мероприятий, просто нажав кнопку - "Добавить в календарь". -
-

Планируете самостоятельную поездку на {{conf.name}} ?

-
-Если Вам требуется размещение, мы рекомендуем посмотреть отели и цены в период проведения конференции здесь. + "Добавить в календарь".

+

Планируете самостоятельную поездку на {{name}} ?

+

Если Вам требуется размещение, мы рекомендуем посмотреть отели и цены в период проведения конференции здесь. Не забудьте проверить место и даты конференции на официальном сайте и в календаре организатора. Событие могут перенести, отменить, объединить с проектом схожей тематики. Expomap не несет ответственности за неточности предоставляемой информации. -Есть вопрос по участию в {{conf.name}} ? Ответим по тел. +7 (499) 999-12-07 - +Есть вопрос по участию в {{name}} ? Ответим по тел. +7 (499) 999-12-07

+ {% endblocktrans %}
\ No newline at end of file diff --git a/templates/client/includes/exposition/default_description.html b/templates/client/includes/exposition/default_description.html index af30f614..f96b760e 100644 --- a/templates/client/includes/exposition/default_description.html +++ b/templates/client/includes/exposition/default_description.html @@ -1,24 +1,34 @@ +{% load i18n %}
- Выставка {{expo.name}} проводится {% include 'client/includes/show_date_block.html' with obj=expo %} в городе {{expo.city.name}}, {{expo.country.name}}. - Экспонируемые продукты и разделы выставки Вы можете посмотреть ниже, в блоке «Дополнительная информация». - Полный список участников {{expo.name}} размещается на официальном сайте выставки и постоянно обновляется. - Там же Вы сможете найти экспонентов предыдущего года. Деловая программа {{expo.name}} обычно публикуется ближе к - началу события. -
-

Ваш личный календарь

-
- Добавьте выставку {{expo.name}} в расписание, чтобы не потерять важное событие. Создавайте свой календарь мероприятий, - просто нажав кнопку Добавить в календарь. -
-

Планируете самостоятельную поездку на {{expo.name}}?

-
- Мы рекомендуем посмотреть отели и цены в период проведения выставки здесь . - {% if expo.place %} - Как добраться до выставочного центра {{expo.place.name}} можно посмотреть - здесь. - {% endif %} - Не забудьте проверить место и даты выставки на официальном сайте и в календаре выставочного комплекса. - Событие могут перенести, отменить, объединить с проектом схожей тематики. - Expomap не несет ответственности за неточности предоставляемой информации. - Есть вопрос о посещении или участии в {{ expo.name }}? Ответим по тел. +7 (499) 999-12-07 + {% blocktrans with name=expo.name %} +

Выставка {{ name }} проводится{% endblocktrans %} + {% include 'client/includes/show_date_block.html' with obj=expo %} + {% blocktrans with city=expo.city.name country=expo.country.name %} в городе {{ city }}, {{ country }} + .{% endblocktrans %} + {% blocktrans with name=expo.name id=expo.city.id code=request.LANGUAGE_CODE date1=expo.data_begin|date:'j' date2=expo.data_begin|date:'Y' date3=expo.data_begin|date:'n' date4=expo.data_end|date:'j' date5=expo.data_end|date:'Y' date6=expo.data_end|date:'n' %} + Экспонируемые продукты и разделы выставки Вы можете посмотреть ниже, в блоке + «Дополнительная информация». + Полный список участников {{ name }} размещается на официальном сайте выставки и постоянно обновляется. + Там же Вы сможете найти экспонентов предыдущего года. Деловая программа {{ name }} обычно публикуется ближе к + началу события.

+ +

Ваш личный календарь

+

Добавьте выставку {{ name }} в календарь, чтобы не + потерять важное событие. Создавайте свой календарь мероприятий, + просто нажав кнопку Добавить в календарь.

+ +

Планируете самостоятельную поездку на {{ name }}?

+

Мы рекомендуем посмотреть отели и цены в период проведения выставки + здесь. + {% endblocktrans %}{% if expo.place %} + {% blocktrans with name=expo.place.name url=expo.place.url %}Как добраться до выставочного центра {{ name }} можно + посмотреть + здесь.{% endblocktrans %} +{% endif %} + {% blocktrans with name=expo.name %} + Не забудьте проверить место и даты выставки на официальном сайте и в календаре выставочного комплекса. + Событие могут перенести, отменить, объединить с проектом схожей тематики. + Expomap не несет ответственности за неточности предоставляемой информации. + Есть вопрос о посещении или участии в {{ name }}? Ответим по тел. +7 (499) 999-12-07

+ {% endblocktrans %}
\ No newline at end of file From 537f5bc50191b85642c9e346dc7214a1247637eb Mon Sep 17 00:00:00 2001 From: Ivan Kovalkovskyi Date: Thu, 24 Sep 2015 15:32:17 +0300 Subject: [PATCH 4/4] pagination improved --- accounts/views.py | 3 ++- article/views.py | 3 ++- company/views.py | 3 ++- conference/views.py | 3 ++- core/views.py | 3 ++- exposition/views.py | 3 ++- functions/custom_views.py | 20 +++++++++++++++++--- functions/overrides.py | 19 +++++++++++++++++++ photologue/views.py | 2 +- place_exposition/views.py | 3 ++- proj/settings.py | 12 +++++++++--- specialist_catalog/views.py | 8 ++++++-- translator/views.py | 3 ++- 13 files changed, 68 insertions(+), 17 deletions(-) create mode 100644 functions/overrides.py diff --git a/accounts/views.py b/accounts/views.py index e4eb1243..c6cc53b5 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -8,7 +8,8 @@ from django.contrib.auth.decorators import login_required from django.utils.translation import ugettext as _, get_language from django.utils import timezone from django_messages.forms import SendForm -from django.views.generic import TemplateView, FormView, ListView +from django.views.generic import TemplateView, FormView +from functions.custom_views import ListView from sorl.thumbnail import get_thumbnail from .forms import ChangePasswordForm, EmailAnnouncementForm, FeedFilterForm from company.forms import CreateCompanyForm diff --git a/article/views.py b/article/views.py index 4b421db2..53dbdb6e 100644 --- a/article/views.py +++ b/article/views.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import json -from django.views.generic import DetailView, ListView +from django.views.generic import DetailView +from functions.custom_views import ListView from django.http import HttpResponse from models import Article from forms import ArticleFilterForm diff --git a/company/views.py b/company/views.py index d82401a8..d77a6ca2 100644 --- a/company/views.py +++ b/company/views.py @@ -2,7 +2,8 @@ import json from django.http import HttpResponse from django.conf import settings -from django.views.generic import ListView, DetailView +from django.views.generic import DetailView +from functions.custom_views import ListView from django.shortcuts import get_object_or_404 from django.utils.translation import ugettext as _, get_language from haystack.query import EmptySearchQuerySet diff --git a/conference/views.py b/conference/views.py index bbbc63c6..c5a854e8 100644 --- a/conference/views.py +++ b/conference/views.py @@ -6,7 +6,8 @@ from django.http import HttpResponse, Http404, HttpResponseRedirect, HttpRespons from django.contrib import messages from django.shortcuts import get_object_or_404 from django.contrib.contenttypes.models import ContentType -from django.views.generic import ListView, DetailView +from django.views.generic import DetailView +from functions.custom_views import ListView from django.views.generic.edit import FormMixin from django.utils.translation import ugettext as _ from django.utils import translation diff --git a/core/views.py b/core/views.py index 0ec0cb16..1ad5be9a 100644 --- a/core/views.py +++ b/core/views.py @@ -3,7 +3,8 @@ from country.models import Country from city.models import City from place_exposition.models import PlaceExposition from place_conference.models import PlaceConference -from django.views.generic import ListView, CreateView, DeleteView, UpdateView, DetailView +from django.views.generic import CreateView, DeleteView, UpdateView, DetailView +from functions.custom_views import ListView from django.core.urlresolvers import reverse_lazy from functions.views_help import split_params from django.utils.translation import ugettext as _ diff --git a/exposition/views.py b/exposition/views.py index fa7eff6a..b35e42a6 100644 --- a/exposition/views.py +++ b/exposition/views.py @@ -4,7 +4,8 @@ import datetime from django.http import HttpResponseRedirect, HttpResponse, HttpResponsePermanentRedirect from django.contrib.contenttypes.models import ContentType from django.conf import settings -from django.views.generic import ListView, DetailView +from django.views.generic import DetailView +from functions.custom_views import ListView from django.utils.translation import ugettext as _ from django.shortcuts import get_object_or_404 from django.http import Http404 diff --git a/functions/custom_views.py b/functions/custom_views.py index dfbc9071..781626cc 100644 --- a/functions/custom_views.py +++ b/functions/custom_views.py @@ -18,9 +18,23 @@ from hvad.utils import get_translation_aware_manager #python import random +from django.views.generic import ListView as OldListView -from country.models import Country - +class ListView(OldListView): + """ + List of modules, where overrided ListView is used: + - accounts.views + - article.views + - company.views + - conference.views + - core.views + - exposition.views + - photologue.views + - place_exposition.views + - specialist_catalog.views + - translator.views + """ + paginator_class = settings.DEFAULT_PAGINATOR @login_required def filtered_list(request, objects, template, item_per_page=settings.ADMIN_PAGINATION): @@ -186,7 +200,7 @@ def delete_object(request, Model, Form, url, prev_page,): return render_to_response('delete.html', args) #-----class------------------ -from django.views.generic import ListView, DetailView +from django.views.generic import DetailView from functions.views_help import split_params from city.models import City diff --git a/functions/overrides.py b/functions/overrides.py new file mode 100644 index 00000000..8a132cb7 --- /dev/null +++ b/functions/overrides.py @@ -0,0 +1,19 @@ +from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage + +class SeoPaginator(Paginator): + + def validate_number(self, number): + "Validates the given 1-based page number." + try: + number = int(number) + except (TypeError, ValueError): + raise PageNotAnInteger('That page number is not an integer') + if number < 1: + raise EmptyPage('That page number is less than 1') + if number > self.num_pages: + if number == 1 and self.allow_empty_first_page: + pass + else: + number = 1 + return number + diff --git a/photologue/views.py b/photologue/views.py index a0ebb335..fb2e9589 100644 --- a/photologue/views.py +++ b/photologue/views.py @@ -3,7 +3,7 @@ import warnings from django.conf import settings from django.views.generic.dates import ArchiveIndexView, DateDetailView, DayArchiveView, MonthArchiveView, YearArchiveView from django.views.generic.detail import DetailView -from django.views.generic.list import ListView +from functions.custom_views import ListView from .models import Photo, Gallery # Number of galleries to display per page. diff --git a/place_exposition/views.py b/place_exposition/views.py index a40f28d7..ba8f939a 100644 --- a/place_exposition/views.py +++ b/place_exposition/views.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from django.shortcuts import render_to_response -from django.views.generic import ListView, DetailView, FormView +from django.views.generic import DetailView, FormView +from functions.custom_views import ListView from django.utils import translation from django.http import HttpResponseRedirect, HttpResponse from django.template import RequestContext diff --git a/proj/settings.py b/proj/settings.py index 9fdca037..f7fb9c17 100644 --- a/proj/settings.py +++ b/proj/settings.py @@ -422,10 +422,14 @@ THUMBNAIL_DEBUG = DEBUG CALLBACK_EMAIL = 'kotzilla@ukr.net' BOOKING_AID = '333667' - - +try: + from functions.overrides import SeoPaginator as Paginator +except ImportError: + from django.core.paginator import Paginator +DEFAULT_PAGINATOR = Paginator ADMIN_PAGINATION = 20 CLIENT_PAGINATION = 15 + TEMPLATE_DEBUG = DEBUG NO_LOGO = '/static/client/img/no-logo.png' @@ -504,4 +508,6 @@ if DEBUG: # 'INTERCEPT_REDIRECTS': False, #} -""" \ No newline at end of file +""" + +# -- PAGINATION -- # diff --git a/specialist_catalog/views.py b/specialist_catalog/views.py index 49ff483d..c3a17a20 100644 --- a/specialist_catalog/views.py +++ b/specialist_catalog/views.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -from django.views.generic import CreateView, UpdateView, DeleteView, ListView, FormView, DetailView +from django.views.generic import CreateView, UpdateView, DeleteView, FormView, DetailView +from functions.custom_views import ListView from django.views.generic.detail import SingleObjectMixin from django.utils.translation import ugettext as _ from .forms import * @@ -11,6 +12,8 @@ from django.http import HttpResponseRedirect, Http404 from .models import _city, _country + + # =========== ADMIN VIEWS =========== # Specialist views @@ -70,11 +73,12 @@ class CatalogCreateView(CreateView): success_url = reverse_lazy("catalog_all") + class CatalogListView(ListView): model = SpecialistCatalog template_name = 'admin/specialist/catalog_all.html' paginate_by = settings.ADMIN_PAGINATION - + paginator_class = settings.DEFAULT_PAGINATOR def get_queryset(self): _GET = self.request.GET query, city, country, only_cntry = _GET.get('query'), _GET.get('city'), _GET.get('country'), _GET.get('only_countries') diff --git a/translator/views.py b/translator/views.py index a6884462..30d277c5 100644 --- a/translator/views.py +++ b/translator/views.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -from django.views.generic import ListView, DetailView +from django.views.generic import DetailView +from functions.custom_views import ListView from django.shortcuts import get_object_or_404 from django.views.generic.detail import SingleObjectMixin from django.utils.translation import ugettext as _
{{ all.participation}} {{ all.catalog }}
{{ stat.date|date:"Y-m-d" }}