Merge branch 'newsletter' of git.general-servers.com:expomap/expomap into newsletter

remotes/origin/1203
Ivan Kovalkovskyi 10 years ago
commit 1b6020132e
  1. 3
      accounts/urls.py
  2. 81
      accounts/views.py
  3. 1
      emencia/django/newsletter/admin_forms.py
  4. 67
      emencia/django/newsletter/forms.py
  5. 4
      emencia/django/newsletter/mailer.py
  6. 7
      emencia/django/newsletter/managers.py
  7. 2
      emencia/django/newsletter/templates/newsletter/newsletter_link_unsubscribe.html
  8. 21
      emencia/django/newsletter/urls/mailing_list.py
  9. 4
      emencia/django/newsletter/urls/tracking.py
  10. 89
      emencia/django/newsletter/views/mailing_list.py
  11. 4
      templates/admin/newsletters/newsletter_list.html
  12. 65
      templates/client/accounts/settings.html
  13. 1
      templates/client/base_catalog.html
  14. 150
      templates/client/newsletters/unsubscribe_form.html
  15. 41
      templates/client/newsletters/unsubscribe_success.html
  16. 71
      templates/client/popups/announce_subscription.html

@ -14,7 +14,7 @@ def test(request):
urlpatterns = patterns('',
url(r'^profile/$', login_required(ProfileView.as_view())),
url(r'^profile/company/$', login_required(ProfileCompanyView.as_view())),
url(r'^profile/settings/$', login_required(SettingsView.as_view())),
url(r'^profile/settings/$', login_required(SettingsView.as_view()), name='accounts_settings'),
url(r'^profile/calendar/remove/$', 'accounts.views.remove_from_calendar'),
url(r'^profile/calendar/export/$', 'core.views.download_workbook'),
url(r'^profile/calendar/$', login_required(CalendarView.as_view())),
@ -35,6 +35,7 @@ urlpatterns = patterns('',
#url(r'^profile/messages/$', login_required(MessagesView.as_view())),
# ajax
url(r'^profile/update/announce-settings/$', 'accounts.views.save_announce_settings', name='account_save_announce_settings'),
url(r'^profile/update/name/$', login_required(NameView.as_view())),
url(r'^profile/update/home/$', login_required(HomeView.as_view())),
url(r'^profile/update/avatar/$', login_required(AvatarView.as_view())),

@ -3,21 +3,22 @@ import dateutil.relativedelta as rdelta
import json, datetime
import calendar as python_calendar
from django.shortcuts import get_object_or_404
from django.http import HttpResponseRedirect, HttpResponse, Http404
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, HttpResponse, Http404, HttpResponseForbidden
from django.contrib.auth.decorators import login_required
from django.utils.translation import ugettext as _, get_language
from django_messages.forms import SendForm
from django.views.generic import TemplateView, FormView
from functions.custom_views import ListView
from sorl.thumbnail import get_thumbnail
from .forms import ChangePasswordForm, EmailAnnouncementForm, FeedFilterForm
from .forms import ChangePasswordForm, FeedFilterForm
from company.forms import CreateCompanyForm
from .models import User
from .edit_forms import AvatarForm, NameForm, HomeForm, WorkForm, AboutCompanyForm, PhoneForm, EmailForm,\
WebPageForm, SocialForm, AboutForm
from emencia.django.newsletter.forms import SubscribeSettingsForm
from emencia.django.newsletter.models import Contact
from meta.views import MetadataMixin
class SettingsView(TemplateView):
@ -27,21 +28,75 @@ class SettingsView(TemplateView):
"""
template_name = 'client/accounts/settings.html'
def get_context_data(self, **kwargs):
context = super(SettingsView, self).get_context_data(**kwargs)
context['change_password_form'] = ChangePasswordForm()
def get_announce_form(self):
user = self.request.user
try:
contact = user.contact_set.get(email=user.username)
except Contact.DoesNotExist:
contact = None
if not contact:
return SubscribeSettingsForm()
setting = contact.contactsettings
initial = {'email': contact.email}
initial['city'] = ','.join(['%s:%s'%(item.id, item.name) for item in set(setting.city.all())])
if setting.exponent_practicum or setting.organiser_practicum or setting.theme.exists():
initial['get_announce'] = True
# north america check
if setting.area.filter(id=SubscribeSettingsForm.NA_ID).exists():
initial['na_expo'] = True
# asia check
if setting.area.filter(id=SubscribeSettingsForm.ASIA_ID).exists():
initial['asia_expo'] = True
# europe check
if setting.area.filter(id=SubscribeSettingsForm.EUROPE_ID).exists():
initial['europe_expo'] = True
form = SubscribeSettingsForm(instance=setting, initial=initial)
return form
def get_context_data(self, **kwargs):
context = super(SettingsView, self).get_context_data(**kwargs)
context['change_password_form'] = ChangePasswordForm()
context['subscribe'] = self.get_announce_form()
if contact:
context['subscribe'] = SubscribeSettingsForm(instance=contact.contactsettings)
else:
context['subscribe'] = SubscribeSettingsForm()
return context
def save_announce_settings(request):
if request.POST:
user = request.user
email = request.POST.get('email') or user.username
# check if setting subscription already exist
try:
contact, created = user.contact_set.get(email=email), False
except Contact.DoesNotExist:
contact, created = Contact.objects.create_contact(email, user, create_setting=True), True
setting = contact.contactsettings
form = SubscribeSettingsForm(request.POST, instance=setting)
if form.is_valid():
setting = form.save(commit=False)
setting.contact = contact
setting.save()
form.save_m2m()
form.save_additional_fields(setting)
else:
errors = form.errors
# todo: subscribe settings error handle
#not_valid
return HttpResponseRedirect(reverse('accounts_settings'))
def dates_range(date1, date2):
delta = date2 - date1
dates = []
@ -54,7 +109,7 @@ class CalendarView(TemplateView):
display template with user calendar(one month)
"""
template_name = 'accounts/calendar.html'
template_name = 'client/accounts/calendar.html'
def get_context_data(self, **kwargs):
"""
@ -155,7 +210,7 @@ class ProfileView(TemplateView):
in template forms handles dynamically by ajax
"""
template_name = 'accounts/new_profile.html'
template_name = 'client/accounts/new_profile.html'
def get_context_data(self, **kwargs):
context = super(ProfileView, self).get_context_data(**kwargs)
@ -217,8 +272,6 @@ class ProfileCompanyView(TemplateView):
from meta.views import MetadataMixin
class UserView(MetadataMixin, TemplateView):
"""
display user information for another users

@ -32,6 +32,7 @@ class ContactSettingsForm(forms.ModelForm):
def save(self, commit=True):
contactsettings = super(ContactSettingsForm, self).save(commit=False)
old_save_m2m = self.save_m2m
if commit:
contactsettings.save()
contact = contactsettings.contact

@ -250,12 +250,15 @@ class SubscribeAssideForm(AbstractSubscribeForm):
class SubscribeSettingsForm(AbstractSubscribeForm):
NA_ID = 12
ASIA_ID = 9
EUROPE_ID = 4
city = forms.CharField(
widget=forms.HiddenInput(attrs={'id': 'id_sub_set_city', 'placeholder': _(u'Город')}),
required=False)
get_announce = forms.BooleanField(required=False, label=_(u'Получать анонсы'))
moscow_expo = forms.BooleanField(required=False, label=_(u'Выставки Москвы'))
saint_expo = forms.BooleanField(required=False, label=_(u'Выставки Санкт-Петербурга'))
na_expo = forms.BooleanField(required=False, label=_(u'Выставки Северной Америки'))
asia_expo = forms.BooleanField(required=False, label=_(u'Выставки Азии'))
europe_expo = forms.BooleanField(required=False, label=_(u'Выставки Европы'))
def __init__(self, *args, **kwargs):
@ -263,17 +266,59 @@ class SubscribeSettingsForm(AbstractSubscribeForm):
lang = translation.get_language()
self.fields['theme'] = forms.MultipleChoiceField(
choices=[(item.pk, get_by_lang(item, 'name', lang)) for item in SearchQuerySet().models(Theme).all()],
required=False,
widget=forms.SelectMultiple(attrs={'placeholder': _(u'Тематики'), 'id': 'id_sub_set_theme'}))
self.fields['country'] = forms.MultipleChoiceField(
choices=[(item.pk, get_by_lang(item, 'name', lang)) for item in SearchQuerySet().models(Country).all()],
required=False,
widget=forms.SelectMultiple(attrs={'placeholder': _(u'Страны'), 'id': 'id_sub_set_country'}))
# do not watch
# cursor = db.cursor()
# sql = u"""
# INSERT IGNORE
# INTO newsletter_contact(first_name, email, activated, tester, creation_date, last_name)
# VALUES %s;""" % u','.join([u"('%s', '%s', '%s', '%s', NOW(), '')" % (row[1], row[0], str(activated).upper(), str(is_tester).upper()) for row in row_list])
# cursor.execute(sql)
def save_additional_fields(self, settings):
get_announce = self.cleaned_data.get('get_announce')
na_expo = self.cleaned_data.get('na_expo')
asia_expo = self.cleaned_data.get('asia_expo')
europe_expo = self.cleaned_data.get('europe_expo')
if not get_announce:
settings.organiser_practicum = False
settings.exponent_practicum = False
settings.save()
settings.theme.clear()
if na_expo:
settings.area.add(Area.objects.get(id=self.NA_ID))
else:
settings.area.remove(Area.objects.get(id=self.NA_ID))
if asia_expo:
settings.area.add(Area.objects.get(id=self.ASIA_ID))
else:
settings.area.remove(Area.objects.get(id=self.ASIA_ID))
if europe_expo:
settings.area.add(Area.objects.get(id=self.EUROPE_ID))
else:
settings.area.remove(Area.objects.get(id=self.EUROPE_ID))
return settings
def save(self, commit=True):
contactsettings = super(SubscribeSettingsForm, self).save(commit=False)
# Prepare a 'save_m2m' method for the form,
old_save_m2m = self.save_m2m
def save_m2m():
old_save_m2m()
contactsettings.theme.clear()
for theme in self.cleaned_data['theme']:
contactsettings.theme.add(theme)
contactsettings.country.clear()
for country in self.cleaned_data['country']:
contactsettings.country.add(country)
for city in self.cleaned_data['city']:
contactsettings.city.add(city)
self.save_m2m = save_m2m
if commit:
contactsettings.save()
self.save_m2m()
return contactsettings
def clean_email(self):
return self.cleaned_data['email']

@ -143,7 +143,7 @@ class NewsLetterSender(object):
message[header] = value
uidb36, token = tokenize(contact)
unsubscribe_link = 'http://' + Site.objects.get_current().domain + reverse('newsletter_mailinglist_unsubscribe', args=[self.newsletter.slug, uidb36, token])
unsubscribe_link = 'http://' + Site.objects.get_current().domain + reverse('newsletter_mailinglist_unsubscribe_hard', args=[self.newsletter.slug, uidb36, token])
message['List-Unsubscribe'] = '<' + unsubscribe_link + '>'
message['List-Id'] = str(self.newsletter.id)
@ -376,6 +376,8 @@ class Mailer(NewsLetterSender):
send = False
else:
announce_context = None
try:
if send:
message = self.build_message(contact, announce_context)

@ -39,11 +39,16 @@ class ContactManager(models.Manager):
contact.save()
return contact
def create_contact(self, email, user=None):
def create_contact(self, email, user=None, create_setting=False):
contact = self.model(user=user, email=email)
if user:
contact.first_name = user.first_name
contact.last_name = user.last_name
contact.save()
contact.send_activation()
if create_setting:
from .models import ContactSettings
sett = ContactSettings(contact=contact, exponent_practicum=False, organiser_practicum=False)
sett.save()
return contact

@ -4,7 +4,7 @@
<tbody>
<tr>
<td style="vertical-align: top; padding: 15px 0 15px; text-align: center;">Чтобы отписаться от этой рассылки, перейдите <a href="{% if uidb36 and token %}http://{{ domain }}{% url 'newsletter_mailinglist_unsubscribe' slug=newsletter.slug uidb36=uidb36 token=token %}{% else %}#{% endif %}">по ссылке</a>.
<td style="vertical-align: top; padding: 15px 0 15px; color: #a2a2a2; text-align: left;">&copy; 2018 &mdash; 2013 <a href="#" style="color: #a2a2a2; text-decoration: none;">Expomap.ru</a></td>
<td style="vertical-align: top; padding: 15px 0 15px; color: #a2a2a2; text-align: left;">&copy; 2008 &mdash; 2015 <a href="#" style="color: #a2a2a2; text-decoration: none;">Expomap.ru</a></td>
</tr>
</tbody>
</table>

@ -1,14 +1,29 @@
"""Urls for the emencia.django.newsletter Mailing List"""
from django.conf.urls.defaults import url
from django.conf.urls.defaults import patterns
from django.conf.urls import url
from django.conf.urls import patterns
from emencia.django.newsletter.views.mailing_list import UnsubscribeView, UnsubscriptionSuccess
from emencia.django.newsletter.forms import MailingListSubscriptionForm
from emencia.django.newsletter.forms import AllMailingListSubscriptionForm
urlpatterns = patterns('emencia.django.newsletter.views.mailing_list',
url(r'^unsubscribe/(?P<slug>[-\w]+)/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
url(r'^unsubscribe/hard/(?P<slug>[-\w]+)/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
'view_mailinglist_unsubscribe',
name='newsletter_mailinglist_unsubscribe_hard'),
url(r'^unsubscribe/(?P<slug>[-\w]+)/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
UnsubscribeView.as_view(),
name='newsletter_mailinglist_unsubscribe'),
url(r'^unsubscribe/handle/$',
'unsubscription_handle',
name='newsletter_mailinglist_unsubscribe_handle'),
url(r'^unsubscribe/success/$',
UnsubscriptionSuccess.as_view(),
name='newsletter_mailinglist_unsubscribe_success'),
url(r'^subscribe/(?P<mailing_list_id>\d+)/',
'view_mailinglist_subscribe',
{'form_class': MailingListSubscriptionForm},

@ -1,6 +1,6 @@
"""Urls for the emencia.django.newsletter Tracking"""
from django.conf.urls.defaults import url
from django.conf.urls.defaults import patterns
from django.conf.urls import url
from django.conf.urls import patterns
urlpatterns = patterns('emencia.django.newsletter.views.tracking',
url(r'^newsletter/(?P<slug>[-\w]+)/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)\.(?P<format>png|gif|jpg)$',

@ -1,16 +1,20 @@
# -*- coding: utf-8 -*-
"""Views for emencia.django.newsletter Mailing List"""
from django.template import RequestContext
from django.shortcuts import get_object_or_404
from django.shortcuts import render_to_response
from django.contrib import messages
from django.http import HttpResponseRedirect
from django.views.generic import DetailView, TemplateView
from django.core.urlresolvers import reverse_lazy
from emencia.django.newsletter.utils.tokens import untokenize
from emencia.django.newsletter.models import Newsletter
from emencia.django.newsletter.models import MailingList
from emencia.django.newsletter.models import ContactMailingStatus
from emencia.django.newsletter.models import Newsletter, MailingList, ContactMailingStatus, Contact, ContactSettings
from emencia.django.newsletter.forms import SubscribeSettingsForm
def view_mailinglist_unsubscribe(request, slug, uidb36, token):
"""Unsubscribe a contact to a mailing list"""
"""hard Unsubscribe a contact to a mailing list"""
newsletter = get_object_or_404(Newsletter, slug=slug)
contact = untokenize(uidb36, token)
@ -21,20 +25,8 @@ def view_mailinglist_unsubscribe(request, slug, uidb36, token):
already_unsubscribed = True
ContactMailingStatus.objects.create(newsletter=newsletter, contact=contact,
status=ContactMailingStatus.UNSUBSCRIPTION)
"""
if request.POST.get('email') and not already_unsubscribed:
newsletter.mailing_list.unsubscribers.add(contact)
newsletter.mailing_list.save()
already_unsubscribed = True
ContactMailingStatus.objects.create(newsletter=newsletter, contact=contact,
status=ContactMailingStatus.UNSUBSCRIPTION)
"""
return render_to_response('newsletter/mailing_list_unsubscribe.html',
{'email': contact.email,
'already_unsubscribed': already_unsubscribed},
context_instance=RequestContext(request))
return HttpResponseRedirect(reverse_lazy('newsletter_mailinglist_unsubscribe_success'))
def view_mailinglist_subscribe(request, form_class, mailing_list_id=None):
"""
@ -59,3 +51,66 @@ def view_mailinglist_subscribe(request, form_class, mailing_list_id=None):
'mailing_list': mailing_list,
'form': form},
context_instance=RequestContext(request))
class UnsubscribeView(DetailView):
model = Newsletter
template_name = 'client/newsletters/unsubscribe_form.html'
def get_object(self, queryset=None):
return get_object_or_404(Newsletter, slug=self.kwargs.get('slug'))
def get_announce_form(self):
contact = untokenize(self.kwargs.get('uidb36'), self.kwargs.get('token'))
self.contact= contact
setting = contact.contactsettings
initial = {'email': contact.email}
initial['city'] = ','.join(['%s:%s'%(item.id, item.name) for item in set(setting.city.all())])
if setting.exponent_practicum or setting.organiser_practicum or setting.theme.exists():
initial['get_announce'] = True
# north america check
if setting.area.filter(id=SubscribeSettingsForm.NA_ID).exists():
initial['na_expo'] = True
# asia check
if setting.area.filter(id=SubscribeSettingsForm.ASIA_ID).exists():
initial['asia_expo'] = True
# europe check
if setting.area.filter(id=SubscribeSettingsForm.EUROPE_ID).exists():
initial['europe_expo'] = True
form = SubscribeSettingsForm(instance=setting, initial=initial)
return form
def get_context_data(self, **kwargs):
context = super(UnsubscribeView, self).get_context_data(**kwargs)
context['subscribe'] = self.get_announce_form()
#
ContactMailingStatus.objects.create(newsletter=self.object, contact=self.contact,
status=ContactMailingStatus.UNSUBSCRIPTION)
return context
def unsubscription_handle(request):
if request.POST:
email = request.POST.get('email')
contact = get_object_or_404(Contact, email=email)
setting = contact.contactsettings
form = SubscribeSettingsForm(request.POST, instance=setting)
if form.is_valid():
setting = form.save(commit=False)
setting.contact = contact
setting.save()
form.save_m2m()
form.save_additional_fields(setting)
if form.cleaned_data.get('get_announce'):
messages.add_message(request, messages.INFO, u'Настройки вашой подписки успешно сохранены')
return HttpResponseRedirect(reverse_lazy('newsletter_mailinglist_unsubscribe_success'))
class UnsubscriptionSuccess(TemplateView):
template_name = 'client/newsletters/unsubscribe_success.html'

@ -18,6 +18,8 @@
<th>Дата отправки</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
@ -29,6 +31,8 @@
<td>{{ item.sending_date|date:"Y-m-d H:i" }}</td>
<td><a href="{% url 'newsletters_newsletters_send_test' item.id %}">тест</a> </td>
<td><a href="{% url 'newsletters_newsletters_update' item.id %}">Изменить</a> </td>
<td><a href="#">История</a> </td>
<td>{% if item.status == item.SENT or item.status == item.CANCELED %}<a href="#">Статистика</a>{% endif %}</td>
</tr>
{% endfor %}
</tbody>

@ -1,4 +1,4 @@
{% extends 'base_catalog.html' %}
{% extends 'client/base_catalog.html' %}
{% load static %}
{% load i18n %}
@ -115,7 +115,7 @@
<div class="set-sect subscribe">
<header>{% trans 'настройка подписки' %}</header>
<div class="set-sect-body">
<form action="#">
<form action="{% url 'account_save_announce_settings' %}" method="post">{% csrf_token %}
<ul class="tabs clearfix">
<li class="active"><a class="icon-big-email" href="#">{% trans 'по e-mail' %}</a></li>
@ -127,7 +127,7 @@
<div class="mf-announces clearfix">
<div class="mf-subj-checks-title">
<label class="check">
<input type="checkbox" class="annoncesFlag" name="annoncesFlag" />
{{ subscribe.get_announce }}
Получать анонсы</label>
</div>
@ -171,9 +171,10 @@
<hr />
<div class="mf-line">
<label class="check">{{ subscribe.moscow_expo }}{{ subscribe.moscow_expo.label }}</label>
<label class="check">{{ subscribe.saint_expo }}{{ subscribe.saint_expo.label }}</label>
<label class="check">{{ subscribe.europe_expo }}{{ subscribe.europe_expo.label }}</label>
<label class="check">{{ subscribe.asia_expo }}{{ subscribe.asia_expo.label }}</label>
<label class="check">{{ subscribe.na_expo }}{{ subscribe.na_expo.label }}</label>
</div>
<hr />
@ -196,4 +197,56 @@
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
$(function(){
$('#id_sub_set_country, #id_sub_set_theme')
.select2({
placeholder: $(this).attr('placeholder'),
width: '100%'
});
$('#id_sub_set_city').select2({
placeholder: $(this).attr('placeholder'),
multiple: true,
width: '100%',
ajax: {
url: "/city/get-city/",
dataType: "json",
quietMillis: 200,
data: function(term, page){
return {term: term,
page: page};
},
results: function (data) {
var results = [];
$.each(data, function(index, item){
results.push({
id: item.id,
text: item.label
});
});
return {results: results};
}
},
initSelection : function(element, callback) {
var data = [];
$(element.val().split(",")).each(function(i) {
var item = this.split(':');
data.push({
id: item[0],
text: item[1]
});
});
callback(data);
}
});
});
</script>
{% endblock %}
{% endblock %}

@ -96,4 +96,5 @@
{% block popup %}
{% include 'client/popups/announces.html' %}
{% include 'client/popups/announce_subscription.html' %}
{% endblock %}

@ -0,0 +1,150 @@
{% extends 'client/base_catalog.html' %}
{% load static %}
{% load i18n %}
{% block page_title %}
<div class="page-title">
<h1>{% trans 'Отписаться' %}</h1>
</div>
{% endblock %}
{% block content_list %}
<div class="set-sect subscribe">
<header>{% trans 'настройка подписки' %}</header>
<div class="set-sect-body">
<form action="{% url 'newsletter_mailinglist_unsubscribe_handle' %}" method="post">{% csrf_token %}
<ul class="tabs clearfix">
<li class="active"><a class="icon-big-email" href="#">{% trans 'по e-mail' %}</a></li>
</ul>
<ul class="tabs-content">
<li class="active">
<div class="mf-announces clearfix">
<div class="mf-subj-checks-title">
<label class="check">
{{ subscribe.get_announce }}
{{ subscribe.get_announce.label }}</label>
</div>
<div class="mf-announces-body">
<div class="mf-line mail" style="display: none;">
<div class="mf-field">{{ subscribe.email }}</div>
<div class="mf-msg"></div>
</div>
<div class="mf-line country">
<div class="mf-field">
{{ subscribe.country }}
</div>
<div class="mf-msg"></div>
</div>
<div class="mf-line city">
<div class="mf-field">
{{ subscribe.city }}
</div>
<div class="mf-msg"></div>
</div>
<div class="mf-line subj">
<div class="mf-field">
{{ subscribe.theme }}
</div>
<div class="mf-msg"></div>
</div>
<div class="mf-line period">
<div class="mf-field">
{{ subscribe.periodic }}
</div>
<div class="mf-msg"></div>
</div>
</div>
</div>
<hr />
<div class="mf-line">
<label class="check">{{ subscribe.europe_expo }}{{ subscribe.europe_expo.label }}</label>
<label class="check">{{ subscribe.asia_expo }}{{ subscribe.asia_expo.label }}</label>
<label class="check">{{ subscribe.na_expo }}{{ subscribe.na_expo.label }}</label>
</div>
<hr />
<div class="mf-line">
<label class="check">{{ subscribe.exponent_practicum }}{% trans '«Практикум экспонента»' %}<i>({% trans 'учимся эффективно участвовать в выставках и грамотно пиарить свою компанию на событиях' %})</i></label>
</div>
<div class="mf-line">
<label class="check">{{ subscribe.organiser_practicum }}{% trans '«Практикум организатора событий»' %} <i>({% trans 'Создаем, наполняем и продвигаем собственные ивэнты' %})</i></label>
</div>
</li>
</ul>
<div class="mf-buttons-line">
<button type="submit" class="icon-save">{% trans 'сохранить' %}</button>
</div>
</form>
</div>
</div>
{% block scripts %}
<script>
$(function(){
$('#id_sub_set_country, #id_sub_set_theme')
.select2({
placeholder: $(this).attr('placeholder'),
width: '100%'
});
$('#id_sub_set_city').select2({
placeholder: $(this).attr('placeholder'),
multiple: true,
width: '100%',
ajax: {
url: "/city/get-city/",
dataType: "json",
quietMillis: 200,
data: function(term, page){
return {term: term,
page: page};
},
results: function (data) {
var results = [];
$.each(data, function(index, item){
results.push({
id: item.id,
text: item.label
});
});
return {results: results};
}
},
initSelection : function(element, callback) {
var data = [];
$(element.val().split(",")).each(function(i) {
var item = this.split(':');
data.push({
id: item[0],
text: item[1]
});
});
callback(data);
}
});
});
</script>
{% endblock %}
{% endblock %}

@ -0,0 +1,41 @@
{% extends 'client/base_catalog.html' %}
{% load static %}
{% load i18n %}
{% block page_body %}
<div class="m-article event-page">
<div class="item-wrap event clearfix" style="padding-left: 10px;">
<div class="i-info">
{% if messages %}
<header>
<div class="i-title">
{% trans 'Параметры вашей подписки изменены.' %}
</div>
</header>
{% else %}
<header>
<div class="i-title">
{% trans 'Вы успешно отписаны' %}
</div>
</header>
<div class="i-address">
<header>
<div class="address">
{% trans 'Мы очень сожалеем, что потеряли такого ценного подписчика как Вы! =( Но будем рады видеть Вас снова!' %}
</div>
</header>
</div>
{% endif %}
</div>
</div>
</div>
{% endblock %}

@ -0,0 +1,71 @@
{% load static %}
{% load i18n %}
{% if not request.COOKIES.subscribe_popup %}
<div id="pw-subscribe-popup" class="popup-window subscribe-modal">
<header class="clearfix">
<div class="step1">
<div class="pw-title ">{% trans 'Анонсы' %} <span class="type-of-event">{% trans 'конференций' %}</span> {% trans 'на ваш email' %}</div>
{# <p class="sub-header">{% trans 'по тематике' %} <a href="#">&laquo;Маркетинг&raquo;</a></p>#}
</div>
</header>
<div class="pw-body clearfix">
<div class="step1" >
<div class="label">
<p>
{% trans 'Более <b>30 000 профессионалов</b> получают наши анонсы событий каждую среду. Присоединяйтесь!' %}
</p>
</div>
<form action="/newsletters/" id="subscribe-form" class="pw-form">
<div style="display: none">
{% for theme in themes %}
<input checked="checked" name="theme" type="checkbox" value="{{ theme }}"/>
{% endfor %}
</div>
<div class="pwf-line">
<div class="pwf-field">
<input type="text" placeholder="Ваше имя" name="first_name" id="id_first_name">
</div>
</div>
<div class="pwf-line">
<div class="pwf-field">
<input type="text" placeholder="Email" name="email" id="id_email">
</div>
</div>
<div class="pwf-buttons-line">
<button type="submit" class="submit">{% trans 'Хочу быть в курсе' %}</button>
<img src="/static/client/img/arrow.png" alt="" class="submit-arrow"/>
</div>
</form>
</div>
</div>
</div>
<script>
function setCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
$(function() {
setCookie('subscribe_popup', '1', 30);
setTimeout(function(){
$.fancybox.open(
[{href: '#pw-subscribe-popup'}],
{}
);
}, 1000);
});
</script>
{% endif %}
Loading…
Cancel
Save