Добавить возможность проследить, кто после просмотра пробного урока приобрёл школу (возможно добавить лог для всех емейлов)

remotes/origin/feature/email_log_25-01-19
gzbender 7 years ago
parent 5117f5088b
commit 9f37761e64
  1. 7
      api/v1/views.py
  2. 3
      apps/course/templates/course/_items.html
  3. 7
      apps/user/admin.py
  4. 22
      apps/user/migrations/0029_emaillog.py
  5. 11
      apps/user/models.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:

@ -53,7 +53,8 @@
{% if course.old_price %}
<div class="courses__old-price"><s>{{ course.old_price|floatformat:"-2" }}₽</s></div>
{% endif %}
<div class="courses__price">{{ course.price|floatformat:"-2" }}₽</div>
<div class="courses__price"
{% if course.old_price %}style="color: red;"{% endif %}>{{ course.price|floatformat:"-2" }}₽</div>
{% endif %}
</div>
<a class="courses__title" href="{{ course.url }}">{{ course.title }}</a>

@ -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

@ -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, 'Пробный урок')])),
],
),
]

@ -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)

Loading…
Cancel
Save