remotes/origin/1203
Kotiuk Nazarii 11 years ago
parent 50beeb8ded
commit f6e37c8185
  1. 2
      banners/models.py
  2. 1
      proj/urls.py
  3. 4
      settings/templatetags/template_filters.py
  4. 50
      settings/views.py
  5. 97
      templates/client/blank.html
  6. 8
      templates/client/popups/auto_banner.html
  7. 21
      templates/client/popups/auto_modal.html
  8. 8
      templates/client/popups/cemat_banner1.html
  9. 8
      templates/client/popups/cemat_banner2.html
  10. 26
      templates/client/popups/cemat_modal.html
  11. BIN
      templates/client/static_client/img/expo_b/cemat15.gif
  12. BIN
      templates/client/static_client/img/expo_b/cemat15_v2.gif
  13. BIN
      templates/client/static_client/img/expo_b/cemat_modal1.png
  14. BIN
      templates/client/static_client/img/expo_b/cemat_modal2.png
  15. BIN
      templates/client/static_client/img/expo_b/mims.png
  16. BIN
      templates/client/static_client/img/expo_b/mims15.gif

@ -5,6 +5,8 @@ from django.db import models
class Redirect(models.Model):
redirect = models.URLField()
count = models.PositiveIntegerField(default=0)
views = models.PositiveIntegerField(default=0)
def __unicode__(self):
return self.redirect

