diff --git a/api/v1/serializers/__init__.py b/api/v1/serializers/__init__.py index cf7d67f7..48cfa911 100644 --- a/api/v1/serializers/__init__.py +++ b/api/v1/serializers/__init__.py @@ -3,13 +3,13 @@ import base64 import six import uuid +from django.conf import settings from django.core.files.base import ContentFile from rest_framework import serializers - class Base64ImageField(serializers.ImageField): - + use_url = False def to_internal_value(self, data): if isinstance(data, six.string_types): if 'data:' in data and ';base64,' in data: @@ -30,3 +30,8 @@ class Base64ImageField(serializers.ImageField): extension = imghdr.what(file_name, decoded_file) extension = "jpg" if extension == "jpeg" else extension return extension + + def to_representation(self, value): + file = "%s%s" % (settings.MEDIA_URL, super().to_representation(value),) + + return file diff --git a/api/v1/serializers/course.py b/api/v1/serializers/course.py index 7f45c7a2..55272f85 100644 --- a/api/v1/serializers/course.py +++ b/api/v1/serializers/course.py @@ -203,6 +203,7 @@ class LessonCreateSerializer(serializers.ModelSerializer): t.title = cdata['title'] t.lesson = lesson t.txt = cdata['txt'] + t.uuid = cdata['uuid'] t.save() else: t = Text.objects.create( @@ -210,6 +211,7 @@ class LessonCreateSerializer(serializers.ModelSerializer): title=cdata['title'], lesson=lesson, txt=cdata['txt'], + uuid=cdata['uuid'], ) elif ctype == 'image': if 'id' in cdata and cdata['id']: @@ -218,6 +220,7 @@ class LessonCreateSerializer(serializers.ModelSerializer): image.title = cdata['title'] image.lesson = lesson image.img = ImageObject.objects.get(id=cdata['img']) + image.uuid = cdata['uuid'] image.save() else: image = Image.objects.create( @@ -225,6 +228,7 @@ class LessonCreateSerializer(serializers.ModelSerializer): title=cdata['title'], lesson=lesson, img=ImageObject.objects.get(id=cdata['img']), + uuid=cdata['uuid'], ) elif ctype == 'image-text': if 'id' in cdata and cdata['id']: @@ -234,6 +238,7 @@ class LessonCreateSerializer(serializers.ModelSerializer): it.lesson = lesson it.img = ImageObject.objects.get(id=cdata['img']) it.txt = cdata['txt'] + it.uuid = cdata['uuid'] it.save() else: it = ImageText.objects.create( @@ -242,6 +247,7 @@ class LessonCreateSerializer(serializers.ModelSerializer): lesson=lesson, img=ImageObject.objects.get(id=cdata['img']), txt=cdata['txt'], + uuid=cdata['uuid'], ) elif ctype == 'video': if 'id' in cdata and cdata['id']: @@ -250,6 +256,7 @@ class LessonCreateSerializer(serializers.ModelSerializer): v.title = cdata['title'] v.lesson = lesson v.url = cdata['url'] + v.uuid = cdata['uuid'] v.save() else: v = Video.objects.create( @@ -257,6 +264,7 @@ class LessonCreateSerializer(serializers.ModelSerializer): title=cdata['title'], lesson=lesson, url=cdata['url'], + uuid=cdata['uuid'], ) elif ctype == 'images': if 'id' in cdata and cdata['id']: @@ -264,6 +272,7 @@ class LessonCreateSerializer(serializers.ModelSerializer): g.position = cdata['position'] g.title = cdata['title'] g.lesson = lesson + g.uuid = cdata['uuid'] g.save() if 'images' in cdata: for image in cdata['images']: @@ -276,6 +285,7 @@ class LessonCreateSerializer(serializers.ModelSerializer): lesson=lesson, position=cdata['position'], title=cdata['title'], + uuid=cdata['uuid'], ) if 'images' in cdata: for image in cdata['images']: diff --git a/api/v1/serializers/mixins.py b/api/v1/serializers/mixins.py index 73854170..b98f98f4 100644 --- a/api/v1/serializers/mixins.py +++ b/api/v1/serializers/mixins.py @@ -22,6 +22,7 @@ class DispatchContentMixin(object): t.title = cdata['title'] t.course = course t.txt = cdata['txt'] + t.uuid = cdata['uuid'] t.save() else: t = Text.objects.create( @@ -30,6 +31,7 @@ class DispatchContentMixin(object): title=cdata['title'], course=course, txt=cdata['txt'], + uuid=cdata['uuid'], ) elif ctype == 'image': if 'id' in cdata and cdata['id']: @@ -38,7 +40,15 @@ class DispatchContentMixin(object): image.position = cdata['position'] image.title = cdata['title'] image.course = course - image.img = ImageObject.objects.get(id=cdata['img']) + + try: + image_object = ImageObject.objects.get(id=cdata['img']) + image.img = image_object + image.save() + except ImageObject.DoesNotExist: + pass + + image.uuid = cdata['uuid'] image.save() else: image = Image.objects.create( @@ -46,8 +56,15 @@ class DispatchContentMixin(object): position=cdata['position'], title=cdata['title'], course=course, - img=ImageObject.objects.get(id=cdata['img']), + uuid=cdata['uuid'], ) + try: + image_object = ImageObject.objects.get(id=cdata['img']) + image.img = image_object + image.save() + except ImageObject.DoesNotExist: + pass + elif ctype == 'image-text': if 'id' in cdata and cdata['id']: it = ImageText.objects.get(id=cdata['id']) @@ -55,8 +72,16 @@ class DispatchContentMixin(object): it.position = cdata['position'] it.title = cdata['title'] it.course = course - it.img = ImageObject.objects.get(id=cdata['img']) + + try: + image_object = ImageObject.objects.get(id=cdata['img']) + it.img = image_object + it.save() + except ImageObject.DoesNotExist: + pass + it.txt = cdata['txt'] + it.uuid = cdata['uuid'] it.save() else: it = ImageText.objects.create( @@ -64,9 +89,15 @@ class DispatchContentMixin(object): position=cdata['position'], title=cdata['title'], course=course, - img=ImageObject.objects.get(id=cdata['img']), txt=cdata['txt'], + uuid=cdata['uuid'], ) + try: + image_object = ImageObject.objects.get(id=cdata['img']) + it.img = image_object + it.save() + except ImageObject.DoesNotExist: + pass elif ctype == 'video': if 'id' in cdata and cdata['id']: v = Video.objects.get(id=cdata['id']) @@ -75,6 +106,7 @@ class DispatchContentMixin(object): v.title = cdata['title'] v.course = course v.url = cdata['url'] + v.uuid = cdata['uuid'] v.save() else: v = Video.objects.create( @@ -83,6 +115,7 @@ class DispatchContentMixin(object): title=cdata['title'], course=course, url=cdata['url'], + uuid=cdata['uuid'], ) elif ctype == 'images': if 'id' in cdata and cdata['id']: @@ -91,6 +124,7 @@ class DispatchContentMixin(object): g.course = course g.position = cdata['position'] g.title = cdata['title'] + g.uuid = cdata['uuid'] g.save() if 'images' in cdata: for image in cdata['images']: @@ -109,6 +143,7 @@ class DispatchContentMixin(object): course=course, position=cdata['position'], title=cdata['title'], + uuid=cdata['uuid'], ) if 'images' in cdata: for image in cdata['images']: diff --git a/api/v1/views.py b/api/v1/views.py index c47ce413..2782830b 100644 --- a/api/v1/views.py +++ b/api/v1/views.py @@ -341,11 +341,13 @@ class CommentViewSet(ExtendedModelViewSet): queryset = self.queryset is_deactivated = self.request.query_params.get('is_deactivated', '0') if is_deactivated == '0': - return queryset + queryset = queryset elif is_deactivated == '1': - return queryset.filter(deactivated_at__isnull=True) + queryset = queryset.filter(deactivated_at__isnull=True) elif is_deactivated == '2': - return queryset.filter(deactivated_at__isnull=False) + queryset = queryset.filter(deactivated_at__isnull=False) + + return queryset class AuthorRequestViewSet(ExtendedModelViewSet): diff --git a/apps/content/migrations/0016_auto_20180406_1816.py b/apps/content/migrations/0016_auto_20180406_1816.py new file mode 100644 index 00000000..178b4ec3 --- /dev/null +++ b/apps/content/migrations/0016_auto_20180406_1816.py @@ -0,0 +1,19 @@ +# Generated by Django 2.0.3 on 2018-04-06 18:16 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('content', '0015_content_uuid'), + ] + + operations = [ + migrations.AlterField( + model_name='image', + name='img', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='content_images', to='content.ImageObject', verbose_name='Объект изображения'), + ), + ] diff --git a/apps/content/migrations/0017_auto_20180406_1847.py b/apps/content/migrations/0017_auto_20180406_1847.py new file mode 100644 index 00000000..0007af09 --- /dev/null +++ b/apps/content/migrations/0017_auto_20180406_1847.py @@ -0,0 +1,19 @@ +# Generated by Django 2.0.3 on 2018-04-06 18:47 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('content', '0016_auto_20180406_1816'), + ] + + operations = [ + migrations.AlterField( + model_name='imagetext', + name='img', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='content_imagetexts', to='content.ImageObject', verbose_name='Объект изображения'), + ), + ] diff --git a/apps/content/models.py b/apps/content/models.py index 5c0b9b66..f82e3bd5 100644 --- a/apps/content/models.py +++ b/apps/content/models.py @@ -52,6 +52,7 @@ class Image(Content): img = models.ForeignKey( ImageObject, related_name='content_images', verbose_name='Объект изображения', on_delete=models.CASCADE, + null=True ) @@ -63,6 +64,7 @@ class ImageText(Content): img = models.ForeignKey( ImageObject, related_name='content_imagetexts', verbose_name='Объект изображения', on_delete=models.CASCADE, + null=True ) txt = models.TextField('Текст', default='') diff --git a/apps/course/templates/course/_items.html b/apps/course/templates/course/_items.html index 33312e53..f7b7d666 100644 --- a/apps/course/templates/course/_items.html +++ b/apps/course/templates/course/_items.html @@ -33,6 +33,16 @@
- | 2017 © Lil City, UAB. | +{% now "Y" %} © Lil City, UAB. |
На электронный адрес
{{ user.email }} отправлено письмо для подтверждения.
Если письмо где-то затерялось, вы можете повторить отправку письма для подтверждения. Отправить?
- ОТПРАВИТЬ
+ ОТПРАВИТЬ ПИСЬМО
diff --git a/apps/user/templates/user/payment-history.html b/apps/user/templates/user/payment-history.html
index af251c80..63de99bd 100644
--- a/apps/user/templates/user/payment-history.html
+++ b/apps/user/templates/user/payment-history.html
@@ -16,7 +16,7 @@
На электронный адрес
{{ user.email }} отправлено письмо для подтверждения.
Если письмо где-то затерялось, вы можете повторить отправку письма для подтверждения. Отправить?
- ОТПРАВИТЬ
+ ОТПРАВИТЬ ПИСЬМО
diff --git a/apps/user/templates/user/profile-settings.html b/apps/user/templates/user/profile-settings.html
index f5f2e9fe..8228c2ff 100644
--- a/apps/user/templates/user/profile-settings.html
+++ b/apps/user/templates/user/profile-settings.html
@@ -16,7 +16,7 @@
На электронный адрес
{{ user.email }} отправлено письмо для подтверждения.
Если письмо где-то затерялось, вы можете повторить отправку письма для подтверждения. Отправить?
- ОТПРАВИТЬ
+ ОТПРАВИТЬ ПИСЬМО
diff --git a/project/settings.py b/project/settings.py
index 2934c1de..b12c100d 100644
--- a/project/settings.py
+++ b/project/settings.py
@@ -254,6 +254,8 @@ RAVEN_CONFIG = {
INSTAGRAM_RESULTS_PATH = 'media/instagram/results/'
+DATA_UPLOAD_MAX_MEMORY_SIZE = 20242880
+
try:
from .local_settings import *
except ImportError:
diff --git a/project/templates/lilcity/edit_index.html b/project/templates/lilcity/edit_index.html
index 0c2fc067..b5e79164 100644
--- a/project/templates/lilcity/edit_index.html
+++ b/project/templates/lilcity/edit_index.html
@@ -278,7 +278,7 @@
-
Выбор урока/дня
+ Выбор курса/дня
При записи на 5 уроков скидка 10%.
|