From 786f5d724aaff9b84a5ceb7a6dcb18538bd29e66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80=20=D0=9A=D0=BE=D1=82=D1=8E?= =?UTF-8?q?=D0=BA?= Date: Fri, 1 May 2015 16:51:48 +0300 Subject: [PATCH] fast Commit --- article/models.py | 9 +++ article/urls.py | 4 +- article/views.py | 40 ++++++++++- exposition/management/commands/expo_old.py | 68 ++++++++++++++++++- file/forms.py | 2 +- file/models.py | 3 +- functions/custom_views.py | 4 +- functions/search_forms.py | 9 ++- templates/client/article/news_list.html | 2 +- templates/client/exposition/search.html | 2 +- .../includes/article/article_preview.html | 2 +- .../client/includes/catalog_paginator.html | 12 ++-- .../includes/exposition/search_result.html | 4 +- templates/client/includes/footer.html | 6 +- templates/client/includes/index/confs.html | 2 +- templates/client/includes/index/expos.html | 2 +- templates/client/service/participation.html | 16 ++--- theme/models.py | 4 +- theme/search_indexes.py | 16 +++++ 19 files changed, 171 insertions(+), 36 deletions(-) diff --git a/article/models.py b/article/models.py index 08465981..55b477e5 100644 --- a/article/models.py +++ b/article/models.py @@ -240,6 +240,15 @@ class Article(TranslatableModel): return preview[0] else: return None + + def get_blog_preview2(self): + + preview = self.files.filter(purpose='preview2') + if preview: + return preview[0] + else: + return None + def get_catalog(self): if self.type == 1: return '/blogs/' diff --git a/article/urls.py b/article/urls.py index 621c5389..7e6bc606 100644 --- a/article/urls.py +++ b/article/urls.py @@ -1,9 +1,11 @@ # -*- coding: utf-8 -*- from django.conf.urls import patterns, url -from views import BlogList, NewsList, BlogDetail, NewsDetail, NewsTagCatalog +from views import BlogList, NewsList, BlogDetail, NewsDetail, NewsTagCatalog, BlogsTagCatalog urlpatterns = patterns('', + url(r'^blogs/tag/(?P.*)/page/(?P\d+)/$', BlogsTagCatalog.as_view()), url(r'^blogs/page/(?P\d+)/$', BlogList.as_view()), + url(r'^blogs/tag/(?P.*)/$', BlogsTagCatalog.as_view()), url(r'^blogs/$', BlogList.as_view()), diff --git a/article/views.py b/article/views.py index 3c0d94cc..2ec8de58 100644 --- a/article/views.py +++ b/article/views.py @@ -161,8 +161,46 @@ class NewsTagCatalog(MetadataMixin, ListView): +class BlogsTagCatalog(MetadataMixin, ListView): + model = Article + template_name = 'client/article/catalog.html' + catalog_url = '/blogs/tag/' + filter_object = None + year = None + month = None + + def get_queryset(self): + slug = self.kwargs.get('slug') + tag = get_object_or_404(Tag, url=slug) + self.filter_object = tag + qs = Article.objects.blogs().filter(tag=tag) + year = self.kwargs.get('year') + + if year: + qs = qs.filter(publish_date__year=year) + # info for breadscrumbs + self.year = {'text': year, 'link': '%s%s/%s/'%(self.catalog_url, self.filter_object.url, year)} + + month = self.kwargs.get('month') + monthes = {'jan': {'value': 1, 'name': _(u'Январь')}, 'feb': {'value': 2, 'name': _(u'Февраль')}, + 'mar': {'value': 3, 'name': _(u'Март')}, 'apr': {'value': 4, 'name': _(u'Апрель')}, + 'may': {'value': 5, 'name': _(u'Май')}, 'jun': {'value': 6, 'name': _(u'Июнь')}, + 'jul': {'value': 7, 'name': _(u'Июль')}, 'aug': {'value': 8, 'name': _(u'Август')}, + 'sep': {'value': 9, 'name': _(u'Сентябрь')}, 'oct': {'value': 10, 'name': _(u'Октябрь')}, + 'nov': {'value': 11, 'name': _(u'Ноябрь')}, 'dec': {'value': 12, 'name': _(u'Декабрь')}} + if month and monthes.get(month): + qs = qs.filter(publish_date__month=monthes[month]['value']) + self.month = {'text': monthes[month]['name'], 'link': '%s%s/%s/%s/'%(self.catalog_url, self.filter_object.url, year, month)} + return qs - return qs \ No newline at end of file + + def get_context_data(self, **kwargs): + context = super(BlogsTagCatalog, self).get_context_data(**kwargs) + context['filter_object'] = self.filter_object + context['year'] = self.year + context['month'] = self.month + context['catalog_url'] = self.catalog_url + return context \ No newline at end of file diff --git a/exposition/management/commands/expo_old.py b/exposition/management/commands/expo_old.py index 03a53ce8..fef86a0b 100644 --- a/exposition/management/commands/expo_old.py +++ b/exposition/management/commands/expo_old.py @@ -13,6 +13,71 @@ from city.models import City file_path = settings.MEDIA_ROOT + 'exposition/bad_expos.txt' +import datetime +from theme.models import Theme +from conference.models import Conference +class Command(BaseCommand): + def handle(self, *args, **options): + db = MySQLdb.connect(host="localhost", + user="expomap", + passwd="7FbLtAGjse", + db="old_db", + charset='utf8', + cursorclass=DictCursor) + cursor = db.cursor() + conf_old = """ + SELECT DISTINCT (products_to_categories.products_id), url as old_url + FROM `products_to_categories` + LEFT JOIN `products` ON products_to_categories.products_id=products.products_id + LEFT JOIN `products_description` ON products_to_categories.products_id=products_description.products_id + WHERE `products_status` =1 + AND `conference` =0 + + """ + + + find_themes = "SELECT categories_id FROM `products_to_categories` WHERE `products_id` =%d" + + cursor.execute(conf_old) + + conferences = cursor.fetchall() + #for item in conferences: + cursor.execute(find_themes%conferences[0]['products_id']) + + day = datetime.date.today() + day = day.replace(month=1, day=1) + + for item in conferences: + old_url = item['old_url'] + if not old_url: + continue + try: + expo = Exposition.objects.get(old_url=old_url) + except: + continue + if expo.data_begin > day: + continue + + cursor.execute(find_themes%item['products_id']) + + themes_id = [i['categories_id'] for i in cursor.fetchall()] + theme_qs = Theme.objects.filter(id__in=themes_id) + + expo.theme.add(*theme_qs) + print(expo) + + + + + + + # if item['categories_id'] == 0: + # continue + # Theme.objects.get(id=item['categories_id']) + #print(result) + + +''' class Command(BaseCommand): def handle(self, *args, **options): db = MySQLdb.connect(host="localhost", @@ -100,4 +165,5 @@ class Command(BaseCommand): file = open(file_path, 'w') for item in bad_expos: file.write("%s\n" % item) - file.close() \ No newline at end of file + file.close() +''' \ No newline at end of file diff --git a/file/forms.py b/file/forms.py index 094e6e7e..ca57fc51 100644 --- a/file/forms.py +++ b/file/forms.py @@ -17,7 +17,7 @@ import pytils, re class FileForm(forms.Form): file_path = forms.FileField(label='Выберите файл') model = forms.CharField(required=False, widget=forms.HiddenInput()) - purposes = [('scheme teritory','Схема территории'),('preview','Превью')] + purposes = [('scheme teritory','Схема территории'),('preview','Превью'), ('preview2','Превью2')] purpose = forms.ChoiceField(label='Назначение', choices=purposes) def __init__(self, *args, **kwargs): diff --git a/file/models.py b/file/models.py index 19eba496..c166a0a8 100644 --- a/file/models.py +++ b/file/models.py @@ -20,7 +20,8 @@ PURPOSES = (('photo', 'Фото'), ('map','Карта'), ('scheme teritory','Схема територии'), ('diplom','Дипломы'), - ('preview','Превью') + ('preview','Превью'), + ('preview2','Превью'), ) class FileModel(TranslatableModel): diff --git a/functions/custom_views.py b/functions/custom_views.py index 7e7bb98d..dfbc9071 100644 --- a/functions/custom_views.py +++ b/functions/custom_views.py @@ -227,7 +227,7 @@ class ExpoListView(ExpoMixin, ListView): """ """ - paginate_by = 10 + paginate_by = settings.CLIENT_PAGINATION params = None single_page = False search_form = None @@ -320,7 +320,7 @@ class EventDetail(ExpoMixin, DetailView): from haystack.query import EmptySearchQuerySet class ExpoSearchView(ListView): - paginate_by = 10 + paginate_by = settings.CLIENT_PAGINATION template_name = None search_form = None model = None diff --git a/functions/search_forms.py b/functions/search_forms.py index 590519e9..d24eb185 100644 --- a/functions/search_forms.py +++ b/functions/search_forms.py @@ -221,7 +221,7 @@ class AbstactSearchForm(forms.Form): sqs = sqs.filter(place_filter) return sqs#.order_by('data_begin') - +import datetime class ExpositionSearchForm(AbstactSearchForm): search_url = '/expo/search/' autocomplete_url = '/search-form/autosearch/exposition/' @@ -245,10 +245,10 @@ class ExpositionSearchForm(AbstactSearchForm): choices=[(item.id, item.name) for item in City.used.expo_cities()] ) - fr = forms.DateField(required=False, + fr = forms.DateField(required=False, input_formats=('%d.%m.%Y',), widget=forms.DateInput(attrs={'class': 'date', 'id': 'dateFrom', 'placeholder': _(u'дд.мм.гггг')})) - to = forms.DateField(required=False, + to = forms.DateField(required=False, input_formats=('%d.%m.%Y',), widget=forms.DateInput(attrs={'class': 'date', 'id': 'dateTo', 'placeholder': _(u'дд.мм.гггг')})) @@ -264,6 +264,8 @@ class ExpositionSearchForm(AbstactSearchForm): q = self.cleaned_data.get('q') w = self.cleaned_data.get('w') fr = self.cleaned_data.get('fr') + if not fr: + fr = datetime.date.today() to = self.cleaned_data.get('to') th = self.cleaned_data.get('th') tg = self.cleaned_data.get('tg') @@ -271,6 +273,7 @@ class ExpositionSearchForm(AbstactSearchForm): ci = self.cleaned_data.get('ci') area = self.cleaned_data.get('area') + sqs = SearchQuerySet().models(Exposition).all() if q: diff --git a/templates/client/article/news_list.html b/templates/client/article/news_list.html index 532611eb..9e671309 100644 --- a/templates/client/article/news_list.html +++ b/templates/client/article/news_list.html @@ -54,5 +54,5 @@ {% endblock %} {% block paginator %} - {% include 'includes/catalog_paginator.html' with page_obj=page_obj %} + {% include 'client/includes/catalog_paginator.html' with page_obj=page_obj %} {% endblock %} diff --git a/templates/client/exposition/search.html b/templates/client/exposition/search.html index c2e703bd..6aa7d985 100644 --- a/templates/client/exposition/search.html +++ b/templates/client/exposition/search.html @@ -18,7 +18,7 @@ {% block content_list %} {% with query=object_list %} {% if query %} - {% include 'includes/exposition/search_result.html' %} + {% include 'client/includes/exposition/search_result.html' %} {% else %}

