Pre deployed commit

remotes/origin/1203
Kotiuk Nazarii 11 years ago
parent d8d8395f5a
commit b990914d51
  1. 4
      expobanner/forms.py
  2. 5
      expobanner/models.py
  3. 55
      expobanner/utils.py
  4. 28
      expobanner/views.py
  5. 16
      exposition/views.py
  6. 3
      templates/client/exposition/catalog.html
  7. 5
      templates/client/exposition/catalog_theme.html
  8. 20
      templates/client/includes/banners/aside_2.html
  9. 23
      templates/client/includes/banners/catalog_inner.html
  10. 24
      templates/client/includes/banners/detail_inner.html
  11. 9
      templates/client/includes/banners/header.html

@ -164,13 +164,13 @@ class TopCreateForm(forms.ModelForm):
theme_ids = self.cleaned_data['theme']
if theme_ids:
return Theme.objects.filter(id__in=theme_ids)
return None
return Theme.objects.none()
def clean_country(self):
country_ids = self.cleaned_data['country']
if country_ids:
return Country.objects.filter(id__in=country_ids)
return None
return Country.objects.none()
def clean_exposition(self):
expo_id = self.cleaned_data['exposition']

@ -255,6 +255,11 @@ class Top(models.Model, StatMixin):
class Meta:
ordering = ['position']
def get_event(self):
try:
return self.exposition_set.all()[0]
except IndexError:
return None
class TopStat(models.Model):
date = models.DateField()

@ -21,22 +21,21 @@ def get_by_sort(banner_list):
def get_banner_by_params(banners_list, urls, params):
#print('START. NUMBER of queries = %d'%len(connection.queries))
thematic_banners = []
url_banners = []
for banner in banners_list:
#print('-------------------------')
#print('number of queries = %d'%len(connection.queries))
# check by theme
banner_theme_ids = [str(theme.id) for theme in banner.theme.all()]
#print('number of queries = %d'%len(connection.queries))
if banner_theme_ids:
if params.get('theme'):
theme = params['theme']
if theme in banner_theme_ids:
flag = False
for th in theme:
if th in banner_theme_ids:
flag = True
if flag:
thematic_banners.append(banner)
continue
# check by country
@ -63,7 +62,7 @@ def get_banner_by_params(banners_list, urls, params):
if common_urls:
url_banners.append(banner)
continue
print('-------------------------')
if thematic_banners:
return random.choice(thematic_banners)
if url_banners:
@ -71,3 +70,43 @@ def get_banner_by_params(banners_list, urls, params):
return None
#print('END. NUMBER of queries = %d'%len(connection.queries))
def get_top_events(tops, params):
catalog = params.get('catalog')
country = params.get('country', '')
theme = params.get('theme', [])
city = params.get('city', '')
tag = params.get('tag', '')
catalog_tops = [item for item in tops if item.catalog == catalog]
good_tops = []
for top in catalog_tops:
country_ids = [str(item.id) for item in top.country.all()]
theme_ids = [str(item.id) for item in top.theme.all()]
excluded_tags_ids = [str(item.id) for item in top.excluded_tags.all()]
excluded_cities_ids = [str(item.id) for item in top.excluded_cities.all()]
if not country_ids and not theme_ids:
# universal top
good_tops.append(top)
continue
# check country
if country in country_ids and city not in excluded_cities_ids :
good_tops.append(top)
continue
# check theme
if tag in excluded_tags_ids:
continue
flag = False
for th in theme:
if th in theme_ids:
flag = True
continue
if flag:
good_tops.append(top)
sorted_top = sorted(good_tops, key=lambda x: x.position)
events = []
for top in sorted_top:
event = top.get_event()
if event:
events.append(event)
return events

