From 9f37761e64e868fe4acc784241cfbe255c098405 Mon Sep 17 00:00:00 2001 From: gzbender Date: Fri, 25 Jan 2019 18:41:56 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BF=D1=80=D0=BE=D1=81=D0=BB=D0=B5=D0=B4=D0=B8?= =?UTF-8?q?=D1=82=D1=8C,=20=D0=BA=D1=82=D0=BE=20=D0=BF=D0=BE=D1=81=D0=BB?= =?UTF-8?q?=D0=B5=20=D0=BF=D1=80=D0=BE=D1=81=D0=BC=D0=BE=D1=82=D1=80=D0=B0?= =?UTF-8?q?=20=D0=BF=D1=80=D0=BE=D0=B1=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=83?= =?UTF-8?q?=D1=80=D0=BE=D0=BA=D0=B0=20=D0=BF=D1=80=D0=B8=D0=BE=D0=B1=D1=80?= =?UTF-8?q?=D1=91=D0=BB=20=D1=88=D0=BA=D0=BE=D0=BB=D1=83=20(=D0=B2=D0=BE?= =?UTF-8?q?=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D1=82=D1=8C=20=D0=BB=D0=BE=D0=B3=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=B2=D1=81=D0=B5=D1=85=20=D0=B5=D0=BC=D0=B5=D0=B9?= =?UTF-8?q?=D0=BB=D0=BE=D0=B2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/v1/views.py | 7 ++++++- apps/course/templates/course/_items.html | 3 ++- apps/user/admin.py | 7 ++++++- apps/user/migrations/0029_emaillog.py | 22 ++++++++++++++++++++++ apps/user/models.py | 11 +++++++++++ 5 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 apps/user/migrations/0029_emaillog.py diff --git a/api/v1/views.py b/api/v1/views.py index c2b43019..1122282d 100644 --- a/api/v1/views.py +++ b/api/v1/views.py @@ -71,7 +71,7 @@ from apps.payment.models import ( CoursePayment, SchoolPayment, UserBonus, ) from apps.school.models import SchoolSchedule, LiveLesson -from apps.user.models import AuthorRequest +from apps.user.models import AuthorRequest, EmailLog from project.pusher import pusher from project.sengrid import get_sendgrid_client @@ -694,6 +694,11 @@ class CaptureEmail(views.APIView): email = request.data.get('email') sg = get_sendgrid_client() + if not email: + return Response({'error': 'No email'}, status=status.HTTP_400_BAD_REQUEST) + + EmailLog.objects.create(email=email, source=EmailLog.SOURCE_TRIAL_LESSON) + # берем все списки response = sg.client.contactdb.lists.get() if response.status_code != 200: diff --git a/apps/course/templates/course/_items.html b/apps/course/templates/course/_items.html index a5bfa123..acbccf69 100644 --- a/apps/course/templates/course/_items.html +++ b/apps/course/templates/course/_items.html @@ -53,7 +53,8 @@ {% if course.old_price %}
{{ course.old_price|floatformat:"-2" }}₽
{% endif %} -
{{ course.price|floatformat:"-2" }}₽
+
{{ course.price|floatformat:"-2" }}₽
{% endif %} {{ course.title }} diff --git a/apps/user/admin.py b/apps/user/admin.py index df3e01d9..63398df0 100644 --- a/apps/user/admin.py +++ b/apps/user/admin.py @@ -3,7 +3,7 @@ from django.contrib.auth import get_user_model from django.contrib.auth.admin import UserAdmin as BaseUserAdmin from django.utils.translation import gettext_lazy as _ -from .models import AuthorRequest, EmailSubscription, SubscriptionCategory +from .models import AuthorRequest, EmailSubscription, SubscriptionCategory, EmailLog User = get_user_model() @@ -47,3 +47,8 @@ class EmailSubscriptionAdmin(admin.ModelAdmin): 'user', 'email', ) + + +@admin.register(EmailLog) +class EmailLogAdmin(admin.ModelAdmin): + pass diff --git a/apps/user/migrations/0029_emaillog.py b/apps/user/migrations/0029_emaillog.py new file mode 100644 index 00000000..ed154689 --- /dev/null +++ b/apps/user/migrations/0029_emaillog.py @@ -0,0 +1,22 @@ +# Generated by Django 2.0.7 on 2019-01-25 08:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('user', '0028_auto_20181214_0107'), + ] + + operations = [ + migrations.CreateModel( + name='EmailLog', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('email', models.EmailField(max_length=254, verbose_name='email address')), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('source', models.PositiveSmallIntegerField(choices=[(1, 'Пробный урок')])), + ], + ), + ] diff --git a/apps/user/models.py b/apps/user/models.py index 9ab545e7..5a7337bd 100644 --- a/apps/user/models.py +++ b/apps/user/models.py @@ -304,3 +304,14 @@ class Referral(models.Model): from apps.payment.models import UserBonus UserBonus.objects.create(user=self.referral, amount=referral_bonus, payment=self.payment, referral=self) UserBonus.objects.create(user=self.referrer, amount=referrer_bonus, payment=self.payment, referral=self) + + +class EmailLog(models.Model): + SOURCE_TRIAL_LESSON = 1 + SOURCE_CHOICES = ( + (SOURCE_TRIAL_LESSON, 'Пробный урок'), + ) + + email = models.EmailField(_('email address')) + created_at = models.DateTimeField(auto_now_add=True) + source = models.PositiveSmallIntegerField(choices=SOURCE_CHOICES)