From 63901db985e6ab3391fdc08a228e0c827c0f7a7e Mon Sep 17 00:00:00 2001 From: Alexander Burdeinyi Date: Thu, 10 Nov 2016 10:29:15 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20requirements.txt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/requirements.txt b/requirements.txt index e32f57f2..3512c3a6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -51,3 +51,10 @@ vobject==0.8.2 wstools==0.4.3 xlrd==0.9.2 xlwt==0.7.5 +rosetta +scipy +numpy +nltk +pandas +django-modeltranslation +suds \ No newline at end of file From df9dd17e85c337bedf33bc06dd9d7bde60e4dfb7 Mon Sep 17 00:00:00 2001 From: Alexander Burdeinyi Date: Sat, 12 Nov 2016 01:16:10 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=20+=20=D0=BF=D1=80=D0=BE=D1=81=D0=B8=D1=82?= =?UTF-8?q?=20=D0=B2=D0=B2=D0=B5=D1=81=D1=82=D0=B8=20email=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B4=D0=BE=D0=BB=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D1=80=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7=20=D1=82?= =?UTF-8?q?=D0=B2=D0=B8=D1=82=D1=82=D0=B5=D1=80=20=20+=20=D0=B4=D0=B5?= =?UTF-8?q?=D0=BD=D1=8C=20=D0=BD=D0=B5=D0=B4=D0=B5=D0=BB=D0=B8=20-=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=83=D0=BC=D0=BE=D0=BB=D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@=20=20+=20=D0=B7=D0=B0=D0=B3=D0=BB=D1=83=D1=88?= =?UTF-8?q?=D0=BA=D0=B0,=20=D0=B4=D0=BE=D0=BB=D0=B6=D0=BD=D0=B0=20=D0=B2?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=B8=20=D0=BD=D0=B0=20=D1=81=D0=B0=D0=B9?= =?UTF-8?q?=D1=82,=20=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B5=D0=BA=20=D0=B2=20?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BE=D0=B9=20=D0=B2=D0=BA=D0=BB=D0=B0=D0=B4?= =?UTF-8?q?=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- accounts/views.py | 3 +- emencia/django/newsletter/models.py | 24 ++++++++++++--- fabfile.py | 10 +++---- functions/pipeline.py | 30 +++++++++++-------- proj/forms.py | 30 +++++++++++++++++++ proj/middleware.py | 4 +-- registration/backends/default/views.py | 2 +- support/dev/settings.py | 1 + support/prod/settings.py | 1 + .../client/accounts/mailing_settings.html | 30 +++++++++++++------ templates/client/accounts/settings.html | 10 +++---- templates/client/includes/header.html | 5 +++- templates/client/popups/unsubscribed.html | 28 +++++++++++++++++ templates/registration/acquire_email.html | 23 +++++++------- 14 files changed, 148 insertions(+), 53 deletions(-) create mode 100644 proj/forms.py create mode 100644 templates/client/popups/unsubscribed.html diff --git a/accounts/views.py b/accounts/views.py index cf2404b6..7ca6dd32 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -158,8 +158,7 @@ class MailingSettingsUnsubscribe(GetUserMixin, RedirectView): if contact is None: return HttpResponseForbidden() if contact.subscriber: - contact.subscriber = False - contact.save() + contact.unsubscribe() return super(MailingSettingsUnsubscribe, self).get(request, *args, **kwargs) diff --git a/emencia/django/newsletter/models.py b/emencia/django/newsletter/models.py index aacae032..1b9b6407 100644 --- a/emencia/django/newsletter/models.py +++ b/emencia/django/newsletter/models.py @@ -161,7 +161,7 @@ class Contact(models.Model): periodic = models.PositiveSmallIntegerField(_(u'Периодичность отправки'), choices=PERIODIC_CHOICES, default=PERIODIC_CHOICES.WEEK) periodic_day = models.PositiveSmallIntegerField(_(u'День отправки'), - choices=PERIODIC_DAY_CHOICES, default=PERIODIC_DAY_CHOICES.MON) + choices=PERIODIC_DAY_CHOICES, default=PERIODIC_DAY_CHOICES.WED) content_news = models.BooleanField(_(u'Новости событий'), blank=True, default=True) content_overview = models.BooleanField(_(u'Обзоры'), blank=True, default=True) content_articles = models.BooleanField(_(u'Статьи из блога по участию в вывставках'), blank=True, default=True) @@ -178,6 +178,20 @@ class Contact(models.Model): objects = ContactManager() + def unsubscribe(self): + self.subscriber = False + self.moscow = False + self.russia = False + self.foreign = False + self.content_news = False + self.content_overview = False + self.content_articles = False + self.tags.clear() + self.themes.clear() + self.f_countries.clear() + self.r_cities.clear() + self.save() + def subscriptions(self): """Return the user subscriptions""" return MailingList.objects.filter(subscribers=self) @@ -265,9 +279,11 @@ class Contact(models.Model): if self.russia: r_cities = set(self.r_cities.values_list('pk', flat=True)) r_date = date + relativedelta.relativedelta(months=1) - russia_sqs = SearchQuerySet().models(Exposition, Conference)\ - .filter(country_id=Exact(settings.RUSSIA_PK), data_begin__gte=r_date)\ - .exclude(city_id=Exact(settings.MOSCOW_PK)) + russia_sqs = SearchQuerySet().models(Exposition, Conference) \ + .filter(country_id=Exact(settings.RUSSIA_PK), data_begin__gte=r_date) \ + # .exclude(city_id=Exact(settings.MOSCOW_PK)) + if r_cities or self.moscow: + russia_sqs = russia_sqs.exclude(city_id=Exact(settings.MOSCOW_PK)) if r_cities: russia_sqs = russia_sqs.filter(city_id__in=r_cities) if th_tg_filter is not None: diff --git a/fabfile.py b/fabfile.py index d5a50944..09c48084 100644 --- a/fabfile.py +++ b/fabfile.py @@ -15,7 +15,7 @@ env.passwords = { } REMOTE_HOME_DIR = '/home/www/expomap/' -LOCAL_HOME_DIR = '/home/alexander/projects/expomap/' +LOCAL_HOME_DIR = '/home/as/PycharmProjects/expomap/' nginx_conf_tech = '/etc/nginx/sites-available/tech_work_hit.expomap.ru' nginx_conf = '/etc/nginx/sites-available/hit.expomap.ru' @@ -86,14 +86,14 @@ def get_configs(): def put_configs(): localdir = join(LOCAL_HOME_DIR, 'support/', env.role) # nginx - put(join(localdir, basename(nginx_conf)), - nginx_conf) + # put(join(localdir, basename(nginx_conf)), + # nginx_conf) # # apache2 # put(join(localdir, basename(apache2_conf)), # apache2_conf) # settings - # put(join(localdir, basename(settings_conf)), - # settings_conf) + put(join(localdir, basename(settings_conf)), + settings_conf) def newsletters_media(): diff --git a/functions/pipeline.py b/functions/pipeline.py index b4a39553..389bcff4 100644 --- a/functions/pipeline.py +++ b/functions/pipeline.py @@ -9,10 +9,11 @@ from django.contrib.sites.models import RequestSite, Site from django.core import signing from django.core.mail import EmailMultiAlternatives from django.core.urlresolvers import reverse -from django.shortcuts import redirect +from django.shortcuts import redirect, render from registration import signals from registration.models import RegistrationProfile from social.pipeline.partial import partial +from proj.forms import EmailForm, AssociateForm def random_pass(): @@ -60,18 +61,21 @@ def create_user(strategy, details, response, uid, user=None, *args, **kwargs): def require_email(strategy, details, user=None, is_new=False, *args, **kwargs): if user and user.email: return - elif is_new and not details.get('email'): - email = strategy.request_data().get('email') - import pdb; pdb.set_trace() - if not email: - strategy.request.session['new_email'] = True - return redirect('acquire_email') - elif email and not User.objects.filter(email=email).exists(): - details['email'] = email - else: - strategy.request.session['new_email'] = True - strategy.request.session['new_email_invalid'] = True - return redirect('acquire_email') + email = details.get('email') + if is_new and not email: + form = EmailForm(strategy.request.POST or None) + if strategy.request.method == "POST" and form.is_valid(): + email = form.cleaned_data.get('email') + if not User.objects.filter(email=email).exists(): + details['email'] = email + return {'email': email} + else: + form = AssociateForm(strategy.request.POST or None) + if form.is_valid() and form.user: + details['email'] = email + return {'email': email, 'user': form.user} + return render(strategy.request, "registration/acquire_email.html", {'form': form}) + return def SendVerificationEmail(strategy, backend, code): diff --git a/proj/forms.py b/proj/forms.py new file mode 100644 index 00000000..455b3676 --- /dev/null +++ b/proj/forms.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +from django import forms +from django.utils.translation import ugettext as _ + +from accounts.models import User + + +class EmailForm(forms.Form): + email = forms.EmailField(label=_(u'Email address')) + + +class AssociateForm(EmailForm): + _errors = { + 'required': _(u'Данный email уже зарегистрирован. Авторизируйтесь чтобы привязать аккаунт.'), + 'invalid': _(u'Неправильный логин или пароль.') + } + password = forms.CharField(label=_(u'Пароль'), widget=forms.PasswordInput(), error_messages=_errors) + + def clean_password(self): + self.user = None + pw = self.cleaned_data.get('password') + if pw: + try: + self.user = User.objects.get(email=self.cleaned_data.get('email')) + except: + self.user = None + if self.user and not self.user.check_password(pw): + self.user = None + raise forms.ValidationError(self.fields['password'].error_messages['invalid']) + return pw \ No newline at end of file diff --git a/proj/middleware.py b/proj/middleware.py index 8ee780d7..0b67c5d1 100644 --- a/proj/middleware.py +++ b/proj/middleware.py @@ -66,8 +66,8 @@ class Referer(object): request.session[attr2] = val if userlog is not None: setattr(userlog, attr2, val) - if not getattr(userlog, attr1): - setattr(userlog, attr1, val) + if not getattr(userlog, attr1): + setattr(userlog, attr1, val) if not request.session.get(attr1): request.session[attr1] = val if userlog is not None: diff --git a/registration/backends/default/views.py b/registration/backends/default/views.py index a18622ed..8655ef46 100644 --- a/registration/backends/default/views.py +++ b/registration/backends/default/views.py @@ -248,7 +248,7 @@ def LoginView(request): return HttpResponse(json.dumps(response), content_type='application/json') else: - HttpResponseRedirect('/') + return HttpResponseRedirect('/') def complete_registration(request): diff --git a/support/dev/settings.py b/support/dev/settings.py index fb0eb7b0..73223e20 100644 --- a/support/dev/settings.py +++ b/support/dev/settings.py @@ -332,6 +332,7 @@ INSTALLED_APPS = ( 'emencia.django.newsletter', 'accounts', 'article', + 'comments', 'city', 'company', 'conference', diff --git a/support/prod/settings.py b/support/prod/settings.py index c1248597..42a83835 100644 --- a/support/prod/settings.py +++ b/support/prod/settings.py @@ -332,6 +332,7 @@ INSTALLED_APPS = ( 'emencia.django.newsletter', 'accounts', 'article', + 'comments', 'city', 'company', 'conference', diff --git a/templates/client/accounts/mailing_settings.html b/templates/client/accounts/mailing_settings.html index c89b3855..beb342f2 100644 --- a/templates/client/accounts/mailing_settings.html +++ b/templates/client/accounts/mailing_settings.html @@ -10,6 +10,7 @@ + @@ -17,23 +18,17 @@

