1470: Поп-ап'ы

remotes/origin/stage5
Alexander Burdeiny 10 years ago
parent 5afb515788
commit 8cbe868bcf
  1. 14
      accounts/views.py
  2. 5
      expobanner/utils.py
  3. 9
      static/client/js/rejs/banners.js
  4. 9
      templates/client/blank.html
  5. 14
      templates/client/popups/announce_subscription.html
  6. 3
      theme/search_indexes.py

@ -5,7 +5,7 @@ import datetime
from django.core.urlresolvers import reverse
import calendar as python_calendar
from django.shortcuts import get_object_or_404
from django.http import HttpResponseRedirect, HttpResponse, Http404
from django.http import HttpResponseRedirect, HttpResponse, Http404, HttpResponseBadRequest
from django.contrib.auth.decorators import login_required
from django.utils.translation import ugettext as _, get_language
from django_messages.forms import SendForm
@ -26,7 +26,7 @@ from company.edit_forms import NameForm as CompNameForm, HomeForm as CompHomeFor
FoundationForm as CompFound, SpecializationForm as CompSpec, AddressForm as CompAddress
from meta.views import MetadataMixin
from emencia.django.newsletter.forms import SubscribeSettingsForm
from emencia.django.newsletter.models import Contact
from emencia.django.newsletter.models import Contact, ContactSettings
class SettingsView(TemplateView):
@ -42,7 +42,13 @@ class SettingsView(TemplateView):
try:
contact = user.contact_set.get(email=user.username)
except Contact.DoesNotExist:
contact = None
try:
contact = Contact.objects.get(email=user.username)
contact.user = user
contact.save()
except Contact.DoesNotExist:
contact = None
if not contact:
return SubscribeSettingsForm()
setting = contact.contactsettings
@ -94,7 +100,7 @@ def save_announce_settings(request):
# todo: subscribe settings error handle
#not_valid
return HttpResponseRedirect(reverse('accounts_settings'))
return HttpResponseRedirect(reverse('accounts_settings'))
class CalendarView(TemplateView):

@ -123,13 +123,12 @@ def random_choice_banners(banners):
'''
Include weight of customers model.
'''
print(banners)
choice_from = {}
for i, banner in enumerate(banners):
key = 'customer{pk}'.format(pk=banner.customer_id) if banner.customer_id else i
choice_from.setdefault(key, []).append(banner)
key = random.choice(choice_from.keys())
return random.choice(choice_from.get(key))
pre_choiced = random.choice(choice_from.values())
return random.choice(pre_choiced)
def get_top_events(tops, params, request):

@ -77,6 +77,11 @@
if (parent) {
if (banner.is_popup) {
window.is_popup_banner = true;
// маркируем для попапа подписки о том что есть попап банер
// /templates/client/popups/announce_subscription.html
if (banner.is_img) {
parent.innerHTML =
"<header class=\"clearfix\"><div class=\"pw-title\"></div></header><div class=\"pw-body clearfix\">" +
@ -124,6 +129,10 @@
// top_load - load expo_b_under_search banner or all other
var top_load = top_load || false;
getBanners(getUrl(top_load), insertBanners, top_load);
if (!top_load) {
document.dispatchEvent(window.bannersjsRequestDone);
}
};
// load expo_b_under_search top banner

@ -72,6 +72,15 @@ This template include basic anf main styles and js files,
// console.info("DOMbannersjsElementInserted fired");
window.marker_DOMbannersjsElementInserted = true
});
var bannersjsRequestDone = new Event('bannersjsRequestDone');
window.bannersjsRequestDone = bannersjsRequestDone;
window.marker_bannersjsRequestDone = false;
document.addEventListener("bannersjsRequestDone", function() {
window.marker_bannersjsRequestDone = true;
});
window.is_popup_banner = false;
})();
</script>
<script type="text/javascript" src="{% static 'client/js/rejs/banners.js' %}" async></script>

@ -63,11 +63,13 @@
$(function() {
window.reg_opened = window.reg_opened || false
window.reg_opened = window.reg_opened || false;
function open_func() {
if (window.reg_opened) {
setTimeout(open_func, 1000);
if (window.reg_opened || window.is_popup_banner) {
if (!window.is_popup_banner) {
setTimeout(open_func, 1000);
}
return;
}
setCookie('subscribe_popup', '1', 30);
@ -85,7 +87,11 @@
);
}
setTimeout(open_func, 1000);
if (!window.marker_bannersjsRequestDone) {
document.addEventListener("bannersjsRequestDone", function() {
setTimeout(open_func, 1000);
});
}
});
</script>

@ -94,6 +94,7 @@ class ThemeIndex(indexes.SearchIndex, indexes.Indexable, ExpoSearchMixin):
return Theme
def index_queryset(self, using=None):
translation.activate('ru')
return self.get_model().active.all()
#return self.get_model().objects.filter()
@ -170,4 +171,4 @@ class TagIndex(indexes.SearchIndex, indexes.Indexable, ExpoSearchMixin):
def index_queryset(self, using=None):
#return self.get_model().active.all()
return self.get_model().active.all()
return self.get_model().active.all()

Loading…
Cancel
Save