diff --git a/templates/client/includes/article/article_preview.html b/templates/client/includes/article/article_preview.html index 3d005ac0..551dacc8 100644 --- a/templates/client/includes/article/article_preview.html +++ b/templates/client/includes/article/article_preview.html @@ -2,7 +2,7 @@ {% load thumbnail %} {% if obj.get_blog_preview %} - {% thumbnail obj.get_blog_preview.file_path "250x180" as im %} + {% thumbnail obj.get_blog_preview2.file_path "250x180" as im %} {% endthumbnail %} {% else %} diff --git a/templates/client/includes/catalog_paginator.html b/templates/client/includes/catalog_paginator.html index 5942ea5a..89e05474 100644 --- a/templates/client/includes/catalog_paginator.html +++ b/templates/client/includes/catalog_paginator.html @@ -8,38 +8,38 @@

Показано {{ page_obj.start_index }} - {{ page_obj.end_index }} (всего {{ page_obj.paginator.count }} позиций)
{% if page_obj.has_previous %} - Предыдущая + Предыдущая {% else %} Предыдущая {% endif %} {% if page_obj.has_next %} - Следующая + Следующая {% else %} Следующая {% endif %} diff --git a/templates/client/includes/exposition/search_result.html b/templates/client/includes/exposition/search_result.html index 4f9e055d..a387d86c 100644 --- a/templates/client/includes/exposition/search_result.html +++ b/templates/client/includes/exposition/search_result.html @@ -41,9 +41,9 @@
{% if result.object.country %} {% endif %} diff --git a/templates/client/includes/footer.html b/templates/client/includes/footer.html index de41db3e..8feeb908 100644 --- a/templates/client/includes/footer.html +++ b/templates/client/includes/footer.html @@ -24,8 +24,8 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/templates/client/service/participation.html b/templates/client/service/participation.html index 9aca1da5..21f1e25c 100644 --- a/templates/client/service/participation.html +++ b/templates/client/service/participation.html @@ -35,19 +35,18 @@
-

