diff --git a/conference/views.py b/conference/views.py index c01ce80c..bbbc63c6 100644 --- a/conference/views.py +++ b/conference/views.py @@ -10,6 +10,8 @@ from django.views.generic import ListView, DetailView from django.views.generic.edit import FormMixin from django.utils.translation import ugettext as _ from django.utils import translation +from service.models import Service +from service.views import order_forms from note.models import Note from models import Conference from accounts.models import User @@ -17,7 +19,6 @@ from country.models import Country from city.models import City from theme.models import Theme, Tag from service.order_forms import AdvertiseForm -from functions.search_forms import ExpositionSearchForm from meta.views import MetadataMixin from functions.cache_mixin import JitterCacheMixin, CacheMixin @@ -97,7 +98,6 @@ class ConferenceCatalog(JitterCacheMixin, MetadataMixin, ListView): model = Conference paginate_by = settings.CLIENT_PAGINATION template_name = 'client/conference/catalog.html' - search_form = ExpositionSearchForm filter_object = None year = None month = None @@ -152,10 +152,8 @@ class ConferenceCatalog(JitterCacheMixin, MetadataMixin, ListView): return qs.order_by('data_begin') - def get_context_data(self, **kwargs): context = super(ConferenceCatalog, self).get_context_data(**kwargs) - context['search_form'] = self.search_form context['filter_object'] = self.filter_object context['year'] = self.year context['month'] = self.month @@ -164,6 +162,7 @@ class ConferenceCatalog(JitterCacheMixin, MetadataMixin, ListView): class ConferenceCountryCatalog(ConferenceCatalog): catalog_url = '/conference/country/' + def get_filtered_qs(self): #this method used in parent get_queryset slug = self.kwargs.get('slug') @@ -173,6 +172,12 @@ class ConferenceCountryCatalog(ConferenceCatalog): qs = self.model.enable.upcoming().filter(country=country) return qs + def get_context_data(self, **kwargs): + context = super(ConferenceCountryCatalog, self).get_context_data(**kwargs) + context['country'] = str(self.kwargs['country'].id) + return context + + class ConferenceCityCatalog(ConferenceCatalog): catalog_url = '/conference/city/' def get_filtered_qs(self): @@ -184,6 +189,11 @@ class ConferenceCityCatalog(ConferenceCatalog): self.filter_object = city return qs + def get_context_data(self, **kwargs): + context = super(ConferenceCityCatalog, self).get_context_data(**kwargs) + context['city'] = str(self.kwargs['city'].id) + return context + class ConferenceThemeCatalog(ConferenceCatalog): template_name = 'conference/catalog_theme.html' @@ -219,6 +229,9 @@ class ConferenceThemeCatalog(ConferenceCatalog): context['country'] = self.country if self.city: context['city'] = self.city + + context['theme_for_filter'] = self.kwargs['theme'] + context['themes'] = [str(self.kwargs['theme'].id)] return context @@ -233,16 +246,20 @@ class ConferenceTagCatalog(ConferenceCatalog): self.filter_object = tag return qs + def get_context_data(self, **kwargs): + context = super(ConferenceTagCatalog, self).get_context_data(**kwargs) + tag = self.kwargs['tag'] + context['theme_for_filter'] = tag.theme + context['themes'] = [str(tag.theme.id)] + context['tag'] = str(self.kwargs['tag'].id) + return context + class ConferenceVisitors(MetadataMixin, ListView): paginate_by = settings.CLIENT_PAGINATION model = Conference - #template_name = 'event_visitors.html' - template_name = 'client/conference/visitors.html' - obj = None - search_form = ExpositionSearchForm def get_queryset(self): slug = self.kwargs.get('slug') @@ -252,20 +269,19 @@ class ConferenceVisitors(MetadataMixin, ListView): def get_context_data(self, **kwargs): context = super(ConferenceVisitors, self).get_context_data(**kwargs) - context['object'] = self.obj - context['search_form'] = self.search_form + obj = self.obj + context['object'] = obj + context['city'] = str(obj.city_id) + context['country'] = str(obj.country_id) + context['themes'] = [str(item.id) for item in obj.theme.all()] return context class ConferenceMembers(MetadataMixin, ListView): paginate_by = settings.CLIENT_PAGINATION model = Conference - #template_name = 'event_visitors.html' - template_name = 'client/conference/members.html' - obj = None - search_form = ExpositionSearchForm def get_queryset(self): slug = self.kwargs.get('slug') @@ -275,12 +291,14 @@ class ConferenceMembers(MetadataMixin, ListView): def get_context_data(self, **kwargs): context = super(ConferenceMembers, self).get_context_data(**kwargs) - context['object'] = self.obj - context['search_form'] = self.search_form + obj = self.obj + context['object'] = obj + context['city'] = str(obj.city_id) + context['country'] = str(obj.country_id) + context['themes'] = [str(item.id) for item in obj.theme.all()] return context -from service.models import Service -from service.views import order_forms + class ConferenceThankView(MetadataMixin, DetailView): model = Conference @@ -324,7 +342,11 @@ class ConferenceServiceView(FormMixin, DetailView): raise Http404 context['form'] = self.get_form(self.form_class) context['service'] = service - context['object'] = self.get_object() + obj = self.get_object() + context['object'] = obj + context['city'] = str(obj.city_id) + context['country'] = str(obj.country_id) + context['themes'] = [str(item.id) for item in obj.theme.all()] return context def form_valid(self, form): @@ -347,14 +369,11 @@ class ConferenceServiceView(FormMixin, DetailView): 'city':user.profile.city.name if user.profile.city else '', 'phone': user.profile.phone if user.profile.phone else ''} - - return initial else: return self.initial.copy() - class ConferenceDetail(JitterCacheMixin, DetailView): cache_range = settings.CACHE_RANGE model = Conference @@ -370,19 +389,21 @@ class ConferenceDetail(JitterCacheMixin, DetailView): except City.DoesNotExist: return super(ConferenceDetail, self).dispatch(request, *args, **kwargs) - - def get_context_data(self, **kwargs): context = super(ConferenceDetail, self).get_context_data(**kwargs) context['advertising_form'] = AdvertiseForm() + obj = self.object + context['city'] = str(obj.city_id) + context['country'] = str(obj.country_id) + context['themes'] = [str(item.id) for item in obj.theme.all()] return context + class ConferenceList(MetadataMixin, JitterCacheMixin, ListView): cache_range = settings.CACHE_RANGE model = Conference paginate_by = settings.CLIENT_PAGINATION template_name = 'client/conference/conference_list.html' - search_form = ExpositionSearchForm catalog_url = '/conference/' year = None month = None @@ -410,7 +431,6 @@ class ConferenceList(MetadataMixin, JitterCacheMixin, ListView): context = super(ConferenceList, self).get_context_data(**kwargs) context['month'] = self.month context['catalog_url'] = self.catalog_url - context['search_form'] = self.search_form context['year'] = self.year context['month'] = self.month return context diff --git a/core/views.py b/core/views.py index 9545b925..9e0af308 100644 --- a/core/views.py +++ b/core/views.py @@ -244,7 +244,7 @@ class DeletePage(DeleteView): class PageDetailed(DetailView): model = Page - template_name = 'client/base_page.html' + template_name = 'client/base_catalog.html' slug_field = 'url' slug_url_kwarg = 'url' diff --git a/expobanner/admin.py b/expobanner/admin.py index d1273215..5bb709d7 100644 --- a/expobanner/admin.py +++ b/expobanner/admin.py @@ -1,8 +1,12 @@ # -*- coding: utf-8 -*- -from django.views.generic import TemplateView, CreateView, ListView, UpdateView +from django.views.generic import TemplateView, CreateView, ListView, UpdateView, DetailView from django.conf import settings -from expobanner.models import URL, BannerGroup, Banner -from expobanner.forms import UrlCreateForm, BannerCreateGroupForm, BannerCreateForm, BannerGroupUpdateForm +from django.http import HttpResponseRedirect +from django.shortcuts import get_object_or_404 +from expobanner.models import URL, BannerGroup, Banner, Paid +from expobanner.forms import UrlCreateForm, BannerCreateGroupForm, BannerCreateForm, BannerGroupUpdateForm,\ + PaidCreateForm, PaidUpdateForm, TopCreateForm +from exposition.models import Exposition class BannersControl(TemplateView): @@ -52,6 +56,12 @@ class BannerGroupList(AbstractList): class BannerList(AbstractList): model = Banner verbose = u'Список банеров' + template_name = 'admin/expobanner/banner_list.html' + + def get_queryset(self): + qs = super(BannerList, self).get_queryset() + qs = qs.filter(group__isnull=False) + return qs # UPDATE VIEWS class AbstractUpdate(UpdateView): @@ -71,4 +81,76 @@ class BannerGroupUpdate(AbstractUpdate): class BannerUpdate(AbstractUpdate): model = Banner - form_class = BannerCreateForm \ No newline at end of file + form_class = BannerCreateForm + + +class BannerStat(DetailView): + model = Banner + template_name = 'admin/expobanner/banner_stat.html' + +class PaidList(ListView): + model = Exposition + template_name = 'admin/expobanner/paid_list.html' + paginate_by = settings.ADMIN_PAGINATION + + def get_queryset(self): + return self.model.objects.language().filter(paid_new__isnull=False) + +class PaidCreate(CreateView): + form_class = PaidCreateForm + template_name = 'admin/expobanner/paid_create.html' + success_url = '/admin/expobanners/paid/list/' + +class PaidUpdate(UpdateView): + model = Paid + form_class = PaidUpdateForm + template_name = 'admin/expobanner/paid_update.html' + success_url = '/admin/expobanners/paid/list/' + + def get_initial(self): + """ + Returns the initial data to use for forms on this view. + """ + initial = super(PaidUpdate, self).get_initial() + obj = self.object + initial['tickets'] = obj.tickets.url + initial['participation'] = obj.participation.url + initial['official'] = obj.official.url + + return initial + + def get_context_data(self, **kwargs): + context = super(PaidUpdate, self).get_context_data(**kwargs) + obj = self.object + context['exposition'] = obj.get_event() + return context + + +def paid_turn(request, pk, status): + paid = get_object_or_404(Paid, pk=pk) + if status == 'on': + paid.public = True + else: + paid.public = False + paid.save() + return HttpResponseRedirect('/admin/expobanners/paid/list/') + + +class PaidStat(DetailView): + model = Paid + template_name = 'admin/expobanner/paid_stat.html' + + +class TopList(ListView): + model = Exposition + template_name = 'admin/expobanner/top_list.html' + paginate_by = settings.ADMIN_PAGINATION + + def get_queryset(self): + return self.model.objects.language().filter(top__isnull=False) + + +class TopCreate(CreateView): + form_class = TopCreateForm + template_name = 'admin/expobanner/top_create.html' + success_url = '/admin/expobanners/top/list/' diff --git a/expobanner/admin_urls.py b/expobanner/admin_urls.py index db31823e..5497da30 100644 --- a/expobanner/admin_urls.py +++ b/expobanner/admin_urls.py @@ -3,19 +3,27 @@ from django.conf.urls import patterns, url from expobanner.admin import * urlpatterns = patterns('expobanner.admin', + # banners url(r'^banners/control/$', BannersControl.as_view(), name='expobanner-baneers_control'), - url(r'^banners/url/$', CreateUrl.as_view(), name='expobanner-create_url'), url(r'^banners/group/$', CreateBannerGroup.as_view(), name='expobanner-create_group'), url(r'^banners/banner/$', CreateBanner.as_view(), name='expobanner-create_banner'), - url(r'^banners/url/list/$', UrlList.as_view(), name='expobanner-list_url'), url(r'^banners/group/list/$', BannerGroupList.as_view(), name='expobanner-list_group'), url(r'^banners/banner/list/$', BannerList.as_view(), name='expobanner-list_banner'), - url(r'^banners/url/(?P\d+)/edit/$', UrlUpdate.as_view(), name='expobanner-update_url'), url(r'^banners/group/(?P\d+)/edit/$', BannerGroupUpdate.as_view(), name='expobanner-update_group'), url(r'^banners/banner/(?P\d+)/edit/$', BannerUpdate.as_view(), name='expobanner-update_banner'), - - + url(r'^banners/banner/(?P\d+)/stat/$', BannerStat.as_view(), name='expobanner_stat_banner'), + # paid + url(r'^paid/list/$', PaidList.as_view(), name='expobanner-list_paid'), + url(r'^paid/(?P\d+)/edit/$', PaidUpdate.as_view(), name='expobanner-update_paid'), + url(r'^paid/$', PaidCreate.as_view(), name='expobanner-create_paid'), + url(r'^paid/turn/(?P\d+)/(?P.*)/$', paid_turn, name='expobanner-paid-turn'), + url(r'^paid/(?P\d+)/stat/$', PaidStat.as_view(), name='expobanner_stat_paid'), + # top + url(r'^top/list/$', TopList.as_view(), name='expobanner-list_top'), + url(r'^top/(?P\d+)/edit/$', PaidUpdate.as_view(), name='expobanner-update_top'), + url(r'^top/$', TopCreate.as_view(), name='expobanner-create_top'), + url(r'^top/(?P\d+)/stat/$', PaidStat.as_view(), name='expobanner_stat_top'), ) \ No newline at end of file diff --git a/expobanner/forms.py b/expobanner/forms.py index 82bfd39e..5c3b6473 100644 --- a/expobanner/forms.py +++ b/expobanner/forms.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from django import forms -from expobanner.models import URL, BannerGroup, Banner +from expobanner.models import URL, BannerGroup, Banner, Paid, Top +from exposition.models import Exposition from country.models import Country from city.models import City from theme.models import Theme, Tag @@ -34,7 +35,147 @@ class BannerCreateForm(forms.ModelForm): #city = forms.CharField(label=u'Город', widget=forms.HiddenInput(), required=False) #tag = forms.CharField(label=u'Тег', widget=forms.HiddenInput(), required=False) - class Meta: model = Banner - exclude = ['created_at', 'updated_at', 'often', 'paid'] \ No newline at end of file + exclude = ['created_at', 'updated_at', 'often', 'paid', 'stat_pswd'] + + +class ClientStatForm(forms.Form): + stat_pswd = forms.CharField(label=u'Введите пароль:') + + def check_pass(self, obj): + pswd = self.cleaned_data['stat_pswd'] + return obj.stat_pswd == pswd + + +class PaidCreateForm(forms.ModelForm): + verbose = u'Создать проплаченую выставку' + exposition = forms.CharField(label=u'Выставка', widget=forms.HiddenInput()) + tickets = forms.URLField(label=u'Линк на билеты') + participation = forms.URLField(label=u'Линк на участие') + official = forms.URLField(label=u'Линк на официальный сайт') + + class Meta: + model = Paid + fields = ['logo', 'organiser', 'public'] + + def save(self, commit=True): + paid = super(PaidCreateForm, self).save(commit=False) + if commit: + expo = self.cleaned_data['exposition'] + tickets = self.cleaned_data['tickets'] + tickets_link = Banner.objects.create_for_paid(expo, tickets, 'tickets') + participation = self.cleaned_data['participation'] + participation_link = Banner.objects.create_for_paid(expo, participation, 'participation') + official = self.cleaned_data['official'] + official_link = Banner.objects.create_for_paid(expo, official, 'official') + catalog = expo.get_permanent_url() + catalog_link = Banner.objects.create_for_paid(expo, catalog, 'catalog') + + + paid.tickets = tickets_link + paid.participation = participation_link + paid.official = official_link + paid.catalog = catalog_link + paid.save() + + expo.paid_new = paid + expo.save() + return paid + + def clean_exposition(self): + expo_id = self.cleaned_data['exposition'] + try: + expo = Exposition.objects.get(id=expo_id) + except Exposition.DoesNotExist: + raise forms.ValidationError(u'Такой выставки не существует') + return expo + +class PaidUpdateForm(forms.ModelForm): + tickets = forms.URLField(label=u'Линк на билеты') + participation = forms.URLField(label=u'Линк на участие') + official = forms.URLField(label=u'Линк на официальный сайт') + + class Meta: + model = Paid + fields = ['logo', 'organiser', 'public'] + + def save(self, commit=True): + paid = super(PaidUpdateForm, self).save(commit=False) + if commit: + tickets = self.cleaned_data['tickets'] + b_tickets = paid.tickets + if tickets != b_tickets.url: + b_tickets.url = tickets + b_tickets.save() + + participation = self.cleaned_data['participation'] + b_participation = paid.participation + if participation != b_participation.url: + b_participation.url = participation + b_participation.save() + + official = self.cleaned_data['official'] + b_official = paid.official + if official != b_official.url: + b_official.url = official + b_official.save() + + paid.save() + + return paid + + +class TopCreateForm(forms.ModelForm): + verbose = u'Создать выставку в топе' + exposition = forms.CharField(label=u'Выставка', widget=forms.HiddenInput()) + country = forms.MultipleChoiceField(label=u'Страна', choices=[('', ' ')] + [(c.id, c.name) for c in Country.objects.all()], required=False) + theme = forms.MultipleChoiceField(label=u'Тематика', required=False, + choices=[('', ' ')] + [(item.id, item.name) for item in Theme.objects.language().all()]) + excluded_cities = forms.CharField(label=u'Город', widget=forms.HiddenInput(), required=False) + excluded_tags = forms.CharField(label=u'Тег', widget=forms.HiddenInput(), required=False) + class Meta: + model = Top + fields = ['catalog', 'position', 'theme', 'excluded_tags', 'country', 'excluded_cities', 'fr', 'to'] + + def save(self, commit=True): + top = super(TopCreateForm, self).save(commit=False) + # Prepare a 'save_m2m' method for the form, + old_save_m2m = self.save_m2m + + def save_m2m(): + old_save_m2m() + # This is where we actually link the pizza with toppings + top.theme.clear() + for theme in self.cleaned_data['theme']: + top.theme.add(theme) + + self.save_m2m = save_m2m + + if commit: + expo = self.cleaned_data['exposition'] + top.save() + self.save_m2m() + expo.top = top + expo.save() + return top + + def clean_theme(self): + theme_ids = self.cleaned_data['theme'] + if theme_ids: + return Theme.objects.filter(id__in=theme_ids) + 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 Country.objects.none() + + def clean_exposition(self): + expo_id = self.cleaned_data['exposition'] + try: + expo = Exposition.objects.get(id=expo_id) + except Exposition.DoesNotExist: + raise forms.ValidationError(u'Такой выставки не существует') + return expo \ No newline at end of file diff --git a/expobanner/management/__init__.py b/expobanner/management/__init__.py new file mode 100644 index 00000000..13ef41a7 --- /dev/null +++ b/expobanner/management/__init__.py @@ -0,0 +1 @@ +__author__ = 'kotzilla' diff --git a/expobanner/management/commands/__init__.py b/expobanner/management/commands/__init__.py new file mode 100644 index 00000000..13ef41a7 --- /dev/null +++ b/expobanner/management/commands/__init__.py @@ -0,0 +1 @@ +__author__ = 'kotzilla' diff --git a/expobanner/management/commands/banner_log_check_previous_day.py b/expobanner/management/commands/banner_log_check_previous_day.py new file mode 100644 index 00000000..3a6a1f10 --- /dev/null +++ b/expobanner/management/commands/banner_log_check_previous_day.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +from datetime import date, timedelta +from django.core.management.base import BaseCommand +from expobanner.models import Log, LogStat, Banner +from django.conf import settings + + +class Command(BaseCommand): + def handle(self, *args, **options): + prev_day = date.today() - timedelta(days=1) + for banner in Banner.objects.select_related('group').filter(): + try: + logstat = LogStat.objects.get(banner=banner, group=banner.group, date=prev_day) + except LogStat.DoesNotExist: + logstat = LogStat(banner=banner, group=banner.group, date=prev_day) + + views = Log.objects.filter(datetime__startswith=prev_day, + banner=banner, + group=banner.group, + type=1).count() + clicks = Log.objects.filter(datetime__startswith=prev_day, + banner=banner, + group=banner.group, + type=2).count() + unique_views = Log.objects.filter(datetime__startswith=prev_day, + banner=banner, + group=banner.group, + type=1).values('ip').distinct().count() + unique_clicks = Log.objects.filter(datetime__startswith=prev_day, + banner=banner, + group=banner.group, + type=2).values('ip').distinct().count() + + if not logstat.click or logstat.click < clicks: + logstat.click = clicks + if not logstat.view or logstat.view < views: + logstat.view = views + if not logstat.unique_click or logstat.unique_click < unique_clicks: + logstat.unique_click = unique_clicks + if not logstat.unique_view or logstat.unique_view < unique_views: + logstat.unique_view = unique_views + logstat.save() diff --git a/expobanner/management/commands/banner_log_update.py b/expobanner/management/commands/banner_log_update.py new file mode 100644 index 00000000..86cfb920 --- /dev/null +++ b/expobanner/management/commands/banner_log_update.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- +from datetime import date +from django.core.management.base import BaseCommand +from expobanner.models import Log, LogStat, Banner, PaidStat +from exposition.models import Exposition + + +class Command(BaseCommand): + def handle(self, *args, **options): + today = date.today() + # banners + for banner in Banner.objects.select_related('group').filter(public=True, group__isnull=False): + try: + logstat = LogStat.objects.get(banner=banner, group=banner.group, date=today) + except LogStat.DoesNotExist: + logstat = LogStat(banner=banner, group=banner.group, date=today) + + views = Log.objects.filter(datetime__startswith=today, + banner=banner, + group=banner.group, + type=1).count() + clicks = Log.objects.filter(datetime__startswith=today, + banner=banner, + group=banner.group, + type=2).count() + unique_views = Log.objects.filter(datetime__startswith=today, + banner=banner, + group=banner.group, + type=1).values('ip').distinct().count() + unique_clicks = Log.objects.filter(datetime__startswith=today, + banner=banner, + group=banner.group, + type=2).values('ip').distinct().count() + logstat.click = clicks + logstat.view = views + logstat.unique_click = unique_clicks + logstat.unique_view = unique_views + logstat.save() + + # paid expos + expos = list(Exposition.objects.select_related('paid_new').filter(paid_new__isnull=False)) + for expo in expos: + paid = expo.paid_new + try: + paidstat = PaidStat.objects.get(paid=paid, date=today) + except PaidStat.DoesNotExist: + paidstat = PaidStat(paid=paid, date=today) + + t_clicks = Log.objects.filter(datetime__startswith=today, banner=paid.tickets, type=2).count() + p_clicks = Log.objects.filter(datetime__startswith=today, banner=paid.participation, type=2).count() + o_clicks = Log.objects.filter(datetime__startswith=today, banner=paid.official, type=2).count() + c_clicks = Log.objects.filter(datetime__startswith=today, banner=paid.catalog, type=2).count() + + paidstat.tickets_clicks = t_clicks + paidstat.participation_clicks = p_clicks + paidstat.official_clicks = o_clicks + paidstat.catalog_clicks = c_clicks + + paidstat.save() + + + + + + + + diff --git a/expobanner/managers.py b/expobanner/managers.py index e4cebd65..c3ecadf0 100644 --- a/expobanner/managers.py +++ b/expobanner/managers.py @@ -23,6 +23,15 @@ class BiasedManager(models.Manager): shuffle(result) return result + def create_for_paid(self, expo, url, role): + try: + name = str(expo.name) + except UnicodeEncodeError, UnicodeDecodeError: + name = expo.url + + alt = u'%s_%s'%(name, role) + return self.create(alt=alt, url=url, paid=True) + class BannerGroupCached(models.Manager): def all(self): key = 'banner_group_all' @@ -55,4 +64,14 @@ class URLCached(models.Manager): if not result: result = list(self.filter(public=True)) cache.set(key, result, 150) + return result + +class TopCached(models.Manager): + def all(self): + key = 'expo_b_top_all' + result = cache.get(key) + if not result: + result = list(self.prefetch_related('theme', 'country', 'excluded_tags', 'excluded_cities').all()) + cache.set(key, result, 80) + return result \ No newline at end of file diff --git a/expobanner/mixins.py b/expobanner/mixins.py new file mode 100644 index 00000000..9520ab37 --- /dev/null +++ b/expobanner/mixins.py @@ -0,0 +1,3 @@ +class StatMixin(object): + def get_cookie_name(self): + return u'%s_%d'%(self._meta.db_table, self.id) \ No newline at end of file diff --git a/expobanner/models.py b/expobanner/models.py index a016785d..d125ee1b 100644 --- a/expobanner/models.py +++ b/expobanner/models.py @@ -1,11 +1,14 @@ # -*- coding: utf-8 -*- +import random import hashlib from datetime import datetime, date from django.db import models from django.utils.translation import ugettext_lazy as _ from django.conf import settings from django.contrib.sites.models import Site -from .managers import BiasedManager, BannerGroupCached, URLCached +from django.db.models.signals import post_save +from .managers import BiasedManager, BannerGroupCached, URLCached, TopCached +from .mixins import StatMixin from theme.models import Theme from country.models import Country @@ -64,7 +67,7 @@ class BannerGroup (models.Model): return '/admin/expobanners/banners/group/%d/edit/'%self.id -class Banner(models.Model): +class Banner(models.Model, StatMixin): objects = BiasedManager() title = models.CharField(verbose_name=u'Заголовок', max_length=255, blank=True) @@ -92,13 +95,18 @@ class Banner(models.Model): html = models.BooleanField(verbose_name=_('HTML?'), default=False) flash = models.BooleanField(verbose_name=_('Flash?'), default=False) + js = models.BooleanField(verbose_name=_('Javascript?'), default=False) paid = models.BooleanField(verbose_name=_('Is Paid event link?'), default=False) - public = models.BooleanField(verbose_name=u'Активный', default=True) created_at = models.DateTimeField(verbose_name=_('Created At'), auto_now_add=True) updated_at = models.DateTimeField(verbose_name=_('Updated At'), auto_now=True) + stat_pswd = models.CharField(max_length=16) + + class Meta: + ordering = ['-public'] + def get_admin_url(self): return '/admin/expobanners/banners/banner/%d/edit/'%self.id @@ -110,10 +118,9 @@ class Banner(models.Model): key = str(datetime.now()) return hashlib.md5(key).hexdigest() - def log(self, request, type, key): + def log(self, request, type): log = { 'type': type, - 'key': key, 'banner': self, 'group': self.group, 'ip': request.META.get('REMOTE_ADDR'), @@ -150,6 +157,9 @@ class Banner(models.Model): return ('banner_click', (), {'banner_id': self.pk, 'key': self.key()}) return get_absolute_url(self) + def get_click_link(self): + return '/expo-b/click/%d/'%self.id + class Meta: ordering = ['sort'] verbose_name = _('Banner') @@ -158,7 +168,7 @@ class Banner(models.Model): class Log(models.Model): banner = models.ForeignKey(Banner, related_name='banner_logs') - group = models.ForeignKey(BannerGroup, related_name='group_logs', verbose_name=_('Group'), blank=True) + group = models.ForeignKey(BannerGroup, related_name='group_logs', verbose_name=_('Group'), blank=True, null=True) urls = models.ManyToManyField(URL, related_name='url_logs', verbose_name=_('URLs'), blank=True) user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True, related_name='users', verbose_name=_('User')) @@ -181,7 +191,7 @@ class Log(models.Model): class LogStat(models.Model): banner = models.ForeignKey(Banner, related_name='banner_stat', verbose_name=_('Banner'), blank=True) - group = models.ForeignKey(BannerGroup, related_name='group_stat', verbose_name=_('Group'), blank=True) + group = models.ForeignKey(BannerGroup, related_name='group_stat', verbose_name=_('Group'), blank=True, null=True) urls = models.ManyToManyField(URL, related_name='url_bloks', verbose_name=_('URLs'), null=True, blank=True) date = models.DateField(verbose_name=_('Data')) @@ -195,17 +205,26 @@ class LogStat(models.Model): # ------------------ -class Paid(models.Model): +class Paid(models.Model, StatMixin): tickets = models.ForeignKey(Banner, related_name='paid_tickets') participation = models.ForeignKey(Banner, related_name='paid_participation') official = models.ForeignKey(Banner, related_name='paid_official') - logo = models.ImageField(upload_to='/')# !!!!! - organiser = models.CharField(max_length=100) - active = models.BooleanField(default=True) + catalog = models.ForeignKey(Banner, related_name='paid_catalog') + logo = models.ImageField(upload_to='expo-b/paid', blank=True) + organiser = models.CharField(max_length=100, blank=True) + public = models.BooleanField(default=True, verbose_name=u'Активная') stat_pswd = models.CharField(max_length=16) created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) + class Meta: + ordering = ['-public'] + + def get_event(self): + if self.exposition_set.all().exists(): + return self.exposition_set.all()[0] + return None + class PaidStat(models.Model): paid = models.ForeignKey(Paid) @@ -214,22 +233,33 @@ class PaidStat(models.Model): price_views = models.PositiveIntegerField(default=0) catalog_views = models.PositiveIntegerField(default=0) catalog_clicks = models.PositiveIntegerField(default=0) - - -class Top(models.Model): - catalog = models.CharField(max_length=16) - position = models.PositiveIntegerField(blank=True, null=True) - theme = models.ManyToManyField('theme.Theme', blank=True, null=True) - excluded_tags = models.ManyToManyField('theme.Tag', blank=True, null=True) - country = models.ManyToManyField('country.Country', blank=True, null=True) - excluded_cities = models.ManyToManyField('city.City', blank=True, null=True) - fr = models.DateField(default=date.today()) - to = models.DateField(blank=True, null=True) + tickets_clicks = models.PositiveIntegerField(default=0) + participation_clicks = models.PositiveIntegerField(default=0) + official_clicks = models.PositiveIntegerField(default=0) + + +class Top(models.Model, StatMixin): + catalog = models.CharField(max_length=16, verbose_name=u'Каталог для топа') + position = models.PositiveIntegerField(blank=True, default=2, null=True, verbose_name=u'Позиция') + theme = models.ManyToManyField('theme.Theme', blank=True, null=True, verbose_name=u'Тематики') + excluded_tags = models.ManyToManyField('theme.Tag', blank=True, null=True, verbose_name=u'Исключить теги') + country = models.ManyToManyField('country.Country', blank=True, null=True, verbose_name=u'Страны') + excluded_cities = models.ManyToManyField('city.City', blank=True, null=True, verbose_name=u'Исключить города') + fr = models.DateField(default=date.today(), verbose_name=u'Начало') + to = models.DateField(blank=True, null=True, verbose_name=u'Конец') stat_pswd = models.CharField(max_length=16) + objects = models.Manager() + cached = TopCached() + 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() @@ -238,4 +268,32 @@ class TopStat(models.Model): country = models.ForeignKey('country.Country', blank=True, null=True) city = models.ForeignKey('city.City', blank=True, null=True) views = models.PositiveIntegerField(default=0) - clicks = models.PositiveIntegerField(default=0) \ No newline at end of file + clicks = models.PositiveIntegerField(default=0) + +def generatePassword(length=5): + """ + generate random password + """ + SYMBOLS = [',', '.', '?', '!', '-', '+', '1', '2', '3', '4', '5', '6', '7', '8', + '9', '0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', + 'm', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', + 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '#'] + PASSWORD_LENGTH = length + newPassword = [] + for i in range(PASSWORD_LENGTH): + newPassword.append(SYMBOLS[random.randrange(0, len(SYMBOLS))]) + return ''.join(newPassword) + + +def generate_stat_pass(sender, **kwargs): + obj = kwargs['instance'] + if not obj.stat_pswd: + obj.stat_pswd = generatePassword() + obj.save() + + + +post_save.connect(generate_stat_pass, sender=Banner) +post_save.connect(generate_stat_pass, sender=Paid) +post_save.connect(generate_stat_pass, sender=Top) diff --git a/expobanner/stat_views.py b/expobanner/stat_views.py new file mode 100644 index 00000000..a1ac7ae7 --- /dev/null +++ b/expobanner/stat_views.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +from django.http import HttpResponseRedirect +from django.views.generic import TemplateView, CreateView, ListView, UpdateView, DetailView +from django.views.generic.edit import FormMixin +from django.forms.util import ErrorList +from django.conf import settings +from django.core.urlresolvers import reverse +from expobanner.models import Banner, Paid +from expobanner.forms import ClientStatForm + + + +class BannerStat(FormMixin, DetailView): + model = Banner + form_class = ClientStatForm + template_name = 'client/expobanners/banner_stat.html' + + def get_success_url(self): + return reverse('banner_stat_client', kwargs={'pk': self.object.pk}) + + def get_context_data(self, **kwargs): + context = super(BannerStat, self).get_context_data(**kwargs) + obj = self.object + cookie_name = obj.get_cookie_name() + cookie = self.request.session.get(cookie_name) + if not cookie: + form = context.get('form') + # form in context if form invalid called + if not form: + context['form'] = self.get_form(self.form_class) + + return context + + def post(self, request, *args, **kwargs): + self.object = self.get_object() + form = self.get_form(self.form_class) + if form.is_valid(): + return self.form_valid(form) + else: + return self.form_invalid(form) + + def form_valid(self, form): + obj = self.object + success = form.check_pass(obj) + if success: + self.request.session[obj.get_cookie_name()] = 1 + return HttpResponseRedirect(self.get_success_url()) + else: + form.errors['stat_pswd'] = ErrorList([u'Неправильный пароль']) + return self.form_invalid(form) + +class PaidStat(BannerStat): + model = Paid + template_name = 'client/expobanners/paid_stat.html' + + def get_success_url(self): + return reverse('paid_stat_client', kwargs={'pk': self.object.pk}) \ No newline at end of file diff --git a/expobanner/urls.py b/expobanner/urls.py index 126ae232..65e3a854 100644 --- a/expobanner/urls.py +++ b/expobanner/urls.py @@ -1,11 +1,13 @@ from django.conf.urls import url - +from expobanner.stat_views import * from . import views urlpatterns = [ - url(r'^click/(?P\d{1,4})/(?P[-\w]+)/$', views.click, name='banner_click'), - url(r'^view/(?P\d+)/(?P[-\w]+)/$', views.view, name='banner_view'), - + url(r'^click/(?P\d{1,4})/$', views.click, name='banner_click'), + #url(r'^view/(?P\d+)/$', views.view, name='banner_view'), # url(r'^get-banners/$', views.get_banners), + url(r'^get-tops/$', views.get_top), + url(r'^banner/(?P\d+)/stat/$', BannerStat.as_view(), name='banner_stat_client'), + url(r'^paid/(?P\d+)/stat/$', PaidStat.as_view(), name='paid_stat_client'), ] diff --git a/expobanner/utils.py b/expobanner/utils.py new file mode 100644 index 00000000..9c4222a2 --- /dev/null +++ b/expobanner/utils.py @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- +import random +from django.db import connection + +def get_client_ip(request): + x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') + if x_forwarded_for: + ip = x_forwarded_for.split(',')[0] + else: + ip = request.META.get('REMOTE_ADDR') + return ip + +def get_by_sort(banner_list): + max_sort = 0 + for banner in banner_list: + sort = banner.sort + if sort > max_sort: + max_sort = sort + result = [banner for banner in banner_list if banner.sort == max_sort] + return result + + +def get_banner_by_params(banners_list, urls, params): + thematic_banners = [] + url_banners = [] + + for banner in banners_list: + # check by theme + banner_theme_ids = [str(theme.id) for theme in banner.theme.all()] + if banner_theme_ids: + if params.get('theme'): + theme = params['theme'] + + flag = False + for th in theme: + if th in banner_theme_ids: + flag = True + if flag: + thematic_banners.append(banner) + continue + # check by country + banner_country_ids = [str(country.id) for country in banner.country.all()] + #print('number of queries = %d'%len(connection.queries)) + if banner_country_ids: + if params.get('country'): + + country = params['country'] + if country in banner_country_ids: + thematic_banners.append(banner) + continue + + # check by url + if urls: + banner_urls = banner.urls.all() + print('number of queries = %d'%len(connection.queries)) + + if banner_urls: + + banner_urls = set(banner_urls) + common_urls = set(urls).intersection(banner_urls) + + if common_urls: + url_banners.append(banner) + continue + + if thematic_banners: + return random.choice(thematic_banners) + if url_banners: + return random.choice(url_banners) + 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 \ No newline at end of file diff --git a/expobanner/views.py b/expobanner/views.py index ebe8f182..232ff7d0 100644 --- a/expobanner/views.py +++ b/expobanner/views.py @@ -1,97 +1,29 @@ # -*- coding: utf-8 -*- import json import re -import random from django.http import HttpResponse from django.shortcuts import redirect, get_object_or_404 -from .models import Banner, BannerGroup, URL +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, get_top_events -def click(request, banner_id, key): +def click(request, banner_id): banner = get_object_or_404(Banner, pk=banner_id) - banner.log(request, 2, key) + banner.log(request, 2) return redirect(banner.url) -def view(request, banner_id, key): +def view(request, banner_id): banner = get_object_or_404(Banner, pk=banner_id) - banner.log(request, 1, key) + banner.log(request, 1) return redirect(banner.img.url) - -def get_client_ip(request): - x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') - if x_forwarded_for: - ip = x_forwarded_for.split(',')[0] - else: - ip = request.META.get('REMOTE_ADDR') - return ip - -def get_by_sort(banner_list): - max_sort = 0 - for banner in banner_list: - sort = banner.sort - if sort > max_sort: - max_sort = sort - result = [banner for banner in banner_list if banner.sort == max_sort] - return result - -from django.db import connection -def get_banner_by_params(banners_list, urls, params): - print('START. NUMBER of queries = %d'%len(connection.queries)) - good_banners = [] - - for banner in banners_list: - print('-------------------------') - print('number of queries = %d'%len(connection.queries)) - print(banner) - # 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: - good_banners.append(banner) - continue - # check by country - banner_country_ids = [str(country.id) for country in banner.country.all()] - print('number of queries = %d'%len(connection.queries)) - if banner_country_ids: - if params.get('country'): - - country = params['country'] - if country in banner_country_ids: - good_banners.append(banner) - continue - - # check by url - if urls: - banner_urls = banner.urls.all() - print('number of queries = %d'%len(connection.queries)) - - if banner_urls: - - banner_urls = set(banner_urls) - common_urls = set(urls).intersection(banner_urls) - - if common_urls: - good_banners.append(banner) - continue - print('-------------------------') - good_banners = get_by_sort(good_banners) - - print('END. NUMBER of queries = %d'%len(connection.queries)) - - - if good_banners: - return random.choice(good_banners) - return [] - def get_banners(request): + #url = request.GET.get('url', '/') + url = request.META.get('HTTP_REFERER', '/') # get urls by current url - url = request.GET.get('url', '/') urls = URL.cached.all() good_urls = [] for u in urls: @@ -102,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'), @@ -110,17 +42,43 @@ def get_banners(request): group_banners = BannerGroup.cached.group_banners() result = [] + # get banners for all groups for group, banners in group_banners.iteritems(): banner = get_banner_by_params(banners, good_urls, params) - result.append({'id': group, - 'url': banner.url, - 'is_html': banner.html, - 'is_flash': banner.flash, - 'is_img': True, - 'html': banner.text, - 'img': banner.img.url - }) + if banner: + if banner.js or banner.html: + text = banner.text + img = '' + alt = '' + is_img = False + else: + text = '' + img = banner.img.url + alt = banner.alt + is_img = True + result.append({'id': group, + 'url': banner.get_click_link(), + 'is_html': banner.html, + 'is_flash': banner.flash, + 'is_img': is_img, + 'is_js': banner.js, + 'img': img, + 'alt': alt, + 'text': text + }) + # add view log + banner.log(request, 1) return HttpResponse(json.dumps(result, indent=4), content_type='application/json') +def get_top(request): + params = {'theme': request.GET.getlist('theme', []), + 'tag': request.GET.get('tag'), + 'country': request.GET.get('country'), + 'city': request.GET.get('city'), + 'catalog': request.GET.get('catalog')} + tops = Top.cached.all() + events = get_top_events(tops, params) + context = {'objects': events} + return render_to_response('client/includes/exposition/expo_top.html', context, context_instance=RequestContext(request)) \ No newline at end of file diff --git a/exposition/models.py b/exposition/models.py index 950c36f8..81474a3a 100644 --- a/exposition/models.py +++ b/exposition/models.py @@ -157,6 +157,9 @@ class Exposition(TranslatableModel, EventMixin, ExpoMixin): max_open_area = models.PositiveIntegerField(verbose_name='Максимальная цена открытой площади', blank=True, null=True) registration_payment = models.PositiveIntegerField(verbose_name='Регистрационный взнос', blank=True, null=True) + + paid_new = models.ForeignKey('expobanner.Paid', blank=True, null=True, on_delete=models.SET_NULL) + top = models.ForeignKey('expobanner.Top', blank=True, null=True, on_delete=models.SET_NULL) #set manager of this model(fisrt manager is default) objects = ExpoManager() enable = ClientManager() diff --git a/exposition/views.py b/exposition/views.py index 48b55b3b..43f5fb8f 100644 --- a/exposition/views.py +++ b/exposition/views.py @@ -2,14 +2,14 @@ import json import datetime from django.http import HttpResponseRedirect, HttpResponse, HttpResponsePermanentRedirect -from django.contrib import messages from django.contrib.contenttypes.models import ContentType from django.conf import settings from django.views.generic import ListView, DetailView from django.utils.translation import ugettext as _ -from django.shortcuts import get_object_or_404, render_to_response +from django.shortcuts import get_object_or_404 from django.http import Http404 -from django.utils import translation +from django.views.generic.edit import FormMixin +from django.core.mail import EmailMessage #models from accounts.models import User from models import Exposition @@ -23,9 +23,7 @@ from service.order_forms import AdvertiseForm from functions.search_forms import ExpositionSearchForm from functions.custom_views import ExpoSearchView from meta.views import MetadataMixin -from functions.cache_mixin import JitterCacheMixin, CacheMixin - - +from functions.cache_mixin import JitterCacheMixin class ExpositionBy(JitterCacheMixin, MetadataMixin, ListView): @@ -151,37 +149,82 @@ class ExpoDetail(JitterCacheMixin, MetadataMixin, DetailView): model = Exposition slug_field = 'url' template_name = 'client/exposition/exposition_detail.html' + queryset = Exposition.objects.language().select_related('place', 'city', 'country', 'paid_new') def get_context_data(self, **kwargs): context = super(ExpoDetail, self).get_context_data(**kwargs) context['advertising_form'] = AdvertiseForm() + obj = self.object + context['city'] = str(obj.city_id) + context['country'] = str(obj.country_id) + context['themes'] = [str(item.id) for item in obj.theme.all()] + return context + class ExpositionProgramme(MetadataMixin, DetailView): model = Exposition slug_field = 'url' template_name = 'client/exposition/programm.html' + queryset = Exposition.objects.language().select_related('place', 'city', 'country', 'paid_new') + + def get_context_data(self, **kwargs): + context = super(ExpositionProgramme, self).get_context_data(**kwargs) + obj = self.object + context['city'] = str(obj.city_id) + context['country'] = str(obj.country_id) + context['themes'] = [str(item.id) for item in obj.theme.all()] + + return context class ExpositionPrice(MetadataMixin, DetailView): model = Exposition slug_field = 'url' template_name = 'client/exposition/price.html' + queryset = Exposition.objects.language().select_related('place', 'city', 'country', 'paid_new') + def get_context_data(self, **kwargs): + context = super(ExpositionPrice, self).get_context_data(**kwargs) + obj = self.object + context['city'] = str(obj.city_id) + context['country'] = str(obj.country_id) + context['themes'] = [str(item.id) for item in obj.theme.all()] + + return context class ExpositionStatistic(MetadataMixin, DetailView): model = Exposition slug_field = 'url' template_name = 'client/exposition/statistic.html' + queryset = Exposition.objects.language().select_related('place', 'city', 'country', 'paid_new') + + def get_context_data(self, **kwargs): + context = super(ExpositionStatistic, self).get_context_data(**kwargs) + obj = self.object + context['city'] = str(obj.city_id) + context['country'] = str(obj.country_id) + context['themes'] = [str(item.id) for item in obj.theme.all()] + + return context -from django.views.generic.edit import FormMixin, ModelFormMixin class ExpositionThankView(MetadataMixin, DetailView): model = Exposition slug_field = 'url' template_name = 'client/service/thank_u_page.html' + def get_context_data(self, **kwargs): + context = super(ExpositionThankView, self).get_context_data(**kwargs) + obj = self.object + context['city'] = str(obj.city_id) + context['country'] = str(obj.country_id) + context['themes'] = [str(item.id) for item in obj.theme.all()] + + return context + + def visit_redirect(request, slug): obj = get_object_or_404(Exposition, url=slug) redirect = obj.get_permanent_url() + 'price/' @@ -224,7 +267,12 @@ class ExpositionServiceView(MetadataMixin, FormMixin, DetailView): raise Http404 context['form'] = self.get_form(self.form_class) context['service'] = self.service - context['object'] = self.get_object() + obj = self.get_object() + context['object'] = obj + context['city'] = str(obj.city_id) + context['country'] = str(obj.country_id) + context['themes'] = [str(item.id) for item in obj.theme.all()] + return context def form_valid(self, form): @@ -246,8 +294,6 @@ class ExpositionServiceView(MetadataMixin, FormMixin, DetailView): 'city':user.profile.city.name if user.profile.city else '', 'phone': user.profile.phone if user.profile.phone else ''} - - return initial else: return self.initial.copy() @@ -258,12 +304,12 @@ class ExpoList(MetadataMixin, JitterCacheMixin, ListView): model = Exposition paginate_by = settings.CLIENT_PAGINATION template_name = 'client/exposition/exposition_list.html' - search_form = ExpositionSearchForm catalog_url = '/expo/' year = None month = None def get_queryset(self): + MONTHES = settings.MONTHES if self.request.user.is_staff: qs = self.model.objects.upcoming() else: @@ -284,24 +330,21 @@ class ExpoList(MetadataMixin, JitterCacheMixin, ListView): context = super(ExpoList, self).get_context_data(**kwargs) context['month'] = self.month context['catalog_url'] = self.catalog_url - context['search_form'] = self.search_form context['year'] = self.year context['month'] = self.month return context -MONTHES = settings.MONTHES + class ExpoCatalog(MetadataMixin, ListView): model = Exposition paginate_by = settings.CLIENT_PAGINATION template_name = 'client/exposition/catalog.html' - search_form = ExpositionSearchForm filter_object = None year = None month = None country = None city = None - paid = None def get_filtered_qs(self): # diferent for views @@ -350,12 +393,8 @@ class ExpoCatalog(MetadataMixin, ListView): return qs.order_by('data_begin') - 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 context['month'] = self.month @@ -364,6 +403,7 @@ class ExpoCatalog(MetadataMixin, ListView): context['tag_for_filter'] = self.kwargs['tag'] return context + class ExpoCountryCatalog(ExpoCatalog): catalog_url = '/expo/country/' def get_filtered_qs(self): @@ -375,6 +415,12 @@ class ExpoCountryCatalog(ExpoCatalog): qs = self.model.enable.upcoming().filter(country=country) return qs + def get_context_data(self, **kwargs): + context = super(ExpoCountryCatalog, self).get_context_data(**kwargs) + context['country'] = str(self.kwargs['country'].id) + return context + + class ExpoCityCatalog(ExpoCatalog): catalog_url = '/expo/city/' def get_filtered_qs(self): @@ -385,6 +431,10 @@ class ExpoCityCatalog(ExpoCatalog): qs = self.model.enable.upcoming().filter(city=city) self.filter_object = city return qs + def get_context_data(self, **kwargs): + context = super(ExpoCityCatalog, self).get_context_data(**kwargs) + context['city'] = str(self.kwargs['city'].id) + return context class ExpoThemeCatalog(ExpoCatalog): @@ -400,11 +450,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 @@ -427,21 +474,19 @@ class ExpoThemeCatalog(ExpoCatalog): if self.city: context['city'] = self.city context['theme_for_filter'] = self.kwargs['theme'] + context['themes'] = [str(self.kwargs['theme'].id)] return context class ExpoTagCatalog(ExpoCatalog): catalog_url = '/expo/tag/' + def get_filtered_qs(self): #this method used in parent get_queryset 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 @@ -449,18 +494,16 @@ class ExpoTagCatalog(ExpoCatalog): context = super(ExpoTagCatalog, self).get_context_data(**kwargs) tag = self.kwargs['tag'] context['theme_for_filter'] = tag.theme + context['themes'] = [str(tag.theme.id)] + context['tag'] = str(self.kwargs['tag'].id) return context class ExpoVisitors(MetadataMixin, ListView): paginate_by = settings.CLIENT_PAGINATION model = Exposition - #template_name = 'event_visitors.html' - template_name = 'client/exposition/visitors.html' - obj = None - search_form = ExpositionSearchForm def get_queryset(self): slug = self.kwargs.get('slug') @@ -471,20 +514,19 @@ class ExpoVisitors(MetadataMixin, ListView): def get_context_data(self, **kwargs): context = super(ExpoVisitors, self).get_context_data(**kwargs) - context['object'] = self.obj - context['search_form'] = self.search_form + obj = self.obj + context['object'] = obj + context['city'] = str(obj.city_id) + context['country'] = str(obj.country_id) + context['themes'] = [str(item.id) for item in obj.theme.all()] return context class ExpoMembers(MetadataMixin, ListView): paginate_by = settings.CLIENT_PAGINATION model = Exposition - #template_name = 'event_visitors.html' - template_name = 'client/exposition/members.html' - obj = None - search_form = ExpositionSearchForm def get_queryset(self): slug = self.kwargs.get('slug') @@ -495,8 +537,11 @@ class ExpoMembers(MetadataMixin, ListView): def get_context_data(self, **kwargs): context = super(ExpoMembers, self).get_context_data(**kwargs) - context['object'] = self.obj - context['search_form'] = self.search_form + obj = self.obj + context['object'] = obj + context['city'] = str(obj.city_id) + context['country'] = str(obj.country_id) + context['themes'] = [str(item.id) for item in obj.theme.all()] return context @@ -532,11 +577,9 @@ def add_note(request, slug): return HttpResponse(json.dumps(args), content_type='application/json') -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', '') @@ -548,5 +591,4 @@ def send_to_organiser(request, slug): msg.send() redirect_to = '%sservice/thanks/'%exposition.get_permanent_url() - return HttpResponse(json.dumps({'success':True, 'redirect_to': redirect_to}), content_type='application/json') - + return HttpResponse(json.dumps({'success':True, 'redirect_to': redirect_to}), content_type='application/json') \ No newline at end of file diff --git a/functions/model_mixin.py b/functions/model_mixin.py index a96c53cc..5577ac9c 100644 --- a/functions/model_mixin.py +++ b/functions/model_mixin.py @@ -34,6 +34,9 @@ class EventMixin(object): url = '%s%s/'%(self.get_catalog_url(), self.url) return url + def get_paid_catalog_url(self): + return self.paid_new.catalog.get_click_link() + def org_split(self): if self.org: return self.org.split(';') diff --git a/meta/models.py b/meta/models.py index 504207f9..5dd80db9 100644 --- a/meta/models.py +++ b/meta/models.py @@ -129,7 +129,6 @@ class SeoTextManager(TranslationManager): cache_time = 120 def cache_get(self, *args, **kwargs): - # ПЕРЕРОБИТИ url = kwargs.get('url') lang = kwargs.get('lang')[:2] or translation.get_language()[:2] key = 'seo_text_cache' @@ -137,7 +136,7 @@ class SeoTextManager(TranslationManager): if result: return result.get("%s_%s" % (lang, url)) - qs = SeoText.objects.language('all') + qs = list(SeoText.objects.language('all')) value_dict = {obj.language_code+'_'+obj.url: obj for obj in qs} cache.set(key, value_dict, self.cache_time) return value_dict.get("%s_%s" % (lang, url)) diff --git a/place_exposition/urls.py b/place_exposition/urls.py index 6f68b806..6c40ed2b 100644 --- a/place_exposition/urls.py +++ b/place_exposition/urls.py @@ -1,13 +1,11 @@ # -*- coding: utf-8 -*- from django.conf.urls import patterns, include, url -from views import PlaceSearchView, PlaceDetail, PlaceList, PlaceCityCatalog, PlaceCountryCatalog, PlacePhoto +from views import PlaceDetail, PlaceList, PlaceCityCatalog, PlaceCountryCatalog, PlacePhoto urlpatterns = patterns('', - # correct - url(r'search/', PlaceSearchView.as_view()), - # correct + #url(r'country/$', PlaceCountryCatalog.as_view()), url(r'country/(?P.*)/page/(?P\d+)/$', PlaceCountryCatalog.as_view(), {'meta_id':49}), url(r'country/(?P.*)/$', PlaceCountryCatalog.as_view(), {'meta_id':49}), diff --git a/place_exposition/views.py b/place_exposition/views.py index c72b2c38..a40f28d7 100644 --- a/place_exposition/views.py +++ b/place_exposition/views.py @@ -42,19 +42,11 @@ def place(request, url, photo=None): return render_to_response('photoreport.html', args, context_instance=RequestContext(request)) return render_to_response('place.html', args, context_instance=RequestContext(request)) -from functions.custom_views import ExpoSearchView -from functions.search_forms import PlaceSearchForm -class PlaceSearchView(ExpoSearchView): - #paginate_by = 10 - template_name = 'place/search.html' - search_form = PlaceSearchForm - model = PlaceExposition class PlaceDetail(JitterCacheMixin, MetadataMixin, DetailView): cache_range = settings.CACHE_RANGE model = PlaceExposition - search_form = PlaceSearchForm slug_field = 'url' template_name = 'client/place/place_detail.html' @@ -96,7 +88,9 @@ class PlaceDetail(JitterCacheMixin, MetadataMixin, DetailView): def get_context_data(self, **kwargs): context = super(PlaceDetail, self).get_context_data(**kwargs) - context['search_form'] = self.search_form + obj = self.object + context['city'] = str(obj.city_id) + context['country'] = str(obj.country_id) return context class PlacePhoto(ListView): @@ -118,7 +112,10 @@ class PlacePhoto(ListView): def get_context_data(self, **kwargs): context = super(PlacePhoto, self).get_context_data(**kwargs) - context['object'] = self.obj + obj = self.obj + context['object'] = obj + context['city'] = str(obj.city_id) + context['country'] = str(obj.country_id) return context @@ -126,7 +123,6 @@ class PlaceList(JitterCacheMixin, MetadataMixin, ListView): model = PlaceExposition paginate_by = 10 template_name = 'client/place/place_list.html' - search_form = PlaceSearchForm def get_queryset(self): @@ -135,11 +131,6 @@ class PlaceList(JitterCacheMixin, MetadataMixin, ListView): conf_qs = PlaceConference.objects.language().all() return list(qs)+list(conf_qs) - def get_context_data(self, **kwargs): - context = super(PlaceList, self).get_context_data(**kwargs) - context['search_form'] = self.search_form - return context - class PlaceCatalog(JitterCacheMixin, MetadataMixin, ListView): cache_range = settings.CACHE_RANGE @@ -170,6 +161,11 @@ class PlaceCountryCatalog(PlaceCatalog): return list(qs) + list(conf_qs) + def get_context_data(self, **kwargs): + context = super(PlaceCountryCatalog, self).get_context_data(**kwargs) + context['country'] = str(self.kwargs['country'].id) + return context + class PlaceCityCatalog(PlaceCatalog): catalog_url = '/places/' @@ -181,4 +177,9 @@ class PlaceCityCatalog(PlaceCatalog): self.filter_object = city qs = self.model.objects.language().select_related('country', 'city').filter(city=city).order_by('-rating') conf_qs = PlaceConference.objects.language().select_related('country', 'city').filter(city=city) - return list(qs) + list(conf_qs) \ No newline at end of file + return list(qs) + list(conf_qs) + + def get_context_data(self, **kwargs): + context = super(PlaceCityCatalog, self).get_context_data(**kwargs) + context['city'] = str(self.kwargs['city'].id) + return context \ No newline at end of file diff --git a/proj/settings.py b/proj/settings.py index 0c08d6b9..2c8f2afb 100644 --- a/proj/settings.py +++ b/proj/settings.py @@ -351,7 +351,6 @@ INSTALLED_APPS = ( 'pytils', # ?? 'pymorphy', # ?? 'password_reset', # reset password - 'django_crontab', # crons 'social.apps.django_app.default', # social auth 'core', 'wizard' @@ -402,14 +401,21 @@ LOGGING = { } } -CRONJOBS = [ - ('0 */1 * * *', 'django.core.management.call_command', ['update_index conference --age=1']), - ('0 */1 * * *', 'django.core.management.call_command', ['update_index exposition --age=1']), - ('0 */12 * * *', 'django.core.management.call_command', ['update_index place_exposition --age=12']), - ('0 */24 * * *', 'django.core.management.call_command', ['update_index company --age=24']), - ('0 */24 * * *', 'django.core.management.call_command', ['update_index theme --age=24']), - ('0 */24 * * *', 'django.core.management.call_command', ['update_index tag --age=24']), -] +# TODO automate crons +""" +# update search indexes +0 * * * * /usr/bin/python /var/www/proj/manage.py update_index conference --remove --age=6 +0 * * * * /usr/bin/python /var/www/proj/manage.py update_index exposition --remove --age=6 +0 1,13 * * * /usr/bin/python /var/www/proj/manage.py update_index place_exposition --remove --age=24 +0 3 * * * /usr/bin/python /var/www/proj/manage.py update_index company --remove --age=48 +0 4 * * * /usr/bin/python /var/www/proj/manage.py update_index theme --remove --age=48 +0 5 * * * /usr/bin/python /var/www/proj/manage.py update_index tag --remove --age=48 +0 6 * * * /usr/bin/python /var/www/proj/manage.py update_index country --remove --age=48 +0 7 * * * /usr/bin/python /var/www/proj/manage.py update_index city --remove --age=48 +# update banner logs +10 * * * * /usr/bin/python /var/www/proj/manage.py banner_log_update +20 2,14 * * * /usr/bin/python /var/www/proj/manage.py banner_log_check_previous_day +""" THUMBNAIL_DEBUG = DEBUG diff --git a/proj/urls.py b/proj/urls.py index edebf6eb..106e4ead 100644 --- a/proj/urls.py +++ b/proj/urls.py @@ -8,7 +8,7 @@ import debug_toolbar from django.views.generic.base import TemplateView class Robot(TemplateView): - template_name = 'robots.txt' + template_name = 'client/robots.txt' content_type = 'text/plain' class YandexCheck(TemplateView): @@ -73,9 +73,7 @@ urlpatterns = patterns('', url(r'^', include('password_reset.urls')), url(r'^i18n/', include('django.conf.urls.i18n')), url(r'^redirect/', include('banners.urls')), - #url(r'^social/', include('social_auth.urls')), url(r'^', include('settings.old_urls')), - #url(r'^search/', include('haystack.urls')), url(r'^', include('service.urls')), ) diff --git a/templates/admin/expobanner/banner_list.html b/templates/admin/expobanner/banner_list.html new file mode 100644 index 00000000..2b41f228 --- /dev/null +++ b/templates/admin/expobanner/banner_list.html @@ -0,0 +1,36 @@ +{% extends 'base.html' %} + +{% block body %} + +
+
+