@ -79,6 +79,7 @@ urlpatterns = patterns('',
# ajax urls
urlpatterns += patterns('',
url(r'^ajax/get_popover/$', 'settings.views.get_popover_info'),
url(r'^registration/reply/$', 'registration.backends.default.views.RegisterReply'),
url(r'^register/', 'registration.backends.default.views.RegisterAjaxView'),
url(r'^register-complete/', 'registration.backends.default.views.complete_registration'),

@ -160,6 +160,10 @@ def random_social(value):
def random3(value):
return random.randrange(0,3)
@register.filter
def random5(value):
return random.randrange(0,5)
@register.filter
def fourth(value):
# return almost in 75% cases True in 25% False

@ -124,4 +124,52 @@ def company_autosearch(request):
result = sorted(result, key=lambda x:x['cat'])
return HttpResponse(json.dumps(result), content_type='application/json')
else:
raise Http404
raise Http404
#------------------------------------------------------
# POPOVERS
#------------------------------------------------------
import random
from django.shortcuts import render
from django.template.loader import render_to_string
def get_popover(request):
response = {'success': True}
theme_id = request.GET.get('theme_id')
themes = {'2': ['client/popups/auto_modal.html', 'client/popups/auto_banner.html'],
'32': ['client/popups/auto_modal.html', 'client/popups/auto_banner.html', 'client/popups/cemat_modal.html', 'client/popups/cemat_banner1.html', 'client/popups/cemat_banner2.html'],
'54': ['client/popups/cemat_modal.html', 'client/popups/cemat_banner1.html', 'client/popups/cemat_banner2.html'],
'26': ['client/popups/cemat_modal.html', 'client/popups/cemat_banner1.html', 'client/popups/cemat_banner2.html'],
'22': ['client/popups/cemat_modal.html', 'client/popups/cemat_banner1.html', 'client/popups/cemat_banner2.html'],
'15': ['client/popups/cemat_modal.html', 'client/popups/cemat_banner1.html', 'client/popups/cemat_banner2.html'],
'44': ['client/popups/cemat_modal.html', 'client/popups/cemat_banner1.html', 'client/popups/cemat_banner2.html'],
'30': ['client/popups/cemat_modal.html', 'client/popups/cemat_banner1.html', 'client/popups/cemat_banner2.html']}
popovers = themes.get(theme_id)
if not popovers:
popovers = ['fail']
response['success'] = False
popover = random.choice(popovers)
html = render_to_string(popover)
response['html'] = html
return HttpResponse(json.dumps(response), content_type='application/json')
from banners.models import Redirect
from django.db.models import F
import datetime
def set_cookie(response, key, value, days_expire = 7):
if days_expire is None:
max_age = 365 * 24 * 60 * 60 #one year
else:
max_age = days_expire * 24 * 60 * 60
expires = datetime.datetime.strftime(datetime.datetime.utcnow() + datetime.timedelta(seconds=max_age), "%a, %d-%b-%Y %H:%M:%S GMT")
response.set_cookie(key, value, max_age=max_age, expires=expires)
def get_popover_info(request):
id = request.GET.get('rdr')
if id:
Redirect.objects.filter(id=id).update(views = F('views') + 1)
response = HttpResponse('success')
set_cookie(response, 'popover_test1', '1')
return response

@ -1,6 +1,8 @@
{% load static %}
{% load i18n %}
{% load template_filters %}
{% get_current_language as LANGUAGE_CODE %}
{% comment %}
This template include basic anf main styles and js files,
block with header and footer, which same in all pages,
@ -147,7 +149,7 @@ This template include basic anf main styles and js files,
{% include 'client/includes/footer.html' %}
{% endblock %}
</div>
<div class="popups-wrap">
<div class="popups-wrap" id="main-popup-wrap">
{% if not user.is_authenticated %}
{% include 'client/popups/login.html' %}
{% include 'client/popups/register.html' %}
@ -157,6 +159,99 @@ This template include basic anf main styles and js files,
{% include 'client/popups/callback.html' %}
{% 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 %}
{% include 'client/popups/cemat_modal.html' %}
{% else %}
{% if r == 2 %}
{% include 'client/popups/cemat_banner1.html' %}
{% else %}
{% include 'client/popups/cemat_banner2.html' %}
{% endif %}
{% endif %}
{% endwith %}
{% endif %}
{% if theme_for_filter.id == 32 %}
{% 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 %}
{% include 'client/popups/cemat_modal.html' %}
{% endif %}
{% if r == 4 %}
{% include 'client/popups/cemat_banner1.html' %}
{% endif %}
{% if r == 5 %}
{% include 'client/popups/cemat_banner2.html' %}
{% endif %}
{% endwith %}
{% endif %}
<script>
$(function() {
if ($('#expo-ad-popup').length > 0){
setTimeout(function(){
$.fancybox.open(
[{href: '#expo-ad-popup'}],
{}
);
var rdr = $('#expo-ad-popup').attr('data-rdr');
sendData = {'rdr': rdr};
console.log(rdr);
$.ajax({
url: '/ajax/get_popover/',
data: sendData,
type: 'GET',
async: true,
success: function(data){
console.log(data);
}
});
}, 5000);
}
});
/*
$(function() {
var theme_id = "{{ theme_for_filter.id }}";
var data = {'theme_id': theme_id};
console.log('--------------------------------')
console.log(data);
console.log('--------------------------------')
$.get('/ajax/get_popover/', data, function(data) {
console.log(data);
$('#main-popup-wrap').append(data['html']);
$.fancybox.open([{'href': 'expo-ad-popup'}])
});
});
*/
</script>
{% endif %}
{% endif %}
{# if user doesnt have url- show form #}
{% if not request.user.is_anonymous %}

@ -0,0 +1,8 @@
<div id="expo-ad-popup" data-rdr="51" class="popup-window" style="width:800px;">
<header class="clearfix">
<div class="pw-title"></div>
</header>
<div class="pw-body clearfix">
<a href="/redirects/redirect/51/"><img src="/static/client/img/expo_b/mims15.gif"/></a>
</div>
</div>

@ -0,0 +1,21 @@
<div id="expo-ad-popup" data-rdr="52" class="popup-window" style="width:500px;">
<header class="clearfix">
<div class="pw-title">Вы планируете посещение MIMS Automechanika Moscow в Экспоцентре?</div>
</header>
<div class="pw-body clearfix">
<form class="pw-form simple-validate" action="/redirect/redirect/52/">
<div class="pwf-line">
С 24 по 27 августа 2015 г. в Экспоцентре будут представлены лучшие предложения производителей и поставщиков автозапчастей, оборудования и товаров для технического обслуживания автомобилей.
</div>
<div class="pwf-line">
<a href="/redirect/redirect/52/">
<img src="/static/client/img/expo_b/mims.png">
</a>
</div>
<button >Узнать подробнее</button>
</form>
</div>
</div>

@ -0,0 +1,8 @@
<div id="expo-ad-popup" data-rdr="49" class="popup-window" style="width:800px;">
<header class="clearfix">
<div class="pw-title"></div>
</header>
<div class="pw-body clearfix">
<a href="/redirects/redirect/49/"><img src="/static/client/img/expo_b/cemat15.gif"/></a>
</div>
</div>

@ -0,0 +1,8 @@
<div id="expo-ad-popup" data-rdr="50" class="popup-window" style="width:800px;">
<header class="clearfix">
<div class="pw-title"></div>
</header>
<div class="pw-body clearfix">
<a href="/redirects/redirect/50/"><img src="/static/client/img/expo_b/cemat15_v2.gif"/></a>
</div>
</div>

@ -0,0 +1,26 @@
{% load static %}
{% load i18n %}
<div id="expo-ad-popup" class="popup-window">
<header class="clearfix">
<div class="pw-title">Ваш логист пойдет на выставку CEMAT?</div>
</header>
<div class="pw-body clearfix">
<form class="pw-form simple-validate" action="/redirect/redirect/53/">
<div class="pwf-line">
С 22 по 25 сентября 2015 г. в Крокус Экспо производители складского оборудования и техники представят свои выгодные предложения.
</div>
<div class="pwf-line">
<a href="/redirect/redirect/52/">
<img src="/static/client/img/expo_b/cemat_modal1.png">
</a>
<a href="/redirect/redirect/52/" style="margin-left: 10px;">
<img src="/static/client/img/expo_b/cemat_modal2.png">
</a>
</div>
<button >Узнать подробнее</button>
</form>
</div>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Loading…
Cancel
Save