diff --git a/api/v1/serializers/course.py b/api/v1/serializers/course.py
index fecd2b3a..551830ad 100644
--- a/api/v1/serializers/course.py
+++ b/api/v1/serializers/course.py
@@ -137,6 +137,7 @@ class CourseCreateSerializer(DispatchContentMixin,
'from_author',
'cover',
'price',
+ 'age',
'is_infinite',
'deferred_start_at',
'category',
@@ -288,6 +289,7 @@ class CourseSerializer(serializers.ModelSerializer):
'from_author',
'cover',
'price',
+ 'age',
'is_infinite',
'deferred_start_at',
'category',
diff --git a/apps/course/filters.py b/apps/course/filters.py
index 6e4e873e..cfecd0a0 100644
--- a/apps/course/filters.py
+++ b/apps/course/filters.py
@@ -5,7 +5,8 @@ from .models import Course
class CourseFilter(django_filters.FilterSet):
category = django_filters.CharFilter(field_name='category')
+ age = django_filters.ChoiceFilter(field_name='age', choices=Course.AGE_CHOICES)
class Meta:
model = Course
- fields = ['category']
+ fields = ['category', 'age']
diff --git a/apps/course/migrations/0044_course_age.py b/apps/course/migrations/0044_course_age.py
new file mode 100644
index 00000000..a45fd5eb
--- /dev/null
+++ b/apps/course/migrations/0044_course_age.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.0.6 on 2018-09-07 00:20
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('course', '0043_auto_20180824_2132'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='course',
+ name='age',
+ field=models.SmallIntegerField(choices=[(0, 'Любой возраст'), (1, 'до 5'), (2, '5-7'), (3, '7-9'), (4, '9-12'), (5, '12-15'), (6, '15-18'), (7, 'от 18')], default=0),
+ ),
+ ]
diff --git a/apps/course/models.py b/apps/course/models.py
index 41dcfe29..c7927600 100644
--- a/apps/course/models.py
+++ b/apps/course/models.py
@@ -50,6 +50,23 @@ class Course(BaseModel, DeactivatedMixin):
(ARCHIVED, 'Archived'),
(DENIED, 'Denied')
)
+ AGE_LT5 = 1
+ AGE_57 = 2
+ AGE_79 = 3
+ AGE_912 = 4
+ AGE_1215 = 5
+ AGE_1518 = 6
+ AGE_GT18 = 7
+ AGE_CHOICES = (
+ (0, 'Любой возраст'),
+ (AGE_LT5, 'до 5'),
+ (AGE_57, '5-7'),
+ (AGE_79, '7-9'),
+ (AGE_912, '9-12'),
+ (AGE_1215, '12-15'),
+ (AGE_1518, '15-18'),
+ (AGE_GT18, 'от 18'),
+ )
slug = models.SlugField(
allow_unicode=True, null=True, blank=True,
max_length=100, unique=True, db_index=True,
@@ -73,6 +90,7 @@ class Course(BaseModel, DeactivatedMixin):
'Цена курса', help_text='Если цена не выставлена, то курс бесплатный',
max_digits=10, decimal_places=2, null=True, blank=True
)
+ age = models.SmallIntegerField(choices=AGE_CHOICES, default=0)
is_infinite = models.BooleanField(default=False)
deferred_start_at = models.DateTimeField(
'Отложенный запуск курса', help_text='Заполнить если курс отложенный',
diff --git a/apps/course/templates/course/_items.html b/apps/course/templates/course/_items.html
index b4356f2b..f27bd326 100644
--- a/apps/course/templates/course/_items.html
+++ b/apps/course/templates/course/_items.html
@@ -54,7 +54,7 @@
{% endif %}
{{ course.title }}
-
{{ course.short_description }}
+
{{ course.short_description | safe | linebreaks | truncatechars_html:300 }}
Вернуться
+ {% if has_full_access %}
+
Редактировать
+ {% endif %}
{% if not paid and course.price and not has_full_access %}
Содержание курса
diff --git a/apps/course/templates/course/courses.html b/apps/course/templates/course/courses.html
index 8f6f57d2..f56279f6 100644
--- a/apps/course/templates/course/courses.html
+++ b/apps/course/templates/course/courses.html
@@ -23,15 +23,32 @@
Категории
-
-
Все курсы
+
{% category_items category %}
+
+
+
+
{% if age_name %}{{ age_name }}{% else %}Возраст{% endif %}
+
+
+ {% for a in ages %}
+
+ {% endfor %}
+
+
+
+
@@ -40,7 +57,7 @@
{% if page_obj.has_next %}
- Подгрузить еще
+ Подгрузить еще
{% endif %}
diff --git a/apps/course/templates/course/inclusion/category_items.html b/apps/course/templates/course/inclusion/category_items.html
index 5549ffa4..9ebd98ed 100644
--- a/apps/course/templates/course/inclusion/category_items.html
+++ b/apps/course/templates/course/inclusion/category_items.html
@@ -1,6 +1,6 @@
{% for cat in category_items %}
-
+
-{% endfor %}
\ No newline at end of file
+{% endfor %}
diff --git a/apps/course/templates/course/lesson.html b/apps/course/templates/course/lesson.html
index 990f4e35..547bb402 100644
--- a/apps/course/templates/course/lesson.html
+++ b/apps/course/templates/course/lesson.html
@@ -31,15 +31,9 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/apps/course/views.py b/apps/course/views.py
index 857a57d0..6b578923 100644
--- a/apps/course/views.py
+++ b/apps/course/views.py
@@ -167,9 +167,8 @@ class CourseEditView(TemplateView):
self.object = Course.objects.create(
author=request.user,
)
- #TODO
- #if (request.user != self.object.author and request.user.role < User.AUTHOR_ROLE) or request.user.role != User.ADMIN_ROLE:
- # raise Http404
+ if request.user != self.object.author and request.user.role != User.ADMIN_ROLE:
+ raise Http404
return super().get(request)
def get_context_data(self):
@@ -283,6 +282,14 @@ class CoursesView(ListView):
filtered = CourseFilter(self.request.GET)
context.update(filtered.data)
context['course_items'] = Course.shuffle(context.get('course_items'))
+ context['ages'] = Course.AGE_CHOICES[1:]
+ age = context.get('age')
+ if age and age[0]:
+ age = int(age[0])
+ context['age'] = [age]
+ context['age_name'] = dict(Course.AGE_CHOICES).get(age, '')
+ else:
+ context['age_name'] = ''
return context
def get_template_names(self):
diff --git a/apps/school/templates/school/livelesson_detail.html b/apps/school/templates/school/livelesson_detail.html
index 96db3a06..d3e5c5af 100644
--- a/apps/school/templates/school/livelesson_detail.html
+++ b/apps/school/templates/school/livelesson_detail.html
@@ -14,7 +14,7 @@
{{ livelesson.title }}
-
{{ livelesson.short_description | linebreaks }}
+
{{ livelesson.short_description | safe | linebreaks }}
{% if livelesson.stream_index %}
{% endfor %}
diff --git a/project/templates/blocks/gallery.html b/project/templates/blocks/gallery.html
index ccba4448..9a8c634a 100644
--- a/project/templates/blocks/gallery.html
+++ b/project/templates/blocks/gallery.html
@@ -11,80 +11,56 @@
-
-
- {% comment %}
{% endcomment %}
-
-
- {% comment %}
{% endcomment %}
-
-
- {% comment %}
{% endcomment %}
-
-
- {% comment %}
{% endcomment %}
-
-
- {% comment %}
{% endcomment %}
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
- {% comment %}
{% endcomment %}
-
-
- {% comment %}
{% endcomment %}
-
-
- {% comment %}
{% endcomment %}
-
-
- {% comment %}
{% endcomment %}
-
-
- {% comment %}
{% endcomment %}
-
-
- {% comment %}
{% endcomment %}
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/project/templates/blocks/last_courses.html b/project/templates/blocks/last_courses.html
index 9eee94ce..910b4ca3 100644
--- a/project/templates/blocks/last_courses.html
+++ b/project/templates/blocks/last_courses.html
@@ -3,9 +3,8 @@
Видео-курсы без расписания
Если вам не совсем удобно заниматься с нами каждый день в нашей онлайн-школе, специально для вас мы
- делаем отдельные уроки в записи, которые вы можете проходить когда вам будем удобно.
-
-
Учите и развивайте креативное мышление когда и где угодно
+ делаем отдельные уроки в записи, которые вы можете проходить когда вам будем удобно.
+ Учите и развивайте креативное мышление когда и где угодно
diff --git a/project/templates/blocks/lil_store_js.html b/project/templates/blocks/lil_store_js.html
index 37c99389..4fbb805d 100644
--- a/project/templates/blocks/lil_store_js.html
+++ b/project/templates/blocks/lil_store_js.html
@@ -18,6 +18,9 @@
role: +'{{ request.user.role }}',
photo: '{% if request.user.photo %}{{ request.user.photo.url }}{% else %}{% static 'img/user_default.jpg' %}{% endif %}',
},
- components: {}
+ components: {},
+ urls: {
+ courses: "{% url 'courses' %}"
+ },
};
diff --git a/project/templates/blocks/popup_course_lock.html b/project/templates/blocks/popup_course_lock.html
index 45f87ae0..e7445d96 100644
--- a/project/templates/blocks/popup_course_lock.html
+++ b/project/templates/blocks/popup_course_lock.html
@@ -6,7 +6,7 @@
ЧТОБЫ ПРОДОЛЖИТЬ ПРОСМОТР
{{ course.title }}
-
{{ course.short_description }}
+
{{ course.short_description | safe | linebreaks }}
КУПИТЬ КУРС
diff --git a/project/templates/lilcity/main.html b/project/templates/lilcity/main.html
index 4227d9ec..06cc2758 100644
--- a/project/templates/lilcity/main.html
+++ b/project/templates/lilcity/main.html
@@ -9,7 +9,7 @@
{% include "templates/blocks/about.html" %}
{% include "templates/blocks/last_courses.html" %}
{% include "templates/blocks/gallery.html" %}
- {% include "templates/blocks/game.html" %}
{% include "templates/blocks/teachers.html" %}
+ {% include "templates/blocks/game.html" %}
{% include "templates/blocks/partners.html" %}
{% endblock content %}
diff --git a/project/views.py b/project/views.py
index e2df9f42..89fc7741 100644
--- a/project/views.py
+++ b/project/views.py
@@ -68,7 +68,7 @@ class IndexView(TemplateView):
'online': online,
'online_coming_soon': online_coming_soon,
'school_schedule': school_schedule,
- 'course_items': Course.shuffle(Course.objects.filter(status=Course.PUBLISHED)[:6]),
+ 'course_items': Course.shuffle(Course.objects.filter(status=Course.PUBLISHED)[:3]),
'is_purchased': school_payment_exists,
'min_school_price': SchoolSchedule.objects.aggregate(Min('month_price'))['month_price__min'],
'school_schedules': SchoolSchedule.objects.all(),
diff --git a/web/src/components/CourseRedactor.vue b/web/src/components/CourseRedactor.vue
index 4c46f4b2..767a4254 100644
--- a/web/src/components/CourseRedactor.vue
+++ b/web/src/components/CourseRedactor.vue
@@ -37,10 +37,8 @@
v-bind:class="{ error: ($v.course.short_description.$dirty || showErrors) && $v.course.short_description.$invalid }">
{{titles.shortDescription}}
-
+
@@ -49,7 +47,7 @@
v-bind:class="{ error: ($v.course.category.$dirty || showErrors) && $v.course.category.$invalid }">
КАТЕГОРИЯ
-
@@ -113,6 +111,13 @@
руб.
+
Выделить
@@ -198,7 +203,7 @@
{{ lesson.title }}
-
{{ lesson.short_description }}
+
@@ -232,6 +237,7 @@
import LinkInput from './inputs/LinkInput'
import DatePicker from 'vuejs-datepicker'
import BlockContent from './blocks/BlockContent'
+ import VueRedactor from './redactor/VueRedactor';
import LilSelect from "./inputs/LilSelect";
import LessonRedactor from "./LessonRedactor";
import {api} from "../js/modules/api";
@@ -269,6 +275,7 @@
duration: null,
author: null,
price: null,
+ age: 0,
url: '',
coverImage: '',
kit__body: null,
@@ -333,6 +340,40 @@
'value': '18:00',
}
],
+ ages: [
+ {
+ 'title': 'Любой возраст',
+ 'value': 0,
+ },
+ {
+ 'title': 'до 5',
+ 'value': 1,
+ },
+ {
+ 'title': '5-7',
+ 'value': 2,
+ },
+ {
+ 'title': '7-9',
+ 'value': 3,
+ },
+ {
+ 'title': '9-12',
+ 'value': 4,
+ },
+ {
+ 'title': '12-15',
+ 'value': 5,
+ },
+ {
+ 'title': '15-18',
+ 'value': 6,
+ },
+ {
+ 'title': 'от 18',
+ 'value': 7,
+ },
+ ],
weekdays: [
'',
@@ -441,15 +482,6 @@
this.course.url = slugify(this.course.title);
}
},
- updateCategory() {
- if (this.categoryOptions && Array.isArray(this.categoryOptions) && this.course.category) {
- this.categoryOptions.forEach((category) => {
- if (category.id === this.course.category) {
- this.course.categorySelect = category;
- }
- });
- }
- },
removeLesson(lessonIndex) {
if (!confirm('Вы действительно хотите удалить этот урок?')) {
return;
@@ -885,14 +917,8 @@
promises.push(cats);
cats.then((response) => {
if (response.data) {
- this.categoryOptions = response.data.results.map((category) => {
- return {
- title: category.title,
- value: category.id
- }
- });
+ this.categoryOptions = response.data.results;
}
- this.updateCategory();
});
if(this.live) {
@@ -932,7 +958,6 @@
this.scheduleOptions = _.orderBy(options, (item)=>{return moment(item.value)});
}
- this.updateCategory();
});
}
@@ -1003,23 +1028,6 @@
this.course.price = value || 0;
}
},
- categorySelect: {
- get() {
- if (!this.categoryOptions || this.categoryOptions.length === 0 || !this.course || !this.course.category) {
- return null;
- }
- let value;
- this.categoryOptions.forEach((category) => {
- if (category.value === this.course.category) {
- value = category;
- }
- });
- return value;
- },
- set(value) {
- this.course.category = value.value;
- }
- },
// userSelect: {
// get() {
// if (!this.users || this.users.length === 0 || !this.course || !this.course.author) {
@@ -1078,6 +1086,7 @@
'vue-datepicker': DatePicker,
'lesson-redactor': LessonRedactor,
'vue-draggable': Draggable,
+ 'vue-redactor': VueRedactor,
}
}
@@ -1178,9 +1187,10 @@
overflow: scroll;
}
- .field_short_description {
+ .field_short_description .redactor-box {
+ overflow-x: visible;
+ overflow-y: auto;
max-height: 200px;
- overflow: scroll;
}
diff --git a/web/src/components/LessonRedactor.vue b/web/src/components/LessonRedactor.vue
index 1fe1724b..de458e55 100644
--- a/web/src/components/LessonRedactor.vue
+++ b/web/src/components/LessonRedactor.vue
@@ -27,7 +27,8 @@
@@ -46,6 +47,7 @@
diff --git a/web/src/components/inputs/LilSelect.vue b/web/src/components/inputs/LilSelect.vue
index 7fd19d60..182f2d2e 100644
--- a/web/src/components/inputs/LilSelect.vue
+++ b/web/src/components/inputs/LilSelect.vue
@@ -4,8 +4,9 @@
{{ selectedTitle }}
@@ -14,11 +15,14 @@