diff --git a/apps/auth/views.py b/apps/auth/views.py index d85a75aa..48719b3f 100644 --- a/apps/auth/views.py +++ b/apps/auth/views.py @@ -1,31 +1,30 @@ import os - +import logging from uuid import uuid4 from urllib.parse import urlsplit from facepy import GraphAPI from facepy.exceptions import FacepyError - from django.contrib.auth import get_user_model, logout, login, views from django.contrib.auth.forms import AuthenticationForm from django.core.files.base import ContentFile -from django.http import JsonResponse, Http404 +from django.http import JsonResponse from django.urls import reverse_lazy from django.utils.decorators import method_decorator from django.views.decorators.csrf import csrf_exempt from django.views.generic import FormView, View, TemplateView -from django.views.generic.edit import BaseFormView from django.shortcuts import redirect from django.conf import settings from apps.notification.utils import send_email from apps.config.models import Config from apps.user.models import Referral - from .forms import LearnerRegistrationForm from .tokens import verification_email_token + User = get_user_model() +logger = logging.getLogger(__name__) class LearnerRegistrationView(FormView): @@ -75,7 +74,10 @@ class LearnerRegistrationView(FormView): http_referer = str(http_referer[0]) + '://' + str(http_referer[1]) token = verification_email_token.make_token(user) url = http_referer + str(reverse_lazy('lilcity:verification-email', args=[token, user.id])) - send_email('Вы успешно прошли регистрацию', email, "notification/email/verification_email.html", url=url, config=config) + try: + send_email('Вы успешно прошли регистрацию', email, "notification/email/verification_email.html", url=url, config=config) + except Exception as e: + logger.error(str(e)) if self.request.is_ajax(): return JsonResponse({"success": True}, status=201) diff --git a/apps/content/models.py b/apps/content/models.py index e57746f3..4566864c 100644 --- a/apps/content/models.py +++ b/apps/content/models.py @@ -9,15 +9,19 @@ from django.utils import timezone from django.contrib.postgres.fields import ArrayField from imagekit.models import ImageSpecField from imagekit.processors import ResizeToCover - from polymorphic.models import PolymorphicModel +from project.utils.db import SafeImageField + User = get_user_model() class ImageObject(models.Model): - image = models.ImageField('Изображение', upload_to='content/imageobject') + if settings.DEV_SERVER: + image = SafeImageField('Изображение', upload_to='content/imageobject') + else: + image = models.ImageField('Изображение', upload_to='content/imageobject') image_thumbnail = ImageSpecField(source='image', processors=[ResizeToCover(300, 200, False)], format='JPEG', @@ -158,7 +162,6 @@ class Banner(models.Model): text = models.TextField(blank=True, default='') button_text = models.CharField(max_length=50, blank=True, default='') url = models.URLField(blank=True, default='') - image = models.ImageField() use = models.BooleanField(default=False) color = models.CharField(max_length=7, blank=True, default='') color2 = models.CharField(max_length=7, blank=True, default='') @@ -168,6 +171,10 @@ class Banner(models.Model): update_at = models.DateTimeField(auto_now=True) pages = ArrayField(models.IntegerField(choices=PAGE_CHOICES), default=[], blank=True) main_banner = ArrayField(models.IntegerField(choices=PAGE_CHOICES), default=[], blank=True) + if settings.DEV_SERVER: + image = SafeImageField() + else: + image = models.ImageField() class Meta: verbose_name = 'Банер' diff --git a/apps/course/templates/course/_items.html b/apps/course/templates/course/_items.html index ac011437..f1cd65cf 100644 --- a/apps/course/templates/course/_items.html +++ b/apps/course/templates/course/_items.html @@ -9,9 +9,9 @@ > {% if course.cover and course.cover.image_thumbnail %} - + {% else %} - + {% endif %} {% if course.is_featured %}
diff --git a/apps/course/templates/course/course.html b/apps/course/templates/course/course.html index 04fbe434..db228e96 100644 --- a/apps/course/templates/course/course.html +++ b/apps/course/templates/course/course.html @@ -10,13 +10,13 @@ {% block ogurl %}{{ request.build_absolute_uri }}{% endblock ogurl %} {% block ogimage %} - http://{{request.META.HTTP_HOST}}{% if course.cover and course.cover.image %}{{ course.cover.image.url }}{% else %}{% static 'img/og_courses.jpg' %}{% endif %} + http://{{request.META.HTTP_HOST}}{% if course.cover %}{{ course.cover.image.url }}{% else %}{% static 'img/og_courses.jpg' %}{% endif %} {% endblock ogimage %} {% block ogimage-width %} - {% if course.cover and course.cover.image %}{{ course.cover.image.width }}{% else %}1024{% endif %} + {% if course.cover %}{{ course.cover.image.width|default:'1024' }}{% else %}1024{% endif %} {% endblock ogimage-width %} {% block ogimage-height %} - {% if course.cover and course.cover.image %}{{ course.cover.image.height }}{% else %}512{% endif %} + {% if course.cover %}{{ course.cover.image.height|default:'512' }}{% else %}512{% endif %} {% endblock ogimage-height %} @@ -212,10 +212,8 @@ {% endif %}
- {% if course.cover and course.cover.image %} + {% if course.cover %} - {% else %} - {% endif %} {% if course.is_deferred_start %}
@@ -272,7 +270,7 @@ {% endif %}
diff --git a/apps/school/templates/school/livelesson_detail_unauth.html b/apps/school/templates/school/livelesson_detail_unauth.html index 4493928f..8ca10e74 100644 --- a/apps/school/templates/school/livelesson_detail_unauth.html +++ b/apps/school/templates/school/livelesson_detail_unauth.html @@ -9,10 +9,10 @@ {% if livelesson.cover and livelesson.cover.image %}http://{{request.META.HTTP_HOST}}{{ livelesson.cover.image.url }}{% else %}{{ block.super }}{% endif %} {% endblock ogimage %} {% block ogimage-width %} - {% if livelesson.cover and livelesson.cover.image %}{{ livelesson.cover.image.width }}{% else %}{{ block.super }}{% endif %} + {% if livelesson.cover and livelesson.cover.image %}{{ livelesson.cover.image.width|default:'1024' }}{% else %}{{ block.super }}{% endif %} {% endblock ogimage-width %} {% block ogimage-height %} - {% if livelesson.cover and livelesson.cover.image %}{{ livelesson.cover.image.height }}{% else %}{{ block.super }}{% endif %} + {% if livelesson.cover and livelesson.cover.image %}{{ livelesson.cover.image.height|default:'512' }}{% else %}{{ block.super }}{% endif %} {% endblock ogimage-height %} {% block content %} diff --git a/apps/user/models.py b/apps/user/models.py index 7a774998..2b07118c 100644 --- a/apps/user/models.py +++ b/apps/user/models.py @@ -19,6 +19,7 @@ from django.urls import reverse from api.v1 import serializers from apps.notification.utils import send_email from apps.user.tasks import user_to_mixpanel +from project.utils.db import SafeImageField class UserManager(BaseUserManager): @@ -79,7 +80,10 @@ class User(AbstractUser): is_email_proved = models.BooleanField( 'Верифицирован по email', default=False ) - photo = models.ImageField('Фото', null=True, blank=True, upload_to='users') + if settings.DEV_SERVER: + photo = SafeImageField('Фото', null=True, blank=True, upload_to='users') + else: + photo = models.ImageField('Фото', null=True, blank=True, upload_to='users') show_in_mainpage = models.BooleanField('Показывать на главной странице', default=False) trial_lesson = models.URLField(default='', null=True, blank=True) slug = models.SlugField( diff --git a/docker/.env.review b/docker/.env.review index dc0ff7ab..1c898e6c 100644 --- a/docker/.env.review +++ b/docker/.env.review @@ -1,4 +1,5 @@ DEBUG=True +DEV_SERVER=True ALLOWED_HOSTS=* PORT=8000 CORS_ORIGIN_WHITELIST=lilcity.9ev.ru:8080 @@ -9,7 +10,7 @@ POSTGRES_PASSWORD=GPVs/E/{5&qe DJANGO_SETTINGS_MODULE=project.settings DATABASE_SERVICE_HOST=db SECRET_KEY=jelm*91lj(_-o20+6^a+bgv!4s6e_efry^#+f#=1ak&s1xr-2j -MAILGUN_API_KEY=key-ec6af2d43d031d59bff6b1c8fb9390c +MAILGUN_API_KEY=key-ec6af2d43d031d59bff6b1c8fb9390cb MAILGUN_SENDER_DOMAIN=mail.9ev.ru DEFAULT_FROM_EMAIL=postmaster@mail.9ev.ru TWILIO_ACCOUNT=ACdf4a96b776cc764bc3ec0f0e136ba550 diff --git a/project/settings.py b/project/settings.py index 17b0d706..a56c9463 100644 --- a/project/settings.py +++ b/project/settings.py @@ -30,6 +30,7 @@ SECRET_KEY = os.getenv( # SECURITY WARNING: don't run with debug turned on in production! DEBUG = os.getenv('DEBUG', False) +DEV_SERVER = os.getenv('DEV_SERVER', False) ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', '*').split(',') MAIN_HOST = os.getenv('MAIN_HOST', 'lil.school') @@ -372,14 +373,6 @@ else: # Mixpanel settings MIX_TOKEN = os.getenv('MIXPANEL_TOKEN', '79bd6bfd98667ed977737e6810b8abcd') -# CORS settings - -if DEBUG: - CORS_ORIGIN_ALLOW_ALL = True -else: - CORS_ORIGIN_WHITELIST = os.getenv( - 'CORS_ORIGIN_WHITELIST', 'lilcity.9ev.ru:8080').split(',') - # Swagger doc settings SWAGGER_SETTINGS = { @@ -410,3 +403,14 @@ try: from .local_settings import * except ImportError: pass + +# CORS settings + +if DEBUG or DEV_SERVER: + CORS_ORIGIN_ALLOW_ALL = True +else: + CORS_ORIGIN_WHITELIST = os.getenv( + 'CORS_ORIGIN_WHITELIST', 'lilcity.9ev.ru:8080').split(',') + +if DEV_SERVER: + IMAGEKIT_DEFAULT_CACHEFILE_STRATEGY = 'imagekit.cachefiles.strategies.Optimistic' diff --git a/project/templates/blocks/partners.html b/project/templates/blocks/partners.html index 16b3e26d..d26c0602 100644 --- a/project/templates/blocks/partners.html +++ b/project/templates/blocks/partners.html @@ -37,6 +37,11 @@
+
+ + + +
diff --git a/project/templates/blocks/students.html b/project/templates/blocks/students.html index ec66bf2c..60d95dd2 100644 --- a/project/templates/blocks/students.html +++ b/project/templates/blocks/students.html @@ -18,12 +18,12 @@
- Лил Скул для меня это место, где Солнце может быть синего цвета. + Лил Скул для меня это место,
где Солнце может быть синего цвета.
Злата Пыльцина, 7 лет. Город Волгоград.
- Видео отзыв
diff --git a/project/templates/lilcity/home.html b/project/templates/lilcity/home.html index f9173e21..95a74083 100644 --- a/project/templates/lilcity/home.html +++ b/project/templates/lilcity/home.html @@ -10,6 +10,14 @@ {% endif %} {% endblock ogdescription %} +{% block head %} + +{% endblock head %} + {% block title %}Lil School{% endblock title %} {% block body_attr %}class="main-page"{% endblock body_attr %} {% block content %} diff --git a/project/utils/db.py b/project/utils/db.py index 4a31f79a..eb772fb8 100644 --- a/project/utils/db.py +++ b/project/utils/db.py @@ -1,5 +1,28 @@ from django.db.models.base import ModelBase from django.db import connection +from django.db import models +from django.db.models.fields.files import ImageFieldFile + + +class SafeImageFieldFile(ImageFieldFile): + + @property + def width(self): + try: + return self.width + except: + return None + + @property + def height(self): + try: + return self.height + except: + return None + + +class SafeImageField(models.ImageField): + attr_class = SafeImageFieldFile class ModelFieldsNames(object): diff --git a/web/src/img/girl-brushes.png b/web/src/img/girl-brushes.png new file mode 100644 index 00000000..5517a769 Binary files /dev/null and b/web/src/img/girl-brushes.png differ diff --git a/web/src/img/uni_mitsubishi.png b/web/src/img/uni_mitsubishi.png new file mode 100644 index 00000000..be1663fd Binary files /dev/null and b/web/src/img/uni_mitsubishi.png differ diff --git a/web/src/sass/_common.sass b/web/src/sass/_common.sass index 63c0801b..e1e05105 100755 --- a/web/src/sass/_common.sass +++ b/web/src/sass/_common.sass @@ -1158,12 +1158,14 @@ a[name] padding-bottom: 0 &_students &__column_img - background-image: url(/static/img/zlata.png) + background-image: url(/static/img/girl-brushes.png) height: 400px background-position: bottom center + z-index: -1 +m - height: auto + flex: 195px + background-size: 225px &_students &__center:nth-child(1) +m @@ -1174,11 +1176,17 @@ a[name] +m margin-top: 0 + flex-direction: column-reverse &_students &__center:nth-child(2) &__column_text +m padding: 0 0 0 10px + &_students .btn + width: auto + +m + width: 225px + &_course .go flex-wrap: wrap @@ -1190,6 +1198,7 @@ a[name] +m font-size: 14px + padding: 55px 35px 100px 150px &:before background-image: url(/static/img/bubble-icon.svg?196dc3af196a) @@ -1199,16 +1208,18 @@ a[name] width: 100% height: 80% content: ' ' - left: -2% + left: 0 top: -3% z-index: -1 +m - width: 90%; - left: 15% + width: 73% + left: 20% top: 10% & &-text margin-bottom: 20px + +m + margin-bottom: 15px & &-name text-decoration: underline