From 7267dad3f5e871ff9b1898a0d10d95a837485f44 Mon Sep 17 00:00:00 2001 From: gzbender Date: Thu, 9 Aug 2018 03:19:07 +0500 Subject: [PATCH] =?UTF-8?q?LIL-601,=20=D0=A4=D0=B8=D0=BB=D1=8C=D1=82=D1=80?= =?UTF-8?q?=20=D0=BF=D0=BE=20=D0=B2=D0=BE=D0=B7=D1=80=D0=B0=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=BC=20=D0=B2=20=D0=BA=D1=83=D1=80=D1=81=D0=B0=D1=85,?= =?UTF-8?q?=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=8C=20=D1=83=D0=BA=D0=B0=D0=B7=D0=B0=D1=82=D1=8C=20=D0=B2?= =?UTF-8?q?=D0=BE=D0=B7=D1=80=D0=B0=D1=81=D1=82,=20=D1=80=D0=B5=D1=84?= =?UTF-8?q?=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BC=D0=BD=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/v1/serializers/course.py | 2 + apps/course/filters.py | 3 +- apps/course/models.py | 18 ++++ apps/course/templates/course/courses.html | 29 +++-- .../course/inclusion/category_items.html | 3 +- apps/course/views.py | 9 ++ project/templates/lilcity/index.html | 7 ++ web/src/components/CourseRedactor.vue | 79 ++++++++------ web/src/components/inputs/LilSelect.vue | 28 +++-- web/src/js/modules/api.js | 2 + web/src/js/modules/courses.js | 101 +++++++++++------- 11 files changed, 191 insertions(+), 90 deletions(-) diff --git a/api/v1/serializers/course.py b/api/v1/serializers/course.py index bdb1a289..4e558f3a 100644 --- a/api/v1/serializers/course.py +++ b/api/v1/serializers/course.py @@ -110,6 +110,7 @@ class CourseCreateSerializer(DispatchContentMixin, 'from_author', 'cover', 'price', + 'age', 'is_infinite', 'deferred_start_at', 'category', @@ -261,6 +262,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 827079e6..64596057 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__title', lookup_expr='iexact') + 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/models.py b/apps/course/models.py index 72cfad97..03fd9ed3 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/courses.html b/apps/course/templates/course/courses.html index a3277174..2f47675a 100644 --- a/apps/course/templates/course/courses.html +++ b/apps/course/templates/course/courses.html @@ -20,18 +20,35 @@
-
-
{% if category %}{{ category.0 }}{% else %}Категории{% endif %}
+
+
{% if category.0 %}{{ category.0 }}{% else %}Категории{% endif %}
-
-
Все курсы
+
+
Все категории
{% category_items category %}
+
+
+
+
{% if age_name %}{{ age_name }}{% else %}Возраст{% endif %}
+
+
+
Любой возраст
+
+ {% for a in ages %} +
+
{{ a.1 }}
+
+ {% 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 5e6aeef5..66fb771b 100644 --- a/apps/course/templates/course/inclusion/category_items.html +++ b/apps/course/templates/course/inclusion/category_items.html @@ -1,5 +1,6 @@ {% for cat in category_items %} -
+
{{ cat.title }}
{% endfor %} \ No newline at end of file diff --git a/apps/course/views.py b/apps/course/views.py index 3ecd6bd0..ffbbee66 100644 --- a/apps/course/views.py +++ b/apps/course/views.py @@ -283,6 +283,15 @@ class CoursesView(ListView): context = super().get_context_data() filtered = CourseFilter(self.request.GET) context.update(filtered.data) + context['ages'] = Course.AGE_CHOICES[1:] + # context['age'] = list(map(int, context.get('age', []))) + 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/project/templates/lilcity/index.html b/project/templates/lilcity/index.html index 5d7b9d2d..c7b9d5b7 100644 --- a/project/templates/lilcity/index.html +++ b/project/templates/lilcity/index.html @@ -130,6 +130,13 @@ {% include "templates/blocks/popup_course_lock.html" %} {% include "templates/blocks/popup_subscribe.html" %}
+