{% trans 'Настройте рассылку от Expomap' %}

- {% if not object.subscriber %} -
- {% trans "Вы не являетесь подписчиком. Чтобы подписаться, выберите интересующие Вас данные." %} -
- {% endif %} -
{% csrf_token %}
-

{% trans 'Какие письма вы хотите получать от нас?' %}

+

{% trans 'Какие события включать в Ваше письмо?' %}

@@ -107,16 +102,19 @@
{{ form.content_news }} {{ form.content_news.label_tag }} +
{% trans "Получайте новости выставок и конференций по выбранным тематикам" %}
{{ form.content_overview }} {{ form.content_overview.label_tag }} +
{% trans "Практические материалы, интервью, кейсы, которые помогут эффективно участвовать в выставках" %}
{{ form.content_articles }} {{ form.content_articles.label_tag }} +
{% trans "Блог о том, как создавать и продвигать крутые event`ы" %}
@@ -179,9 +177,12 @@
{% include 'client/popups/mailing_settings_countries.html' %}
+ +
+ {% include 'client/popups/unsubscribed.html' %} +
- + {% if not object.subscriber %} + +{#
#} +{# {% trans "Вы не являетесь подписчиком. Чтобы подписаться, выберите интересующие Вас данные." %}#} +{#
#} + {% endif %} diff --git a/templates/client/accounts/settings.html b/templates/client/accounts/settings.html index 9aaf7388..14c1d069 100644 --- a/templates/client/accounts/settings.html +++ b/templates/client/accounts/settings.html @@ -112,10 +112,10 @@
--> - #} {% block scripts %} + {% include 'c_admin/includes/admin_pagination.html' with page_obj=page_obj %} {# pagination #} diff --git a/templates/client/base_catalog.html b/templates/client/base_catalog.html index bde2f835..1f632633 100644 --- a/templates/client/base_catalog.html +++ b/templates/client/base_catalog.html @@ -36,7 +36,7 @@ {% include 'client/includes/announces.html' %} - {% include 'client/includes/side_popular.html' %} +{# {% include 'client/includes/side_popular.html' %}#} {% include 'client/includes/side_confs.html' %} diff --git a/templates/client/conference/conference_by.html b/templates/client/conference/conference_by.html index 7c14825d..01d6d7cd 100644 --- a/templates/client/conference/conference_by.html +++ b/templates/client/conference/conference_by.html @@ -23,6 +23,8 @@ {% endblock %} {% block content_list %} + {% include 'client/includes/side_popular.html' %} + {% for obj in object_list %} {% set cur_word = obj.name %} {% if cur_word|slice:":1"|lower != prev_word|slice:":1"|lower and forloop.counter != 1 %} diff --git a/templates/client/exposition/exposition_by.html b/templates/client/exposition/exposition_by.html index 0d479d82..0bef5ffb 100644 --- a/templates/client/exposition/exposition_by.html +++ b/templates/client/exposition/exposition_by.html @@ -23,6 +23,8 @@ {% endblock %} {% block content_list %} + {% include 'client/includes/side_popular.html' %} + {% with objects=object_list %} {% for obj in objects %} {% set cur_word = obj.name %} diff --git a/templates/client/includes/reverseorder_warning.html b/templates/client/includes/reverseorder_warning.html index b8f75ace..2c0da620 100644 --- a/templates/client/includes/reverseorder_warning.html +++ b/templates/client/includes/reverseorder_warning.html @@ -1,5 +1,5 @@ {% load i18n %} -
{% trans "Выставки по указанным параметрам не найдены. Попробуйте упростить параметры или расширить временные рамки. Также Вы можете посмотреть уже прошедшие события и проверить самостоятельно, будут ли они проходить в будущем." %}
+
{% trans "Выставки по указанным параметрам не найдены. Попробуйте упростить параметры или расширить временные рамки. Также, вы можете посмотреть уже прошедшие события и проверить самостоятельно, будут ли они проходить в будущем." %}

{% trans "Прошедшие события" %}

diff --git a/templates/client/includes/side_popular.html b/templates/client/includes/side_popular.html index 5165fc42..a807c224 100644 --- a/templates/client/includes/side_popular.html +++ b/templates/client/includes/side_popular.html @@ -1,14 +1,15 @@ {% load i18n %} {% if side_popular %} -
-
{% trans 'Самые популярные' %}
- #} +{#
#} {% endif %} diff --git a/templates/client/popups/register.html b/templates/client/popups/register.html index 79a43a7d..49d0f590 100644 --- a/templates/client/popups/register.html +++ b/templates/client/popups/register.html @@ -42,9 +42,9 @@
{% trans 'пароль должен иметь не меньше 6 символов' %}
-
-