{% trans 'Предлагаем Вам услуги профессиональной организации Вашего участия в выставке' %}{% if object %} {{ object.name }} {% endif %}

+

{% trans 'Увеличим эффективность Вашего участия в выставке' %}{% if object %} {{ object.name }} {% endif %} {% trans 'как минимум на 50%' %}

    -
  • {% trans 'вся информация о выставке' %}
  • -
  • {% trans 'экономия времени' %}
  • -
  • {% trans 'все потенциальные контакты' %}
  • +
  • {% trans 'Мы поможем превратить посетителей стенда в клиентов' %}
  • +
  • {% trans 'Мы удержим Вас от пустых трат' %}
  • +
  • {% trans 'Мы посчитаем отдачу и покажем результаты в цифрах' %}
    -
  • {% trans 'вся информация о выставке' %}
  • -
  • {% trans 'экономия времени' %}
  • -
  • {% trans 'все потенциальные контакты' %}
  • +
  • {% trans 'Мы начнем привлекать Вам клиентов еще до выставки' %}
  • +
  • {% trans 'Мы знаем тонкости и узкие места организации' %}
@@ -172,7 +171,8 @@
- {% trans '

За организацию Вашего участия в зарубежной выставке наша компания берет дополнительный % от контракта с организатором. Его величина варьируется от 5 до 15% и зависит от метража арендуемой площади и необходимых дополнительных услуг, которые определяют общую трудоемкость процесса и состав специалистов.

' %} + {% trans '

Укажите в запросе исходную информацию о Ваших целях и задачах, и мы проверим, насколько'%} + {% if object %} {{ object.name }} {%else %} {% trans 'событие' %}{%endif %} {% trans 'им соответствует. Если событие подходит, мы свяжемся с организаторами, чтобы уточнить наличие свободных площадей и вместе с Вами начнем создавать концепцию Вашего участия

' %}
{% if messages %} diff --git a/theme/models.py b/theme/models.py index f86ae554..4de10b68 100644 --- a/theme/models.py +++ b/theme/models.py @@ -56,11 +56,11 @@ class Theme(TranslatableModel): def expositions_number(self): - return Exposition.objects.filter(theme__id=self.id).count() + return Exposition.enable.upcoming().filter(theme__id=self.id).count() def conferences_number(self): - return Conference.objects.filter(theme__id=self.id).count() + return Conference.enable.upcoming().filter(theme__id=self.id).count() def seminars_number(self): diff --git a/theme/search_indexes.py b/theme/search_indexes.py index edb8a51c..3d9d82fa 100644 --- a/theme/search_indexes.py +++ b/theme/search_indexes.py @@ -17,6 +17,14 @@ class ThemeIndex(indexes.SearchIndex, indexes.Indexable, ExpoSearchMixin): parent_ru = indexes.CharField() catalog_name_en = indexes.CharField() catalog_name_ru = indexes.CharField() + data_begin = indexes.DateField() + data_end = indexes.DateField() + + def prepare_data_begin(self, obj): + return None + + def prepare_data_end(self, obj): + return None def prepare_parent_en(self, obj): translation.activate('en') @@ -101,6 +109,14 @@ class TagIndex(indexes.SearchIndex, indexes.Indexable, ExpoSearchMixin): parent_ru = indexes.CharField() catalog_name_en = indexes.CharField() catalog_name_ru = indexes.CharField() + data_begin = indexes.DateField() + data_end = indexes.DateField() + + def prepare_data_begin(self, obj): + return None + + def prepare_data_end(self, obj): + return None def prepare_parent_en(self, obj): #translation.activate('en')