Merge branch 'feature/email_log_25-01-19' into 'master'

Feature/email log 25 01 19

See merge request lilschool/site!253
remotes/origin/hotfix/course_save_error_27-01-19
Danil 7 years ago
commit 3c8bf468d6
  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, CoursePayment, SchoolPayment, UserBonus,
) )
from apps.school.models import SchoolSchedule, LiveLesson 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.pusher import pusher
from project.sengrid import get_sendgrid_client from project.sengrid import get_sendgrid_client
@ -694,6 +694,11 @@ class CaptureEmail(views.APIView):
email = request.data.get('email') email = request.data.get('email')
sg = get_sendgrid_client() 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() response = sg.client.contactdb.lists.get()
if response.status_code != 200: if response.status_code != 200:

@ -53,7 +53,8 @@
{% if course.old_price %} {% if course.old_price %}
<div class="courses__old-price"><s>{{ course.old_price|floatformat:"-2" }}₽</s></div> <div class="courses__old-price"><s>{{ course.old_price|floatformat:"-2" }}₽</s></div>
{% endif %} {% 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 %} {% endif %}
</div> </div>
<a class="courses__title" href="{{ course.url }}">{{ course.title }}</a> <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.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.utils.translation import gettext_lazy as _ 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() User = get_user_model()
@ -47,3 +47,8 @@ class EmailSubscriptionAdmin(admin.ModelAdmin):
'user', 'user',
'email', '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 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.referral, amount=referral_bonus, payment=self.payment, referral=self)
UserBonus.objects.create(user=self.referrer, amount=referrer_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