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)