diff --git a/api/v1/serializers/mixins.py b/api/v1/serializers/mixins.py
index cb19fafc..3b0f1a86 100644
--- a/api/v1/serializers/mixins.py
+++ b/api/v1/serializers/mixins.py
@@ -37,7 +37,14 @@ 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:
@@ -45,16 +52,29 @@ 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'])
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()
@@ -63,10 +83,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'])
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/course_edit.html b/apps/course/templates/course/course_edit.html
index 521e8d0b..d27f5c6c 100644
--- a/apps/course/templates/course/course_edit.html
+++ b/apps/course/templates/course/course_edit.html
@@ -14,6 +14,6 @@
{% if course and course.id %}:course-id="{{ course.id }}"{% endif %}>
{% endblock content %}
{% block foot %}
-
-
-{% endblock foot %}
+
+
+{% endblock foot %}
\ No newline at end of file
diff --git a/apps/course/views.py b/apps/course/views.py
index a7fb0abe..ffb28759 100644
--- a/apps/course/views.py
+++ b/apps/course/views.py
@@ -155,7 +155,7 @@ class CourseOnModerationView(TemplateView):
class CourseEditView(TemplateView):
template_name = 'course/course_edit.html'
- def get(self, request, pk=None):
+ def get(self, request, pk=None, lesson=None):
drafts = Course.objects.filter(
author=request.user, status=Course.DRAFT
)
diff --git a/project/urls.py b/project/urls.py
index f1d97216..a189c65c 100644
--- a/project/urls.py
+++ b/project/urls.py
@@ -46,6 +46,9 @@ urlpatterns = [
path('author-request/success/', TemplateView.as_view(template_name='user/become-author-success.html'), name='author-request-success'),
path('courses/', CoursesView.as_view(), name='courses'),
path('course/create', CourseEditView.as_view(), name='course_create'),
+ path('course/create/lessons', CourseEditView.as_view(), name='course_create'),
+ path('course/create/lessons/new', CourseEditView.as_view(), name='course_create'),
+ path('course/create/lessons/edit/', CourseEditView.as_view(), name='course_create'),
path('course/create/live', CourseLiveEditView.as_view(), name='course_create_live'),
path('course/on-moderation', CourseOnModerationView.as_view(), name='course-on-moderation'),
path('course//', CourseView.as_view(), name='course'),
diff --git a/web/src/components/CourseRedactor.vue b/web/src/components/CourseRedactor.vue
index 0abe3b33..22e57712 100644
--- a/web/src/components/CourseRedactor.vue
+++ b/web/src/components/CourseRedactor.vue
@@ -35,6 +35,18 @@
v-model="course.title">
+