{{ verbose }}

+
+
+ {% block list_table %} + + + + + + + + + + + {% for item in object_list %} + + + + + + {% endfor %} + +
Объект  
{{ item }}Изменить Статистика
+ {% endblock %} +
+ {# pagination #} + {% include 'admin/includes/admin_pagination.html' with page_obj=object_list %} +
+ +{% endblock %} \ No newline at end of file diff --git a/templates/admin/expobanner/banner_stat.html b/templates/admin/expobanner/banner_stat.html new file mode 100644 index 00000000..15d51bc2 --- /dev/null +++ b/templates/admin/expobanner/banner_stat.html @@ -0,0 +1,43 @@ +{% extends 'base.html' %} +{% load static %} +{% block scripts %} + +{% endblock %} + + +{% block body %} +
+
+
+

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

+
+
+ + + + + + + + + + + + {% with stats=object.banner_stat.all %} + {% for stat in stats %} + + + + + + + + {% endfor %} + {% endwith %} + +
ДатаПоказыКликиУникальные показыУникальные клики
{{ stat.date|date:"Y-m-d" }}{{ stat.view }}{{ stat.click }}{{ stat.unique_view }}{{ stat.unique_click }}
+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/templates/admin/expobanner/paid_create.html b/templates/admin/expobanner/paid_create.html new file mode 100644 index 00000000..4e3af395 --- /dev/null +++ b/templates/admin/expobanner/paid_create.html @@ -0,0 +1,71 @@ +{% extends 'base.html' %} +{% load static %} + +{% block scripts %} +{# selects #} + + + +{% endblock %} + +{% block body %} +
{% csrf_token %} +
+
+
+

{{ form.verbose }}

+
+
+ {% for field in form %} +
+ +
{{ field }} + {{ field.errors }} +
+
+ {% endfor %} +
+
+
+ +
+ + +
+
+{% endblock %} \ No newline at end of file diff --git a/templates/admin/expobanner/paid_list.html b/templates/admin/expobanner/paid_list.html new file mode 100644 index 00000000..81402128 --- /dev/null +++ b/templates/admin/expobanner/paid_list.html @@ -0,0 +1,38 @@ +{% extends 'base.html' %} + +{% block body %} + +
+
+

Список проплаченых выставок

+
+
+ {% block list_table %} + Добавить выставку + + + + + + + + + + + {% for item in object_list %} + + + + + + + {% endfor %} + +
Выставка   
{{ item }}Изменить {% if item.paid_new.public %}отключить{% else %}включить{% endif %} Статистика
+ {% endblock %} +
+ {# pagination #} + {% include 'admin/includes/admin_pagination.html' with page_obj=object_list %} +
+ +{% endblock %} \ No newline at end of file diff --git a/templates/admin/expobanner/paid_stat.html b/templates/admin/expobanner/paid_stat.html new file mode 100644 index 00000000..b935251c --- /dev/null +++ b/templates/admin/expobanner/paid_stat.html @@ -0,0 +1,43 @@ +{% extends 'base.html' %} +{% load static %} +{% block scripts %} + +{% endblock %} + + +{% block body %} +
+
+
+

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

+
+
+ + + + + + + + + + + + {% with stats=object.paidstat_set.all %} + {% for stat in stats %} + + + + + + + + {% endfor %} + {% endwith %} + +
ДатаОфициальный сайтБилетыУчастиеПереходы с каталога
{{ stat.date|date:"Y-m-d" }}{{ stat.official_clicks }}{{ stat.tickets_clicks }}{{ stat.participation_clicks }}{{ stat.catalog_clicks }}
+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/templates/admin/expobanner/paid_update.html b/templates/admin/expobanner/paid_update.html new file mode 100644 index 00000000..d9b82a11 --- /dev/null +++ b/templates/admin/expobanner/paid_update.html @@ -0,0 +1,32 @@ +{% extends 'base.html' %} +{% load static %} + +{% block scripts %} +{% endblock %} + +{% block body %} +
{% csrf_token %} +
+
+
+

{{ exposition }}

+
+
+ {% for field in form %} +
+ +
{{ field }} + {{ field.errors }} +
+
+ {% endfor %} +
+
+
+ +
+ + +
+
+{% endblock %} \ No newline at end of file diff --git a/templates/admin/expobanner/top_create.html b/templates/admin/expobanner/top_create.html new file mode 100644 index 00000000..4479d055 --- /dev/null +++ b/templates/admin/expobanner/top_create.html @@ -0,0 +1,84 @@ +{% extends 'base.html' %} +{% load static %} + +{% block scripts %} +{# selects #} + + + +{% endblock %} + +{% block body %} +
{% csrf_token %} +
+
+
+

{{ form.verbose }}

+
+
+ {% for field in form %} +
+ +
{{ field }} + {{ field.errors }} +
+
+ {% endfor %} +
+
+
+ +
+ + +
+
+{% endblock %} \ No newline at end of file diff --git a/templates/admin/expobanner/top_list.html b/templates/admin/expobanner/top_list.html new file mode 100644 index 00000000..78642de7 --- /dev/null +++ b/templates/admin/expobanner/top_list.html @@ -0,0 +1,36 @@ +{% extends 'base.html' %} + +{% block body %} + +
+
+

Список выставок в топе

+
+
+ {% block list_table %} + Добавить выставку + + + + + + + + + + {% for item in object_list %} + + + + + + {% endfor %} + +
Выставка  
{{ item }}Изменить Статистика
+ {% endblock %} +
+ {# pagination #} + {% include 'admin/includes/admin_pagination.html' with page_obj=object_list %} +
+ +{% endblock %} \ No newline at end of file diff --git a/templates/admin/includes/admin_nav.html b/templates/admin/includes/admin_nav.html index 9f33389b..59a41ebf 100644 --- a/templates/admin/includes/admin_nav.html +++ b/templates/admin/includes/admin_nav.html @@ -109,6 +109,8 @@ Реклама diff --git a/templates/client/base_catalog.html b/templates/client/base_catalog.html index 64ae5440..6582dc3e 100644 --- a/templates/client/base_catalog.html +++ b/templates/client/base_catalog.html @@ -18,49 +18,33 @@ {% include 'client/includes/online_consult.html' %} - {% block aside_banner1 %} - {% if theme_for_filter.id == 27 or theme_for_filter.id == 9 or theme_for_filter.id == 48 %} -
-
- - - -
-
- {% endif %} - {% endblock %} + {% include 'client/includes/banners/aside_1.html' %} {% include 'client/includes/services.html' %}
{% include 'client/includes/announces.html' %} - {% block asside_banner2 %} - - - {% comment %} -
-
- - - -
-
- {% endcomment %} + {% include 'client/includes/side_confs.html' %} +
+ {% include 'client/includes/banners/aside_2.html' %} - {% endblock %} - {% include 'client/includes/side_confs.html' %}
+
{% include 'client/includes/news.html' with news=news_list %}
+ {% include 'client/includes/banners/aside_3.html' %} + {% block aside_vk %} -
- {% include 'client/includes/social_widjet.html' %} -
+
+ {% include 'client/includes/social_widjet.html' %} +
{% endblock %} + + {% include 'client/includes/banners/aside_4.html' %}
@@ -68,7 +52,7 @@ {% include 'client/includes/catalog_search.html' %} {% endwith %} {% block under_search_baner %} - {% include 'client/includes/banners/under_search.html' %} + {% include 'client/includes/banners/search_under.html' %} {% endblock %} {% block bread_scrumbs %} diff --git a/templates/client/base_page.html b/templates/client/base_page.html deleted file mode 100644 index 42d7fcaa..00000000 --- a/templates/client/base_page.html +++ /dev/null @@ -1,113 +0,0 @@ -{% extends 'blank.html' %} - -{% load static %} -{% load i18n %} -{% load template_filters %} - - -{% block main_part %} -
-
- - -
- {% with search_form=search_form %} - {% include 'client/includes/catalog_search.html' %} - {% endwith %} - {% block under_search_baner %} - {% include 'client/includes/banners/under_search.html' %} - {% endblock %} - - {% block bread_scrumbs %} - - {% endblock %} - -
- {% block page_title %} - - {% endblock %} -
- - {% block page_filter %} - {% endblock %} - - {% block page_body %} -
- {% block content_list %} - {% endblock %} - - {% block paginator %} - - - {% endblock %} - - {% block content_footer_banner %} - {% endblock %} -
- - {% block content_text %} - {% comment %} - {% with filter=filter %} - {% include 'includes/event_list_description.html' %} - {% endwith %} - {% endcomment %} - - {% endblock %} - {% endblock %} -
-
-
-{% endblock %} diff --git a/templates/client/blank.html b/templates/client/blank.html index 5c14ac22..00219448 100644 --- a/templates/client/blank.html +++ b/templates/client/blank.html @@ -77,55 +77,17 @@ This template include basic anf main styles and js files, socialInputMask:['http://','https://'] }); - - - - - + + @@ -178,14 +140,6 @@ This template include basic anf main styles and js files, {% if not request.COOKIES.popover_test1 %} {% if theme_for_filter %} - - {% if theme_for_filter.id == 2 %} - {% if False|random_social %} - {% include 'client/popups/auto_modal.html' %} - {% else %} - {% include 'client/popups/auto_banner.html' %} - {% endif %} - {% endif %} {% if theme_for_filter.id == 54 or theme_for_filter.id == 26 or theme_for_filter.id == 22 or theme_for_filter.id == 15 or theme_for_filter.id == 44 or theme_for_filter.id == 30 %} {% with r=False|random3 %} {% if r == 1 %} @@ -201,18 +155,11 @@ This template include basic anf main styles and js files, {% endif %} {% if theme_for_filter.id == 32 %} - {% with r=False|random5 %} + {% with r=False|random3 %} {% if r == 1 %} - {% include 'client/popups/auto_modal.html' %} - {% endif %} - - {% if r == 2 %} - {% include 'client/popups/auto_banner.html' %} - {% endif %} - {% if r == 3 %} {% include 'client/popups/cemat_modal.html' %} {% endif %} - {% if r == 4 %} + {% if r == 2 %} {% include 'client/popups/cemat_banner1.html' %} {% endif %} {% if r == 0 %} diff --git a/templates/client/conference/catalog.html b/templates/client/conference/catalog.html index bac0aa8b..3295bd59 100644 --- a/templates/client/conference/catalog.html +++ b/templates/client/conference/catalog.html @@ -27,14 +27,14 @@

{% if meta %}{{ meta.h1 }}{% else %}{% trans 'Конференции' %}: {{ filter_object.name }}{% endif %}

- {% include 'includes/exposition/catalog_filter_period.html' %} + {% include 'client/includes/exposition/catalog_filter_period.html' %} {% endblock %} {% block content_list %} - {% include 'includes/conference/conference_list.html' with object_list=object_list %} + {% include 'client/includes/conference/conference_list.html' with object_list=object_list %} {% 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 %} \ No newline at end of file diff --git a/templates/client/conference/conference_list.html b/templates/client/conference/conference_list.html index 9c98e09c..9e3ad406 100644 --- a/templates/client/conference/conference_list.html +++ b/templates/client/conference/conference_list.html @@ -26,17 +26,17 @@

{% if meta %}{{ meta.h1 }}{% else %}{% trans 'Конференции' %}{% endif %}

- {% include 'includes/exposition/catalog_filter_period.html' %} + {% include 'client/includes/exposition/catalog_filter_period.html' %} {% endblock %} {% block content_list %} - {% include 'includes/conference/conference_list.html' with object_list=object_list %} + {% include 'client/includes/conference/conference_list.html' with object_list=object_list %} {% 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 %} \ No newline at end of file diff --git a/templates/client/conference/members.html b/templates/client/conference/members.html index 42359fc6..9c4c02c9 100644 --- a/templates/client/conference/members.html +++ b/templates/client/conference/members.html @@ -17,9 +17,9 @@ {% endblock %} {% block content_list %} - {% include 'includes/exposition/members.html' with object_list=object_list %} + {% include 'client/includes/exposition/members.html' with object_list=object_list %} {% 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 %} \ No newline at end of file diff --git a/templates/client/conference/visitors.html b/templates/client/conference/visitors.html index 1050e608..b6227f5f 100644 --- a/templates/client/conference/visitors.html +++ b/templates/client/conference/visitors.html @@ -18,9 +18,9 @@ {% block content_list %} - {% include 'includes/exposition/visitors.html' with object_list=object_list %} + {% include 'client/includes/exposition/visitors.html' with object_list=object_list %} {% 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 %} \ No newline at end of file diff --git a/templates/client/expobanners/banner_stat.html b/templates/client/expobanners/banner_stat.html new file mode 100644 index 00000000..da8af1c1 --- /dev/null +++ b/templates/client/expobanners/banner_stat.html @@ -0,0 +1,67 @@ +{% extends 'base_catalog.html' %} + +{% block page_title %} +
+

{{ object }}. Статистика

+
+{% endblock %} + +{% block content_list %} +
+ {% if form %} +
{% csrf_token %} + +
+
+

{{ form.stat_pswd.label }}

+
+ {% if form.errors %} + {# если есть ошибка #} +
+ {{ form.stat_pswd }} +
+
+ {{ form.errors.stat_pswd.0 }}{# текст ошибки #} +
+ + {% else %} + {# ошибки нет #} +
+ {{ form.stat_pswd }} +
+ {% endif %} +
+ +
+
+ +
+ + {% else %} + + + + + + + + + + + + {% with stats=object.banner_stat.all %} + {% for stat in stats %} + + + + + + + + {% endfor %} + {% endwith %} + +
ДатаПоказыКликиУникальные показыУникальные клики
{{ stat.date|date:"Y-m-d" }}{{ stat.view }}{{ stat.click }}{{ stat.unique_view }}{{ stat.unique_click }}
+ {% endif %} +
+{% endblock %} \ No newline at end of file diff --git a/templates/client/expobanners/paid_stat.html b/templates/client/expobanners/paid_stat.html new file mode 100644 index 00000000..ba695d71 --- /dev/null +++ b/templates/client/expobanners/paid_stat.html @@ -0,0 +1,67 @@ +{% extends 'base_catalog.html' %} + +{% block page_title %} +
+

{{ object.get_event }}. Статистика

+
+{% endblock %} + +{% block content_list %} +
+ {% if form %} +
{% csrf_token %} + +
+
+

{{ form.stat_pswd.label }}

+
+ {% if form.errors %} + {# если есть ошибка #} +
+ {{ form.stat_pswd }} +
+
+ {{ form.errors.stat_pswd.0 }}{# текст ошибки #} +
+ + {% else %} + {# ошибки нет #} +
+ {{ form.stat_pswd }} +
+ {% endif %} +
+ +
+
+ +
+ + {% else %} + + + + + + + + + + + + {% with stats=object.paidstat_set.all %} + {% for stat in stats %} + + + + + + + + {% endfor %} + {% endwith %} + +
ДатаОфициальный сайтБилетыУчастиеПереходы с каталога
{{ stat.date|date:"Y-m-d" }}{{ stat.official_clicks }}{{ stat.tickets_clicks }}{{ stat.participation_clicks }}{{ stat.catalog_clicks }}
+ {% endif %} +
+{% endblock %} \ No newline at end of file diff --git a/templates/client/exposition/catalog.html b/templates/client/exposition/catalog.html index de61d7eb..cb8941dc 100644 --- a/templates/client/exposition/catalog.html +++ b/templates/client/exposition/catalog.html @@ -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 %} diff --git a/templates/client/exposition/catalog_theme.html b/templates/client/exposition/catalog_theme.html index ec72ee80..8d199340 100644 --- a/templates/client/exposition/catalog_theme.html +++ b/templates/client/exposition/catalog_theme.html @@ -49,18 +49,13 @@ {% block page_title %}
- {#

{% trans 'Выставки' %}: {{ filter_object.name }}

#}

{% if meta %}{{ meta.h1 }}{% else %}{% trans 'Выставки' %}: {{ filter_object.name }}{% endif %}

- {% 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 %} diff --git a/templates/client/exposition/exposition_detail.html b/templates/client/exposition/exposition_detail.html index 8a365de1..3910dd18 100644 --- a/templates/client/exposition/exposition_detail.html +++ b/templates/client/exposition/exposition_detail.html @@ -17,10 +17,10 @@ {% endblock %} {% block content_list %} - {% if not object.paid %} - {% include 'client/includes/exposition/exposition_object.html' with exposition=object %} - {% else %} + {% if object.paid_new_id and object.paid_new.public %} {% include 'client/includes/exposition/expo_paid.html' with exposition=object %} + {% else %} + {% include 'client/includes/exposition/exposition_object.html' with exposition=object %} {% endif %} {% endblock %} @@ -34,21 +34,14 @@ {% with theme_ids=object.theme_ids %} {% if 32 in theme_ids %} - {% with r=False|random5 %} - {% if r == 1 %} - {% include 'client/popups/auto_modal.html' %} - {% endif %} - - {% if r == 2 %} - {% include 'client/popups/auto_banner.html' %} - {% endif %} - {% if r == 3 %} + {% with r=False|random3 %} + {% if r == 0 %} {% include 'client/popups/cemat_modal.html' %} {% endif %} - {% if r == 4 %} + {% if r == 1 %} {% include 'client/popups/cemat_banner1.html' %} {% endif %} - {% if r == 5 %} + {% if r == 2 %} {% include 'client/popups/cemat_banner2.html' %} {% endif %} {% endwith %} @@ -65,14 +58,7 @@ {% endif %} {% endif %} {% endwith %} - {% else %} - {% if 2 in theme_ids %} - {% if False|random_social %} - {% include 'client/popups/auto_modal.html' %} - {% else %} - {% include 'client/popups/auto_banner.html' %} - {% endif %} - {% endif %} + {% endif %} {% endif %} {% endwith %} diff --git a/templates/client/exposition/exposition_price.html b/templates/client/exposition/exposition_price.html deleted file mode 100644 index 3944e886..00000000 --- a/templates/client/exposition/exposition_price.html +++ /dev/null @@ -1,219 +0,0 @@ -{% extends 'base_catalog.html' %} -{% load static %} -{% load i18n %} -{% load template_filters %} - - -{% block content_list %} - -{% block content_text %} -{% block page_body %} -
-
- - -
-
-
- {% if object_list.0.main_title %} - {{ object_list.0.main_title|safe }} - {% else %} - {{ object_list.0.name|safe }} - {% endif %} -
-
- -
- {% with obj=object_list.0 %} - {% include 'client/includes/show_date_block.html' %} - {% endwith %} -
- {% if object_list.0.place %} -
-
-
- {{ object_list.0.place.address.address }} -
- -
- - -
- {% endif %} - - -
-
-
-
{% trans 'Стоимость посещения и участия' %}
-
- -
-
- -
-
{% trans 'Для посещения' %}
- -
{% trans 'Стоимость билетов' %}
- -
- -
    - {% if object_list.0.price_day %} -
  • -
    {{ object_list.0.price_day }} €
    -
    {% trans 'на 1 день' %}
    -
  • - {% endif %} - {% if object_list.0.price_all %} -
  • -
    {{ object_list.0.price_all }} €
    -
    {% trans 'на все дни' %}
    -
  • - {% endif %} - -
- -
{% trans 'Предварительная регистрация' %}
- -
- -
- -
    - {% if object_list.0.price_day_bar %} -
  • -
    {{ object_list.0.price_day_bar }} €
    - -
    на 1 день
    -
  • - {% endif %} - {% if object_list.0.price_all_bar %} -
  • -
    {{ object_list.0.price_all_bar }} €
    -
    {% trans 'на все дни' %}
    -
  • - {% endif %} - -
- -
{% trans 'Регистрация на' %} {% trans 'стойке' %}
- -
- -
- -
-
{% trans 'Выставка открыта для' %}:
-
    - {{ object_list.0.get_audience }} - -
-
-
- -
- -
-
{% trans 'Для участия' %}
- -
{% trans 'Стоимость аренды 1м²' %}
- -
    - {% if object_list.0.max_closed_equipped_area %} -
  • - -
    {{ object_list.0.max_closed_equipped_area }} €
    -
    {% trans 'оборудованная площадь' %}
    -
  • - {% endif %} - - {% if object_list.0.max_closed_area %} -
  • -
    {{ object_list.0.max_closed_area }} €
    -
    {% trans 'необорудованная площадь' %}
    -
  • - {% endif %} - - {% if object_list.0.max_open_area %} -
  • -
    {{ object_list.0.max_open_area }} €
    -
    {% trans 'открытая площадь' %}
    -
  • - {% endif %} - -
- - {% trans 'Заявка на участие' %} - -
- {% if object_list.0.min_stand_size %} -

{% trans 'Минимальный размер стенда' %} — {{ object_list.0.min_stand_size }}м²

- {% endif %} - {% if object_list.0.registration_payment %} -

{% trans 'Регистрационный взнос' %} — {{ object_list.0.registration_payment }}€

- {% endif %} - {% if object_list.0.application_deadline %} -

{% trans 'Крайний срок подачи заявки' %} — {{ object_list.0.application_deadline }}

- {% endif %} - -
- -
-
-
- -
-
- -
- - -
- -
-{% endblock %} -{% endblock %} -{% endblock %} diff --git a/templates/client/includes/article/blog_list.html b/templates/client/includes/article/blog_list.html index 9b937c76..0c70bd85 100644 --- a/templates/client/includes/article/blog_list.html +++ b/templates/client/includes/article/blog_list.html @@ -10,6 +10,13 @@ {{ blog.created|date:"d E Y" }}{% if blog.tag.all.exists %}{% include 'includes/article_tags.html' with obj=blog %}{% endif %} + {% if forloop.counter == 5 or objects|length < 5 %} + {% include 'client/includes/banners/catalog_inner_2.html' %} + {% endif %} + + {% if forloop.counter == 8 %} + {% include 'client/includes/banners/catalog_inner.html' %} + {%endif %} {% endfor %} diff --git a/templates/client/includes/article/news_list.html b/templates/client/includes/article/news_list.html index 46851fa2..b2cc424b 100644 --- a/templates/client/includes/article/news_list.html +++ b/templates/client/includes/article/news_list.html @@ -10,6 +10,13 @@ {{ news.publish_date|date:"d E Y" }}{% with event=news.get_event %}{% if event %}{{ event.name }}{% endif %}{% endwith %} + {% if forloop.counter == 5 or objects|length < 5 %} + {% include 'client/includes/banners/catalog_inner_2.html' %} + {% endif %} + + {% if forloop.counter == 8 %} + {% include 'client/includes/banners/catalog_inner.html' %} + {%endif %} {% endfor %} \ No newline at end of file diff --git a/templates/client/includes/banners/aside_1.html b/templates/client/includes/banners/aside_1.html new file mode 100644 index 00000000..661a1575 --- /dev/null +++ b/templates/client/includes/banners/aside_1.html @@ -0,0 +1,4 @@ +
+
+
+
\ No newline at end of file diff --git a/templates/client/includes/banners/aside_2.html b/templates/client/includes/banners/aside_2.html new file mode 100644 index 00000000..439bfe68 --- /dev/null +++ b/templates/client/includes/banners/aside_2.html @@ -0,0 +1,24 @@ +
+
+ + + +
+
\ No newline at end of file diff --git a/templates/client/includes/banners/aside_3.html b/templates/client/includes/banners/aside_3.html new file mode 100644 index 00000000..cbaccc36 --- /dev/null +++ b/templates/client/includes/banners/aside_3.html @@ -0,0 +1,4 @@ +
+
+
+
\ No newline at end of file diff --git a/templates/client/includes/banners/aside_4.html b/templates/client/includes/banners/aside_4.html new file mode 100644 index 00000000..94d6023e --- /dev/null +++ b/templates/client/includes/banners/aside_4.html @@ -0,0 +1,4 @@ +
+
+
+
\ No newline at end of file diff --git a/templates/client/includes/banners/catalog_inner.html b/templates/client/includes/banners/catalog_inner.html new file mode 100644 index 00000000..ccf1add4 --- /dev/null +++ b/templates/client/includes/banners/catalog_inner.html @@ -0,0 +1,26 @@ +
+ + +
\ No newline at end of file diff --git a/templates/client/includes/banners/catalog_inner_2.html b/templates/client/includes/banners/catalog_inner_2.html new file mode 100644 index 00000000..b8ec5c0f --- /dev/null +++ b/templates/client/includes/banners/catalog_inner_2.html @@ -0,0 +1,2 @@ +
+
\ No newline at end of file diff --git a/templates/client/includes/banners/detail_inner.html b/templates/client/includes/banners/detail_inner.html new file mode 100644 index 00000000..6d0760aa --- /dev/null +++ b/templates/client/includes/banners/detail_inner.html @@ -0,0 +1,25 @@ +
+ +
\ No newline at end of file diff --git a/templates/client/includes/banners/expo_detail.html b/templates/client/includes/banners/expo_detail.html index 29e091ce..405cc617 100644 --- a/templates/client/includes/banners/expo_detail.html +++ b/templates/client/includes/banners/expo_detail.html @@ -1,12 +1,6 @@ {% load static %} {% load template_filters %} -
-{% if object.theme.all.0.id in banner_themes %} - - {% else %} - {% if object.theme.all.1.id in banner_themes %} - - {% endif %} -{% endif %} +
+
\ No newline at end of file diff --git a/templates/client/includes/banners/expo_list_baner.html b/templates/client/includes/banners/expo_list_baner.html deleted file mode 100644 index 792fa3b3..00000000 --- a/templates/client/includes/banners/expo_list_baner.html +++ /dev/null @@ -1,6 +0,0 @@ -{% load static %} -
- {% if theme_for_filter.id in banner_themes or tag_for_filter.id in banner_tags %} - - {% endif %} -
\ No newline at end of file diff --git a/templates/client/includes/banners/header.html b/templates/client/includes/banners/header.html new file mode 100644 index 00000000..89c7f5a2 --- /dev/null +++ b/templates/client/includes/banners/header.html @@ -0,0 +1,12 @@ +
+ + + + + +
\ No newline at end of file diff --git a/templates/client/includes/banners/main_page_inner.html b/templates/client/includes/banners/main_page_inner.html new file mode 100644 index 00000000..0a06e549 --- /dev/null +++ b/templates/client/includes/banners/main_page_inner.html @@ -0,0 +1,2 @@ +
+
\ No newline at end of file diff --git a/templates/client/includes/banners/search_under.html b/templates/client/includes/banners/search_under.html new file mode 100644 index 00000000..12962f81 --- /dev/null +++ b/templates/client/includes/banners/search_under.html @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/templates/client/includes/banners/tops.html b/templates/client/includes/banners/tops.html new file mode 100644 index 00000000..142e63a4 --- /dev/null +++ b/templates/client/includes/banners/tops.html @@ -0,0 +1,13 @@ +
+ +
+ \ No newline at end of file diff --git a/templates/client/includes/banners/under_search.html b/templates/client/includes/banners/under_search.html deleted file mode 100644 index 4d80cf36..00000000 --- a/templates/client/includes/banners/under_search.html +++ /dev/null @@ -1,19 +0,0 @@ -{% load static %} -{% load template_filters %} - -
- {% with r=False|random4 %} - {% ifequal r 0 %} - - {% endifequal %} - {% ifequal r 1 %} - - {% endifequal %} - {% ifequal r 2 %} - - {% endifequal %} - {% ifequal r 3 %} - - {% endifequal %} - {% endwith %} -
\ No newline at end of file diff --git a/templates/client/includes/company/company_list.html b/templates/client/includes/company/company_list.html index 9147a93a..89614691 100644 --- a/templates/client/includes/company/company_list.html +++ b/templates/client/includes/company/company_list.html @@ -60,5 +60,12 @@
+ {% if forloop.counter == 5 or objects|length < 5 %} + {% include 'client/includes/banners/catalog_inner_2.html' %} + {% endif %} + + {% if forloop.counter == 8 %} + {% include 'client/includes/banners/catalog_inner.html' %} + {%endif %} {% endfor %} \ No newline at end of file diff --git a/templates/client/includes/conference/conference_list.html b/templates/client/includes/conference/conference_list.html index 8b69ed42..c1d2487f 100644 --- a/templates/client/includes/conference/conference_list.html +++ b/templates/client/includes/conference/conference_list.html @@ -92,31 +92,12 @@ + {% if forloop.counter == 5 or objects|length < 5 %} + {% include 'client/includes/banners/catalog_inner_2.html' %} + {% endif %} + {% if forloop.counter == 8 %} - - + {% include 'client/includes/banners/catalog_inner.html' %} {%endif %} {% endfor %} diff --git a/templates/client/includes/conference/conference_object.html b/templates/client/includes/conference/conference_object.html index 6fc8b293..02b61d28 100644 --- a/templates/client/includes/conference/conference_object.html +++ b/templates/client/includes/conference/conference_object.html @@ -196,6 +196,12 @@ {% endif %} + +
+
+ {% include 'client/includes/banners/detail_inner.html' %} +
+
diff --git a/templates/client/includes/exposition/expo_paid.html b/templates/client/includes/exposition/expo_paid.html index 4152a5f0..487cca85 100644 --- a/templates/client/includes/exposition/expo_paid.html +++ b/templates/client/includes/exposition/expo_paid.html @@ -29,11 +29,11 @@
{{ exposition.discount_description|safe|linebreaks }}
{% endif %}
- {% if exposition.paid.org_logo %} + {% if exposition.paid_new.logo %} {% endif %} @@ -115,7 +115,7 @@
@@ -125,7 +125,7 @@
  • {% trans 'Зарегистрируйтесь на событие' %}
    {% trans 'Билеты на выставку' %} @@ -133,7 +133,7 @@
  • {% trans 'Забронируйте площадь по лучшей цене' %}
    - Заявка на участие + Заявка на участие
  • diff --git a/templates/client/includes/exposition/expo_list_paid.html b/templates/client/includes/exposition/expo_top.html similarity index 52% rename from templates/client/includes/exposition/expo_list_paid.html rename to templates/client/includes/exposition/expo_top.html index 1b5fdd3e..639c0425 100644 --- a/templates/client/includes/exposition/expo_list_paid.html +++ b/templates/client/includes/exposition/expo_top.html @@ -1,27 +1,32 @@ {% load static %} {% load i18n %} {% load template_filters %} -{% with objects=object_list %} - {% if objects %} + - {% else %} -

    - - {% trans "Выставки по указанным параметрам не найдены. Попробуйте задать менее точный запрос по теме или расширить период времени" %} - -

    - {% endif %} - -{% endwith %} - - - -{% block scripts %} -{% if request.GET.debug == '1' %} - -{% else %} - -{% endif %} -{% endblock %} \ No newline at end of file diff --git a/templates/client/includes/exposition/exposition_list.html b/templates/client/includes/exposition/exposition_list.html index a0e2fcba..6f27536d 100644 --- a/templates/client/includes/exposition/exposition_list.html +++ b/templates/client/includes/exposition/exposition_list.html @@ -3,13 +3,14 @@ {% load template_filters %} {% with objects=object_list %} {% if objects %} -
      + {% include 'client/includes/banners/tops.html' %} +
        {% for obj in objects %}
      • {% endif %}
        - +
        {{ obj.main_title|safe }} @@ -99,35 +100,12 @@
      • - {% if forloop.counter == 5 or objects|length < 5 %} - {% include 'client/includes/banners/expo_list_baner.html' %} - {% endif %} + {% if forloop.counter == 5 or objects|length < 5 %} + {% include 'client/includes/banners/catalog_inner_2.html' %} + {% endif %} {% if forloop.counter == 8 %} - - + {% include 'client/includes/banners/catalog_inner.html' %} {%endif %} {% endfor %} diff --git a/templates/client/includes/exposition/exposition_object.html b/templates/client/includes/exposition/exposition_object.html index 18d2a2c7..dc783ff0 100644 --- a/templates/client/includes/exposition/exposition_object.html +++ b/templates/client/includes/exposition/exposition_object.html @@ -206,32 +206,10 @@ -
        -
        - -
        +
        +
        + {% include 'client/includes/banners/detail_inner.html' %} +

        diff --git a/templates/client/includes/exposition/members.html b/templates/client/includes/exposition/members.html index f9c74e1a..d0bd4e4a 100644 --- a/templates/client/includes/exposition/members.html +++ b/templates/client/includes/exposition/members.html @@ -49,5 +49,12 @@
        + {% if forloop.counter == 5 or objects|length < 5 %} + {% include 'client/includes/banners/catalog_inner_2.html' %} + {% endif %} + + {% if forloop.counter == 8 %} + {% include 'client/includes/banners/catalog_inner.html' %} + {%endif %} {% endfor %}
      \ No newline at end of file diff --git a/templates/client/includes/exposition/price.html b/templates/client/includes/exposition/price.html index b7006c6a..f2470f8b 100644 --- a/templates/client/includes/exposition/price.html +++ b/templates/client/includes/exposition/price.html @@ -151,14 +151,15 @@
      - {% if not exposition.paid %} - {% if exposition.country_id in sng_countries %} - {% else %} - {% trans 'Заказать билет' %} - {% endif %} + {% if exposition.paid_new_id and exposition.paid_new.public %} + {% trans 'Заказать билет' %} + {% else %} + {% if exposition.country_id in sng_countries %} {% else %} - {% trans 'Заказать билет' %} + {% trans 'Заказать билет' %} {% endif %} + {% endif %} +
      {% if exposition.get_audience %}
      @@ -222,10 +223,10 @@ {% else %}

      {% trans 'Цены на площадь доступны по запросу' %}

      {% endif %} - {% if not exposition.paid %} - {% trans 'Заявка на участие' %} + {% if exposition.paid_new_id and exposition.paid_new.public %} + {% trans 'Заявка на участие' %} {% else %} - {% trans 'Заявка на участие' %} + {% trans 'Заявка на участие' %} {% endif %} {% if exposition.min_stand_size or exposition.registration_payment or exposition.application_deadline %} diff --git a/templates/client/includes/exposition/search_result.html b/templates/client/includes/exposition/search_result.html index a387d86c..93bc23af 100644 --- a/templates/client/includes/exposition/search_result.html +++ b/templates/client/includes/exposition/search_result.html @@ -83,6 +83,13 @@
      + {% if forloop.counter == 5 or objects|length < 5 %} + {% include 'client/includes/banners/catalog_inner_2.html' %} + {% endif %} + + {% if forloop.counter == 8 %} + {% include 'client/includes/banners/catalog_inner.html' %} + {%endif %} {% endfor %}
    {% block scripts %} diff --git a/templates/client/includes/exposition/visitors.html b/templates/client/includes/exposition/visitors.html index ecf0a7d2..0958316b 100644 --- a/templates/client/includes/exposition/visitors.html +++ b/templates/client/includes/exposition/visitors.html @@ -51,6 +51,13 @@
  • + {% if forloop.counter == 5 or objects|length < 5 %} + {% include 'client/includes/banners/catalog_inner_2.html' %} + {% endif %} + + {% if forloop.counter == 8 %} + {% include 'client/includes/banners/catalog_inner.html' %} + {%endif %} {% endfor %} diff --git a/templates/client/includes/header.html b/templates/client/includes/header.html index a58bb786..911ea5a4 100644 --- a/templates/client/includes/header.html +++ b/templates/client/includes/header.html @@ -37,7 +37,6 @@ {% endfor %} {% if user.is_staff %}
  • admin
  • -
  • TEST
  • {% endif %} @@ -98,19 +97,7 @@ -
    - {% block header_banner %} - - - - - {% endblock %} -
    + {% include 'client/includes/banners/header.html' %} diff --git a/templates/client/includes/place/place_list.html b/templates/client/includes/place/place_list.html index d5aae814..936a8bf6 100644 --- a/templates/client/includes/place/place_list.html +++ b/templates/client/includes/place/place_list.html @@ -48,6 +48,13 @@ + {% if forloop.counter == 5 or objects|length < 5 %} + {% include 'client/includes/banners/catalog_inner_2.html' %} + {% endif %} + + {% if forloop.counter == 8 %} + {% include 'client/includes/banners/catalog_inner.html' %} + {%endif %} {% endfor %} {% endwith %} \ No newline at end of file diff --git a/templates/client/includes/place/place_object.html b/templates/client/includes/place/place_object.html index 2ca4bd36..9d6b5e10 100644 --- a/templates/client/includes/place/place_object.html +++ b/templates/client/includes/place/place_object.html @@ -287,6 +287,10 @@
    {% include 'client/includes/booking_block.html' with city=place.city place=place %}
    +
    +
    + {% include 'client/includes/banners/detail_inner.html' %} +
    {% if place.get_nearest_places %}
    {% trans 'Ближайшие выставочные центры' %}
    diff --git a/templates/client/includes/seo_text.html b/templates/client/includes/seo_text.html index 833c8d87..9ed0dbf8 100644 --- a/templates/client/includes/seo_text.html +++ b/templates/client/includes/seo_text.html @@ -1,3 +1,3 @@ -
    +

    {{ object.title }}

    {{ object.body|safe }}
    \ No newline at end of file diff --git a/templates/client/index.html b/templates/client/index.html index 96882fb3..a887eb2a 100644 --- a/templates/client/index.html +++ b/templates/client/index.html @@ -55,22 +55,7 @@
    - -
    - {% block menu_banner %} - {% comment %} - {% if False|random3 == 1 %} - - {% else %} - {% if False|random3 == 2 %} - - {% else %} - - {% endif %} - {% endif %} - {% endcomment %} - {% endblock %} -
    + {% include 'client/includes/banners/main_page_inner.html' %} @@ -159,12 +144,6 @@
    {% include 'client/includes/index/blogs.html' with blogs=blogs %} - {% comment %} - -
    -
    -
    - {% endcomment %}
    diff --git a/templates/client/page/page_view.html b/templates/client/page/page_view.html index 55405f98..6b5f9894 100644 --- a/templates/client/page/page_view.html +++ b/templates/client/page/page_view.html @@ -1,4 +1,4 @@ -{% extends 'base_page.html' %} +{% extends 'client/base_catalog.html' %} {% load static %} {% load i18n %} diff --git a/templates/client/place/catalog.html b/templates/client/place/catalog.html index 77939ade..1753dc27 100644 --- a/templates/client/place/catalog.html +++ b/templates/client/place/catalog.html @@ -18,7 +18,7 @@ {% endblock %} {% block content_list %} - {% include 'includes/place/place_list.html' with object_list=object_list %} + {% include 'client/includes/place/place_list.html' with object_list=object_list %} {% endblock %} {% block paginator %} diff --git a/templates/client/robots.txt b/templates/client/robots.txt index f98ce0b4..13f41eb9 100644 --- a/templates/client/robots.txt +++ b/templates/client/robots.txt @@ -97,6 +97,7 @@ Disallow: /*/serv-visa-info.php Disallow: /*/serv-uchastie-info.php Disallow: /*/serv-catalogue-info.php Disallow: /*/serv-catalogs-info.php +Disallow: /expo-b/ Sitemap: http://expomap.ru/sitemap.xml User-agent: Googlebot @@ -198,6 +199,7 @@ Disallow: /*/serv-visa-info.php Disallow: /*/serv-uchastie-info.php Disallow: /*/serv-catalogue-info.php Disallow: /*/serv-catalogs-info.php +Disallow: /expo-b/ Sitemap: http://expomap.ru/sitemap.xml User-agent: Yandex @@ -299,5 +301,6 @@ Disallow: /*/serv-visa-info.php Disallow: /*/serv-uchastie-info.php Disallow: /*/serv-catalogue-info.php Disallow: /*/serv-catalogs-info.php +Disallow: /expo-b/ Host: expomap.ru Sitemap: http://expomap.ru/sitemap.xml \ No newline at end of file diff --git a/templates/client/static_client/js/banners.js b/templates/client/static_client/js/banners.js new file mode 100644 index 00000000..1f6126ca --- /dev/null +++ b/templates/client/static_client/js/banners.js @@ -0,0 +1,87 @@ +(function () { + "use strict"; + + var API_URL_ROOT = "/expo-b/get-banners/"; + + var getUrl = function () { + var data = window.sendData; + + if (data instanceof Object) { + var search = []; + + for (var key in data) { + if (data.hasOwnProperty(key)) { + var value = data[key]; + + if (value instanceof Array) { + for (var i = 0, l = value.length; i < l; i++) { + search.push(encodeURIComponent(key) + "=" + encodeURIComponent(value[i])); + } + } else { + search.push(encodeURIComponent(key) + "=" + encodeURIComponent(value)); + } + } + } + + if (search.length) { + return API_URL_ROOT + "?" + search.join("&"); + } + } + + return API_URL_ROOT; + }; + + var getBanners = function (url, callback) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", url, true); + + xhr.onreadystatechange = function (event) { + if (event.target.readyState === 4) { + if (event.target.status === 200) { + try { + callback(JSON.parse(event.target.responseText)); + } catch (error) { + // do nothing + } + } + } + }; + + xhr.send(); + }; + + var addBanner = function (banner) { + var parent = document.getElementById(banner.id); + + if (parent) { + if (banner.is_img) { + var a = document.createElement("a"); + a.href = banner.url; + + var img = document.createElement("img"); + img.src = banner.img; + img.alt = banner.alt; + + a.appendChild(img); + parent.appendChild(a); + } else if (banner.is_html) { + parent.innerHTML = banner.text; + } + } + + }; + + var insertBanners = function (data) { + if (data instanceof Array) { + for (var i = 0, l = data.length; i < l; i++) { + addBanner(data[i]); + } + } + }; + + var main = function () { + getBanners(getUrl(), insertBanners); + }; + + window.addEventListener("load", main); +})(); diff --git a/templates/registration/acquire_email.html b/templates/registration/acquire_email.html index 17a0c5f0..2aac49a2 100644 --- a/templates/registration/acquire_email.html +++ b/templates/registration/acquire_email.html @@ -1,4 +1,4 @@ -{% extends "client/base_page.html" %} +{% extends "client/base_catalog.html" %} {% block title %}Email confirmation{% endblock %} diff --git a/templates/registration/social_registration_complete.html b/templates/registration/social_registration_complete.html index 755add9b..1f01c1c8 100644 --- a/templates/registration/social_registration_complete.html +++ b/templates/registration/social_registration_complete.html @@ -1,4 +1,4 @@ -{% extends "client/base_page.html" %} +{% extends "client/base_catalog.html" %} {% block title %}Registration complete{% endblock %}