diff --git a/core/simple_views.py b/core/simple_views.py index d6fe480c..5f556f4a 100644 --- a/core/simple_views.py +++ b/core/simple_views.py @@ -13,26 +13,32 @@ class SeminarLendingView(TemplateView): def send_to_organiser(request): - mail_send = 'kotzilla@ukr.net' + mail_send = 'expomap@mail.ru' fname = request.POST.get('name') lname = request.POST.get('surname') email = request.POST.get('email', '') company = request.POST.get('company', '') office = request.POST.get('office', '') + phone = request.POST.get('phone', '') title = request.POST.get('type', '') text = u"""Имя: %s; Фамилия:%s; Email: %s; + Телефон: %s; компния:%s; - должность: %s"""%(fname, lname, email, company, office) + должность: %s"""%(fname, lname, email, phone, company, office) msg = EmailMessage(title, text, settings.DEFAULT_FROM_EMAIL, [mail_send]) msg.content_subtype = "html" msg.send() redirect_to = '/service/thanks/' - message = u"""Мы получили Ваш запрос и очень рады, что Вам интересно участие в семинаре Expomap. Если места еще есть, мы пришлем Вам приглашение на указанную Вами электронную почту. -Увидимся на welcome-coffee ☺""" + if title.endswith(u'семинар'): + message = u"""Мы получили Ваш запрос и очень рады, что Вам интересно участие в семинаре Expomap. Если места еще есть, мы пришлем Вам приглашение на указанную Вами электронную почту. + Увидимся на welcome-coffee ☺""" + else: + message = u"""Благодарим за интерес к нашему семинару! За несколько дней до мероприятия мы пришлем Вам ссылку для подключения к онлайн-трансляции!""" + return HttpResponse(json.dumps({'success':True, 'redirect_to': redirect_to, 'message': message}), content_type='application/json') diff --git a/country/models.py b/country/models.py index 7508cbf1..738db7e7 100644 --- a/country/models.py +++ b/country/models.py @@ -146,8 +146,9 @@ class Country(TranslatableModel): return Webinar.objects.filter(country=self.id).count() def active_cities(self): - - return City.used.active_qs().filter(country=self) + result = list(set(City.used.active_qs().filter(country=self))) + result.sort(key=lambda x:x.name) + return result lang = translation.get_language() #return City.objects.select_related('exposition_city')\ # .filter(exposition_city__city__isnull=False, translations__language_code=lang, country=self).distinct().order_by('translations__name') diff --git a/exposition/management/commands/test.py b/exposition/management/commands/test.py index 271b6d8d..022c3e6d 100644 --- a/exposition/management/commands/test.py +++ b/exposition/management/commands/test.py @@ -1,20 +1,141 @@ # -*- coding: utf-8 -*- +import MySQLdb +import os.path +from MySQLdb.cursors import DictCursor +from django.utils.translation import activate from django.core.management.base import BaseCommand -from meta.models import MetaSetting +from django.conf import settings +from exposition.models import Exposition +from theme.models import Theme +from theme.models import Theme, Tag class Command(BaseCommand): def handle(self, *args, **options): - a = MetaSetting.objects.filter(translations__h1__contains='«').count() - qs = MetaSetting.objects.language('ru').all() - for item in qs: - item.title = item.title.replace(u'«', u'').replace(u'»', u'') - item.description = item.title.replace(u'«', u'').replace(u'»', u'') - item.h1 = item.h1.replace(u'«', u'').replace(u'»', u'') - #item.save() + #expos = Exposition.objects.filter(theme__isnull=True, old_url__isnull=False) + db = MySQLdb.connect(host="localhost", + user="expomap", + passwd="7FbLtAGjse", + db="old_db", + charset='utf8', + cursorclass=DictCursor) + cursor = db.cursor() + activate('ru') + #expos = Exposition.enable.upcoming().filter(logo='') + expos = Exposition.objects.filter(tag__isnull=True).order_by('-data_end') + #expo = Exposition.objects.get(old_url='salon-du-livre-2015') + #handle_expo_tag(expo, cursor) + for expo in expos: + handle_expo_tag(expo, cursor) + + ''' + find_old_id = """ + SELECT products.products_id + from products + LEFT JOIN `products_description` ON products.products_id=products_description.products_id + WHERE url='%s' + """ + + find_themes = "SELECT categories_id FROM `products_to_categories` WHERE `products_id` =%d" + ''' + """ + for expo in expos: + cursor.execute(find_old_id%expo.old_url) + old_ids = [item['products_id'] for item in cursor.fetchall()] + print expo.old_url + for id in old_ids: + cursor.execute(find_themes%id) + themes_ids = [item['categories_id'] for item in cursor.fetchall()] + print themes_ids + #if not themes_ids: + # continue + + + theme_qs = Theme.objects.filter(id__in=themes_ids) + #expo.theme.add(*theme_qs) + break + + print('----------------------') + """ + + +def handle_expo_tag(expo, cursor): + old_url = expo.old_url + if not old_url: + return None + print(old_url) + find_old = """ + SELECT products.products_id, url + from products + LEFT JOIN `products_description` ON products.products_id=products_description.products_id + WHERE url='%s' + """ + cursor.execute(find_old%old_url) + result = cursor.fetchone() + expo_id = result.get('products_id') + if not expo_id: + return + + find_tag_id = """ + SELECT tag_id + FROM `products_tags` + WHERE `product_id` =%d + """ + cursor.execute(find_tag_id%expo_id) + tags_ids = [str(item['tag_id']) for item in cursor.fetchall()] + if not tags_ids: + return None + find_tag = """ + SELECT title + FROM `tags` + WHERE id in(%s) + """ + cursor.execute(find_tag%', '.join(tags_ids)) + tag_names = [item['title'] for item in cursor.fetchall()] + if not tag_names: + return None + + themes = [item['id'] for item in expo.theme.all().values('id')] + qs = Tag.objects.filter(translations__name__in=tag_names, theme__in=themes) + expo.tag.add(*qs) + + + +def handle_expo(expo, cursor): + """ + fixing logos + + """ + if expo.logo: + return + + find_old = """ + SELECT products.products_id, url, products_img1 as logo + from products + LEFT JOIN `products_description` ON products.products_id=products_description.products_id + WHERE url='%s' + """ + cursor.execute(find_old%expo.old_url) + result = cursor.fetchall() + if not result: + return + logo = result[0]['logo'] + + + if logo: + logo = logo.replace('..', '') + + print(logo) + print(os.path.isfile(settings.MEDIA_ROOT[:-1]+logo)) + if (os.path.isfile(settings.MEDIA_ROOT[:-1]+logo)): + + expo.logo = logo + expo.save() + + diff --git a/proj/urls.py b/proj/urls.py index 8eab31d1..92cf2c80 100644 --- a/proj/urls.py +++ b/proj/urls.py @@ -11,6 +11,9 @@ class Robot(TemplateView): template_name = 'robots.txt' content_type = 'text/plain' +class YandexCheck(TemplateView): + template_name = 'client/simple_pages/yandex_check.html' + from sitemaps import ExpoCard, ExpoCity, ExpoCountry, ExpoTheme, ExpoTag, ConfCard, ConfCity, ConfCountry, ConfTheme,\ ConfTag, NewsSiteMap, BlogsSiteMap, Additional, Important @@ -34,6 +37,7 @@ urlpatterns = patterns('', url(r'^sitemap\.xml$', views.index, {'sitemaps': sitemaps}), url(r'^sitemap-(?P
.+)\.xml$', views.sitemap, {'sitemaps': sitemaps}), url(r'^robots.txt$', Robot.as_view()), + url(r'^yandex_4c326c16c916403e.html$', YandexCheck.as_view()), url(r'^$', MainPageView.as_view()), url(r'^page/', include('core.simple_urls')), url(r'^theme/', include('theme.urls')), diff --git a/proj/views.py b/proj/views.py index f93b2a0c..c5cb918d 100644 --- a/proj/views.py +++ b/proj/views.py @@ -37,7 +37,9 @@ def error404(request): expo_themes = Theme.active.expo_themes_with_count() conf_themes = Theme.active.conference_themes_with_count() context.update({'expo_themes': expo_themes, 'conf_themes': conf_themes}) - return render_to_response('client/404.html', context, context_instance=RequestContext(request)) + response = render_to_response('client/404.html', context, context_instance=RequestContext(request)) + response.status_code = 404 + return response class MainPageView(JitterCacheMixin,TemplateView): cache_range = settings.CACHE_RANGE diff --git a/settings/templatetags/template_filters.py b/settings/templatetags/template_filters.py index ec5ede18..ad5276dd 100644 --- a/settings/templatetags/template_filters.py +++ b/settings/templatetags/template_filters.py @@ -156,6 +156,10 @@ def timetable_by_day(qs, day): def random_social(value): return bool(random.getrandbits(1)) +@register.filter +def random3(value): + return random.randrange(0,3) + @register.filter def fourth(value): # return almost in 75% cases True in 25% False @@ -224,7 +228,10 @@ def without_page(value): @register.filter def note_by_user(obj, user): - return obj.get_note_by_user(user.id) + if obj: + + return obj.get_note_by_user(user.id) + return '' @register.filter def isdigit(value): diff --git a/templates/client/includes/banners/under_search.html b/templates/client/includes/banners/under_search.html index 695169b6..ea2f6dbb 100644 --- a/templates/client/includes/banners/under_search.html +++ b/templates/client/includes/banners/under_search.html @@ -1,9 +1,24 @@ {% load static %} {% load template_filters %} +
+ {% comment %} + {% if False|random3 == 1 %} + + {% else %} + {% if False|random3 == 2 %} + + {% else %} + + {% endif %} + {% endif %} + {% endcomment %} + + {% comment %} {% if False|fourth %} {% else %} {% endif %} + {% endcomment %}
\ No newline at end of file diff --git a/templates/client/includes/conference/conference_object.html b/templates/client/includes/conference/conference_object.html index 0e417f6f..87aee843 100644 --- a/templates/client/includes/conference/conference_object.html +++ b/templates/client/includes/conference/conference_object.html @@ -152,6 +152,22 @@ {% endfor %} {% endwith %} + {% else %} + {% if event.org %} +
{% trans 'Организатор' %}:
+
+ {{ event.org }} +
+ {% endif %} + {% endif %} + {% if event.place_alt %} + {% if not event.place %} +
{% trans 'Место проведения' %}:
+
+ {{ event.place_alt }} +
+ {% endif %} + {% endif %} {% if event.web_page %}
{% trans 'Веб-сайт' %}:
diff --git a/templates/client/includes/exposition/exposition_object.html b/templates/client/includes/exposition/exposition_object.html index b2491d4a..94710116 100644 --- a/templates/client/includes/exposition/exposition_object.html +++ b/templates/client/includes/exposition/exposition_object.html @@ -165,6 +165,15 @@ {% endif %} {% endif %} + {% if exposition.place_alt %} + {% if not exposition.place %} +
{% trans 'Место проведения' %}:
+
+ {{ exposition.place_alt }} +
+ {% endif %} + + {% endif %} {% if exposition.web_page %}
{% trans 'Веб-сайт' %}:
diff --git a/templates/client/index.html b/templates/client/index.html index 04cfcfd2..96882fb3 100644 --- a/templates/client/index.html +++ b/templates/client/index.html @@ -58,11 +58,17 @@
{% block menu_banner %} - {% if False|fourth %} - + {% comment %} + {% if False|random3 == 1 %} + {% else %} - + {% if False|random3 == 2 %} + + {% else %} + + {% endif %} {% endif %} + {% endcomment %} {% endblock %}
@@ -88,7 +94,7 @@ {% comment %}