@ -3,8 +3,10 @@ import json
import re
from django.http import HttpResponse
from django.shortcuts import redirect, get_object_or_404
from django.shortcuts import render_to_response
from django.template import RequestContext
from .models import Banner, BannerGroup, URL, Top
from expobanner.utils import get_by_sort, get_banner_by_params, get_client_ip
from expobanner.utils import get_by_sort, get_banner_by_params, get_client_ip, get_top_events
def click(request, banner_id):
@ -32,7 +34,7 @@ def get_banners(request):
elif url == u.url:
good_urls.append(u)
# fill parameters dict
params = {'theme': request.GET.get('theme'),
params = {'theme': request.GET.getlist('theme', []),
'tag': request.GET.get('tag'),
'country': request.GET.get('country'),
'city': request.GET.get('city'),
@ -69,25 +71,8 @@ def get_banners(request):
return HttpResponse(json.dumps(result, indent=4), content_type='application/json')
def get_top_events(tops, params):
catalog = params.get('catalog')
country = params.get('country', '')
theme = params.get('theme', [])
good_tops = []
for top in tops:
if top.catalog != catalog:
continue
country_ids = [str(item.id) for item in top.country.all()]
if not country in country_ids:
continue
from exposition.models import Exposition
from django.shortcuts import render_to_response
from django.template import RequestContext
def get_top(request):
params = {'theme': request.GET.get('theme'),
params = {'theme': request.GET.getlist('theme', []),
'tag': request.GET.get('tag'),
'country': request.GET.get('country'),
'city': request.GET.get('city'),
@ -95,6 +80,5 @@ def get_top(request):
tops = Top.cached.all()
events = get_top_events(tops, params)
expos = Exposition.objects.filter(top__isnull=False)
context = {'objects': expos}
context = {'objects': events}
return render_to_response('client/includes/exposition/expo_top.html', context, context_instance=RequestContext(request))

@ -303,7 +303,6 @@ class ExpoCatalog(MetadataMixin, ListView):
month = None
country = None
city = None
paid = None
def get_filtered_qs(self):
# diferent for views
@ -355,8 +354,6 @@ class ExpoCatalog(MetadataMixin, ListView):
def get_context_data(self, **kwargs):
context = super(ExpoCatalog, self).get_context_data(**kwargs)
if self.paid:
context['paid'] = self.paid
context['search_form'] = self.search_form
context['filter_object'] = self.filter_object
context['year'] = self.year
@ -411,11 +408,8 @@ class ExpoThemeCatalog(ExpoCatalog):
city_slug = self.kwargs.get('city_slug')
theme = get_object_or_404(Theme, url=slug)
self.kwargs['theme'] = theme
qs = self.model.enable.upcoming().filter(theme=theme)
qs = self.model.enable.upcoming().filter(theme=theme).exclude(paid__isnull=False)
paid= list(self.model.enable.filter(theme=theme).filter(paid__isnull=False))
if paid:
self.paid = paid
if country_slug:
country = get_object_or_404(Country, url=country_slug)
self.country = country
@ -449,11 +443,7 @@ class ExpoTagCatalog(ExpoCatalog):
slug = self.kwargs.get('slug')
tag = get_object_or_404(Tag, url=slug)
self.kwargs['tag'] = tag
qs = self.model.enable.upcoming().filter(tag=tag).exclude(paid__isnull=False)
paid= list(self.model.enable.filter(tag=tag).filter(paid__isnull=False))
if paid:
self.paid = paid
qs = self.model.enable.upcoming().filter(tag=tag)
self.filter_object = tag
return qs
@ -550,7 +540,7 @@ from django.core.mail import send_mail
from django.core.mail import EmailMessage
def send_to_organiser(request, slug):
exposition = get_object_or_404(Exposition, url=slug)
mail_send = exposition.paid.organiser
mail_send = 'evm@expomap.ru'
name = request.POST.get('person_inf')
email = request.POST.get('person')
phone = request.POST.get('phone', '')

@ -33,9 +33,6 @@
{% endblock %}
{% block content_list %}
{% if paid %}
{% include 'includes/exposition/expo_list_paid.html' with object_list=paid %}
{% endif %}
{% include 'includes/exposition/exposition_list.html' with object_list=object_list %}
{% endblock %}

@ -49,18 +49,13 @@
{% block page_title %}
<div class="page-title">
{# <h1>{% trans 'Выставки' %}: <strong>{{ filter_object.name }}</strong></h1> #}
<h1>{% if meta %}{{ meta.h1 }}{% else %}{% trans 'Выставки' %}: <strong>{{ filter_object.name }}</strong>{% endif %}</h1>
</div>
{% include 'includes/exposition/catalog_filter_period.html' %}
{% endblock %}
{% block content_list %}
{% if paid %}
{% include 'includes/exposition/exposition_list.html' with object_list=paid %}
{% endif %}
{% include 'includes/exposition/exposition_list.html' with object_list=object_list %}
{% endblock %}

@ -1,4 +1,24 @@
<div class="sbnr">
<div class="sbnr-wrap" id="expo_b_aside_2">
<!-- Яндекс.Директ -->
<script type="text/javascript">
yandex_partner_id = 58151;
yandex_site_bg_color = 'FFFFF';
yandex_ad_format = 'direct';
yandex_font_size = 1;
yandex_direct_type = 'vertical';
yandex_direct_limit = 3;
yandex_direct_title_font_size = 3;
yandex_direct_links_underline = false;
yandex_direct_title_color = '666666';
yandex_direct_url_color = '000000';
yandex_direct_text_color = '000000';
yandex_direct_hover_color = 'FF8000';
yandex_direct_sitelinks_color = 'FF8000';
yandex_direct_favicon = false;
yandex_no_sitelinks = false;
document.write('<scr'+'ipt type="text/javascript" src="//an.yandex.ru/system/context.js"></scr'+'ipt>');
</script>
</div>
</div>

@ -1,3 +1,26 @@
<div id="expo_b_catalog_inner">
<script type="text/javascript">
yandex_partner_id = 58151;
yandex_site_bg_color = 'FFFFFF';
yandex_ad_format = 'direct';
yandex_font_size = 1;
yandex_direct_type = 'horizontal';
yandex_direct_border_type = 'block';
yandex_direct_limit = 3;
yandex_direct_title_font_size = 3;
yandex_direct_border_radius = true;
yandex_direct_links_underline = false;
yandex_direct_header_bg_color = 'FEEAC7';
yandex_direct_bg_color = 'FFF9F0';
yandex_direct_border_color = 'FBE5C0';
yandex_direct_title_color = '666666';
yandex_direct_url_color = '000000';
yandex_direct_text_color = '000000';
yandex_direct_hover_color = 'FF3333';
yandex_direct_sitelinks_color = '666666';
yandex_direct_favicon = false;
yandex_no_sitelinks = false;
document.write('<scr'+'ipt type="text/javascript" src="//an.yandex.ru/system/context.js"></scr'+'ipt>');
</script>
</div>

@ -1,3 +1,25 @@
<div id="expo_b_detail_inner">
<script type="text/javascript">
yandex_partner_id = 58151;
yandex_site_bg_color = 'FFFFFF';
yandex_ad_format = 'direct';
yandex_font_size = 1;
yandex_direct_type = 'horizontal';
yandex_direct_border_type = 'block';
yandex_direct_limit = 3;
yandex_direct_title_font_size = 3;
yandex_direct_border_radius = true;
yandex_direct_links_underline = false;
yandex_direct_header_bg_color = 'FEEAC7';
yandex_direct_bg_color = 'FFF9F0';
yandex_direct_border_color = 'FBE5C0';
yandex_direct_title_color = '666666';
yandex_direct_url_color = '000000';
yandex_direct_text_color = '000000';
yandex_direct_hover_color = 'FF3333';
yandex_direct_sitelinks_color = '666666';
yandex_direct_favicon = false;
yandex_no_sitelinks = false;
document.write('<scr'+'ipt type="text/javascript" src="//an.yandex.ru/system/context.js"></scr'+'ipt>');
</script>
</div>

@ -1,3 +1,12 @@
<div class="abn" id="expo_b_header">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 468 на 60 -->
<ins class="adsbygoogle"
style="display:inline-block;width:468px;height:60px"
data-ad-client="ca-pub-5242360491829403"
data-ad-slot="4482648777"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
Loading…
Cancel
Save