From cb809cb8fa154831359c72e80251f64ea97ddbd6 Mon Sep 17 00:00:00 2001 From: gzbender Date: Thu, 19 Jul 2018 14:55:42 +0500 Subject: [PATCH 01/30] =?UTF-8?q?LIL-560=20=D0=9A=D0=BD=D0=BE=D0=BF=D0=BA?= =?UTF-8?q?=D1=83=20=C2=AB=D0=A1=D0=BC=D0=BE=D1=82=D1=80=D0=B5=D1=82=D1=8C?= =?UTF-8?q?=20=D1=83=D1=80=D0=BE=D0=BA=C2=BB=20=D0=BF=D0=BE=D0=B4=D0=BD?= =?UTF-8?q?=D1=8F=D1=82=D1=8C=20=D0=B2=D1=8B=D1=88=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blocks/_schedule_purchased_item.html | 78 ------------------- apps/school/templates/blocks/schedule.html | 69 +--------------- .../schedule_item.html} | 38 +++++---- .../templates/blocks/schedule_purchased.html | 4 +- .../templates/school/schedules_print.html | 62 +-------------- .../templates/summer/schedule_purchased.html | 4 +- web/src/sass/_common.sass | 11 ++- 7 files changed, 41 insertions(+), 225 deletions(-) delete mode 100644 apps/school/templates/blocks/_schedule_purchased_item.html rename apps/school/templates/{summer/_schedule_purchased_item.html => blocks/schedule_item.html} (70%) diff --git a/apps/school/templates/blocks/_schedule_purchased_item.html b/apps/school/templates/blocks/_schedule_purchased_item.html deleted file mode 100644 index b9d1db1f..00000000 --- a/apps/school/templates/blocks/_schedule_purchased_item.html +++ /dev/null @@ -1,78 +0,0 @@ -{% load static %} {% load thumbnail %} -
-
-
-
- {{ school_schedule }} -
- {% if live_lesson %} -
{{ live_lesson.date }}
- {% endif %} -
-
-
{{ school_schedule.start_at }} (МСК)
- {% if school_schedule.weekday in school_schedules_purchased %} - {% if live_lesson and live_lesson.title %} - {% include './open_lesson.html' %} - {% endif %} - {% else %} - {% include './day_pay_btn.html' %} - {% endif %} -
- {% comment %} - - {% endcomment %} - {% if school_schedule.weekday in school_schedules_purchased %} - - {% endif %} -
-
-
- {% thumbnail live_lesson.cover.image "70x70" crop="center" as im %} - - {% empty %} - - {% endthumbnail %} -
-
-
-
{{ school_schedule.title }}{% if live_lesson and live_lesson.title %}, - {{ live_lesson.title }} - {% endif %} -
-
- {% if live_lesson and live_lesson.short_description %} - {{ live_lesson.short_description }} - {% else %} - {{ school_schedule.description }} - {% endif %} -
-
-
Материалы
-
-
- {{ school_schedule.materials }} -
-
- {% if school_schedule.schoolschedule_images.exists %} -
Результаты прошлых уроков
- - {% endif %} -
-
-
- -
-
diff --git a/apps/school/templates/blocks/schedule.html b/apps/school/templates/blocks/schedule.html index 2e4c6457..5f088511 100644 --- a/apps/school/templates/blocks/schedule.html +++ b/apps/school/templates/blocks/schedule.html @@ -6,74 +6,7 @@
{% for school_schedule in school_schedules %} - {% with current_live_lesson=school_schedule.current_live_lesson %} -
-
-
-
- {{ school_schedule }} -
- {% if current_live_lesson %} - - {% endif %} -
-
-
{{ school_schedule.start_at }} (МСК)
- -
-
-
-
- {% thumbnail current_live_lesson.cover.image "70x70" crop="center" as im %} - - {% empty %} - - {% endthumbnail %} -
-
-
-
{{ school_schedule.title }} - {% if current_live_lesson and current_live_lesson.title %} - , {{ current_live_lesson.title }} - {% endif %} -
-
- {% if live_lesson %} - {{ live_lesson.short_description }} - {% else %} - {{ school_schedule.description }} - {% endif %} -
-
-
Материалы
-
-
- {{ school_schedule.materials }} -
-
- {% if school_schedule.schoolschedule_images.exists %} -
Результаты прошлых уроков
- - {% endif %} -
-
-
- -
-
- {% endwith %} + {% include 'blocks/schedule_item.html' with school_schedule=school_schedule live_lesson=school_schedule.current_live_lesson purchased=True %} {% endfor %}
diff --git a/apps/school/templates/summer/_schedule_purchased_item.html b/apps/school/templates/blocks/schedule_item.html similarity index 70% rename from apps/school/templates/summer/_schedule_purchased_item.html rename to apps/school/templates/blocks/schedule_item.html index 0e86ccba..0cafb9f3 100644 --- a/apps/school/templates/summer/_schedule_purchased_item.html +++ b/apps/school/templates/blocks/schedule_item.html @@ -1,21 +1,23 @@ {% load static %} {% load thumbnail %} -
+
{{ school_schedule }}
- {% if live_lesson %} + {% if purchased and live_lesson %}
{{ live_lesson.date }}
{% endif %} +
{{ school_schedule.start_at }} (МСК)
-
{{ school_schedule.start_at }} (МСК)
- {% if school_schedule.weekday in school_schedules_purchased %} - {% if live_lesson and live_lesson.title %} - {% include './open_lesson.html' %} + {% if purchased %} + {% if school_schedule.weekday in school_schedules_purchased %} + {% if live_lesson and live_lesson.title %} + {% include './open_lesson.html' %} + {% endif %} + {% else %} + {% include './day_pay_btn.html' %} {% endif %} - {% else %} - {% include './day_pay_btn.html' %} {% endif %}
@@ -36,7 +38,7 @@ {% endthumbnail %}
-
+
{{ school_schedule.title }}{% if live_lesson and live_lesson.title %}, {{ live_lesson.title }} {% endif %} @@ -51,11 +53,19 @@
Материалы
-
- {{ school_schedule.materials }} -
+ {% if print %} +
+
+ {{ school_schedule.materials }} +
+
+ {% else %} +
+ {{ school_schedule.materials }} +
+ {% endif %}
- {% if school_schedule.schoolschedule_images.exists %} + {% if not print and school_schedule.schoolschedule_images.exists %}
Результаты прошлых уроков
+ {% if not print %}
+ {% endif %}
diff --git a/apps/school/templates/blocks/schedule_purchased.html b/apps/school/templates/blocks/schedule_purchased.html index 7f8f035d..5d1a5827 100644 --- a/apps/school/templates/blocks/schedule_purchased.html +++ b/apps/school/templates/blocks/schedule_purchased.html @@ -41,10 +41,10 @@ {% for school_schedule in school_schedules %} {% if is_previous %} {% if school_schedule.previous_live_lesson in live_lessons %} - {% include './_schedule_purchased_item.html' with school_schedule=school_schedule live_lesson=school_schedule.previous_live_lesson %} + {% include 'blocks/schedule_item.html' with school_schedule=school_schedule live_lesson=school_schedule.previous_live_lesson purchased=True %} {% endif %} {% else %} - {% include './_schedule_purchased_item.html' with school_schedule=school_schedule live_lesson=school_schedule.current_live_lesson %} + {% include 'blocks/schedule_item.html' with school_schedule=school_schedule live_lesson=school_schedule.current_live_lesson purchased=True %} {% endif %} {% endfor %} {% endif %} diff --git a/apps/school/templates/school/schedules_print.html b/apps/school/templates/school/schedules_print.html index 25aca06e..66c936cb 100644 --- a/apps/school/templates/school/schedules_print.html +++ b/apps/school/templates/school/schedules_print.html @@ -11,70 +11,16 @@ - +
Расписание
- {% for school_schedule in school_schedules %} {% with current_live_lesson=school_schedule.current_live_lesson %} -
-
-
-
- {{ school_schedule }} -
- {% if current_live_lesson %} - - {% endif %} -
-
-
{{ school_schedule.start_at }} (МСК)
-
-
-
-
- {% thumbnail current_live_lesson.cover.image "70x70" crop="center" as im %} - {% empty %} - {% endthumbnail %} -
-
-
-
{{ school_schedule.title }}{% if current_live_lesson %}, - {{ current_live_lesson.title }} - {% endif %} -
-
- {% if live_lesson %} - {{ live_lesson.short_description }} - {% else %} - {{ school_schedule.description }} - {% endif %} -
-
-
Материалы
-
-
-
- {{ school_schedule.materials }} -
-
-
- - - - - - - - - - -
-
-
- {% endwith %} {% endfor %} + {% for school_schedule in school_schedules %} + {% include 'blocks/schedule_item.html' with school_schedule=school_schedule live_lesson=school_schedule.current_live_lesson print=True %} + {% endfor %}
diff --git a/apps/school/templates/summer/schedule_purchased.html b/apps/school/templates/summer/schedule_purchased.html index 63e963fd..e327fc96 100644 --- a/apps/school/templates/summer/schedule_purchased.html +++ b/apps/school/templates/summer/schedule_purchased.html @@ -41,10 +41,10 @@ {% for school_schedule in school_schedules %} {% if is_previous %} {% if school_schedule.previous_live_lesson in live_lessons %} - {% include './_schedule_purchased_item.html' with school_schedule=school_schedule live_lesson=school_schedule.previous_live_lesson %} + {% include 'blocks/schedule_item.html' with school_schedule=school_schedule live_lesson=school_schedule.previous_live_lesson purchased=True %} {% endif %} {% else %} - {% include './_schedule_purchased_item.html' with school_schedule=school_schedule live_lesson=school_schedule.current_live_lesson %} + {% include 'blocks/schedule_item.html' with school_schedule=school_schedule live_lesson=school_schedule.current_live_lesson purchased=True %} {% endif %} {% endfor %} {% endif %} diff --git a/web/src/sass/_common.sass b/web/src/sass/_common.sass index 8386a037..f9cee7ff 100755 --- a/web/src/sass/_common.sass +++ b/web/src/sass/_common.sass @@ -3782,6 +3782,7 @@ a.grey-link +m display: flex flex-direction: row + width: 100% &__day position: relative margin: 10px 0 5px @@ -3807,20 +3808,22 @@ a.grey-link margin: -3px 0 0 auto &__buy +m - display: flex - margin-left: 20px + flex: 1 0 0 + text-align: right &__time margin: 15px 0 opacity: .5 +m - width: 90px - margin: 0 + margin: -1px 15px + font-size: 12px; &__btn margin-right: -60px padding-left: 20px padding-right: 20px white-space: nowrap letter-spacing: 1px + +m + margin-right: 0 &__pic display: block width: 100% From 1cbb6fd39dcaed345f03d905b6ebb25b1e6d3f04 Mon Sep 17 00:00:00 2001 From: gzbender Date: Thu, 19 Jul 2018 23:38:54 +0500 Subject: [PATCH 02/30] =?UTF-8?q?LIL-576=20=D0=9F=D0=BE=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D1=82=D1=8C=20=D0=B2=D0=B5=D1=80=D1=81=D1=82=D0=BA?= =?UTF-8?q?=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/course/course_only_lessons.html | 15 +++++------ apps/course/templates/course/lesson.html | 24 ++++++++--------- web/src/sass/_common.sass | 27 +++++++++++++++---- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/apps/course/templates/course/course_only_lessons.html b/apps/course/templates/course/course_only_lessons.html index f0217bcf..0f8c0483 100644 --- a/apps/course/templates/course/course_only_lessons.html +++ b/apps/course/templates/course/course_only_lessons.html @@ -180,19 +180,18 @@ {% endif %} diff --git a/apps/course/templates/course/lesson.html b/apps/course/templates/course/lesson.html index 662a4dd5..48d64ef8 100644 --- a/apps/course/templates/course/lesson.html +++ b/apps/course/templates/course/lesson.html @@ -27,18 +27,18 @@ {% endif %}
-
{{ lesson.title }}
-
{{ lesson.short_description }}
- {% comment %} - {% if lesson.cover %} - - {% else %} - - {% endif %} - - - - {% endcomment %} +
+
+
+ +
+
+
+
{{ lesson.title }}
+
{{ lesson.short_description }}
+
+
diff --git a/web/src/sass/_common.sass b/web/src/sass/_common.sass index 8386a037..fe137963 100755 --- a/web/src/sass/_common.sass +++ b/web/src/sass/_common.sass @@ -175,7 +175,7 @@ button top: 1px left: 1px right: 1px - bottom: 1px + bottom: 2px background: white border-radius: 2px transition: opacity .2s @@ -2654,10 +2654,9 @@ a.grey-link border-radius: 50%; overflow: hidden; &__pic - top: 50%; - position: relative; - transform: translateY(-50%); + object-fit: cover width: 100% + height: 100% &__content flex: 0 0 calc(100% - 165px) &__actions @@ -2700,7 +2699,7 @@ a.grey-link margin-bottom: 10px color: #191919 &__content - margin-bottom: 30px + margin-bottom: 15px color: #191919 &__video_frame width: 100% @@ -2708,6 +2707,24 @@ a.grey-link &__chat_frame width: 100% height: 600px + &__row + display: flex + +m + display: block + &__preview + margin-right: 25px + flex: 0 0 140px + +m + display: none + &__pic-wrapper + width: 130px; + height: 130px; + border-radius: 50%; + overflow: hidden; + &__pic + object-fit: cover + width: 100% + height: 100% .lessons From d2613889420b5cdc9c3707c2996e1fa6abc0e6d1 Mon Sep 17 00:00:00 2001 From: gzbender Date: Mon, 23 Jul 2018 02:48:31 +0500 Subject: [PATCH 03/30] =?UTF-8?q?LIL-595=20=D0=A1=D0=BE=D1=80=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BF=D1=80=D0=B8=20=D0=B2?= =?UTF-8?q?=D1=8B=D0=B2=D0=BE=D0=B4=D0=B5=20=D0=BA=D1=83=D1=80=D1=81=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=BD=D0=B0=20=D1=81=D0=B0=D0=B9=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/course/models.py | 2 +- apps/course/views.py | 15 ++++++++- web/src/components/CourseRedactor.vue | 44 +++++++++++++-------------- 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/apps/course/models.py b/apps/course/models.py index 942a0593..b716d53b 100644 --- a/apps/course/models.py +++ b/apps/course/models.py @@ -97,7 +97,7 @@ class Course(BaseModel, DeactivatedMixin): class Meta: verbose_name = 'Курс' verbose_name_plural = 'Курсы' - ordering = ['-created_at'] + ordering = ['-is_featured', ] def __str__(self): return str(self.id) + ' ' + self.title diff --git a/apps/course/views.py b/apps/course/views.py index 8cff720a..1d961625 100644 --- a/apps/course/views.py +++ b/apps/course/views.py @@ -1,3 +1,4 @@ +from random import shuffle from paymentwall import Pingback from django.contrib.auth import get_user_model @@ -234,7 +235,6 @@ class CoursesView(ListView): def get(self, request, *args, **kwargs): self.object_list = self.get_queryset() - allow_empty = self.get_allow_empty() if request.is_ajax(): context = self.get_context_data() template_name = self.get_template_names() @@ -276,6 +276,19 @@ class CoursesView(ListView): context = super().get_context_data() filtered = CourseFilter(self.request.GET) context.update(filtered.data) + # Иммитация order_by('?'), чтобы можно было использовать пагинацию + # если что, сделать свой QuerySet для Course с методом, который возвращает такой список + course_items = context.get('course_items') + featured = [] + other = [] + for ci in course_items: + if ci.is_featured: + featured.append(ci) + else: + other.append(ci) + shuffle(featured) + shuffle(other) + context['course_items'] = featured + other return context def get_template_names(self): diff --git a/web/src/components/CourseRedactor.vue b/web/src/components/CourseRedactor.vue index f4291156..3b2f279f 100644 --- a/web/src/components/CourseRedactor.vue +++ b/web/src/components/CourseRedactor.vue @@ -992,28 +992,28 @@ }); } - // let user = api.getCurrentUser(this.accessToken); - // promises.push(user); - // - // user.then((response) => { - // if (response.data) { - // this.me = response.data; - // - // if(this.me.role == ROLE_ADMIN) { - // api.getUsers({role: [ROLE_AUTHOR,ROLE_ADMIN], page_size: 1000}, this.accessToken) - // .then((usersResponse) => { - // if (usersResponse.data) { - // this.users = usersResponse.data.results.map((user) => { - // return { - // title: `${user.first_name} ${user.last_name}`, - // value: user.id - // } - // }); - // } - // }); - // } - // } - // }); + let user = api.getCurrentUser(this.accessToken); + promises.push(user); + + user.then((response) => { + if (response.data) { + this.me = response.data; + + /* if(this.me.role == ROLE_ADMIN) { + api.getUser(this.me.id, {role: [ROLE_AUTHOR, ROLE_ADMIN], page_size: 1000}, this.accessToken) + .then((usersResponse) => { + if (usersResponse.data) { + this.users = usersResponse.data.results.map((user) => { + return { + title: `${user.first_name} ${user.last_name}`, + value: user.id + } + }); + } + }); + } */ + } + }); // if (this.courseId) { // this.loadCourse().then(()=>{this.updateViewSection(window.location, 'load')}).catch(()=>{ From 4d06d62f06072b8496df30edfc970f2b49c18191 Mon Sep 17 00:00:00 2001 From: gzbender Date: Mon, 23 Jul 2018 15:54:30 +0500 Subject: [PATCH 04/30] =?UTF-8?q?LIL-595=20=D0=A1=D0=BE=D1=80=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BF=D1=80=D0=B8=20=D0=B2?= =?UTF-8?q?=D1=8B=D0=B2=D0=BE=D0=B4=D0=B5=20=D0=BA=D1=83=D1=80=D1=81=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=BD=D0=B0=20=D1=81=D0=B0=D0=B9=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/course/models.py | 19 +++++++++++++++++++ apps/course/views.py | 15 +-------------- project/views.py | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/apps/course/models.py b/apps/course/models.py index b716d53b..bc7717b6 100644 --- a/apps/course/models.py +++ b/apps/course/models.py @@ -1,4 +1,5 @@ import arrow +from random import shuffle from uuid import uuid4 from django.db import models from django.core.exceptions import ValidationError @@ -148,6 +149,24 @@ class Course(BaseModel, DeactivatedMixin): def count_videos_in_lessons(self): return Video.objects.filter(lesson__in=self.lessons.all()).count() + @classmethod + def shuffle(cls, qs, order_is_featured = True): + if order_is_featured: + featured = [] + other = [] + for c in list(qs): + if c.is_featured: + featured.append(c) + else: + other.append(c) + shuffle(featured) + shuffle(other) + return featured + other + else: + all = list(qs) + shuffle(all) + return all + class Category(models.Model): title = models.CharField('Название категории', max_length=100) diff --git a/apps/course/views.py b/apps/course/views.py index 1d961625..5fd8b577 100644 --- a/apps/course/views.py +++ b/apps/course/views.py @@ -1,4 +1,3 @@ -from random import shuffle from paymentwall import Pingback from django.contrib.auth import get_user_model @@ -276,19 +275,7 @@ class CoursesView(ListView): context = super().get_context_data() filtered = CourseFilter(self.request.GET) context.update(filtered.data) - # Иммитация order_by('?'), чтобы можно было использовать пагинацию - # если что, сделать свой QuerySet для Course с методом, который возвращает такой список - course_items = context.get('course_items') - featured = [] - other = [] - for ci in course_items: - if ci.is_featured: - featured.append(ci) - else: - other.append(ci) - shuffle(featured) - shuffle(other) - context['course_items'] = featured + other + context['course_items'] = Course.shuffle(context.get('course_items')) return context def get_template_names(self): diff --git a/project/views.py b/project/views.py index c8400f14..57435b56 100644 --- a/project/views.py +++ b/project/views.py @@ -74,7 +74,7 @@ class IndexView(TemplateView): 'online': online, 'online_coming_soon': online_coming_soon, 'school_schedule': school_schedule, - 'course_items': Course.objects.filter(status=Course.PUBLISHED)[:6], + 'course_items': Course.shuffle(Course.objects.filter(status=Course.PUBLISHED)[:6]), 'is_purchased': school_payment_exists, 'min_school_price': SchoolSchedule.objects.aggregate(Min('month_price'))['month_price__min'], 'school_schedules': SchoolSchedule.objects.all(), From 55bb4bb70cef8a5dad963f667577a56ac7bd4bd7 Mon Sep 17 00:00:00 2001 From: gzbender Date: Tue, 24 Jul 2018 18:26:01 +0500 Subject: [PATCH 05/30] =?UTF-8?q?LIL-597=20=D0=9F=D0=BE=D0=BA=D0=B0=D0=B7?= =?UTF-8?q?=D1=8B=D0=B2=D0=B0=D1=82=D1=8C=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81?= =?UTF-8?q?=D0=B8=20=D1=83=D1=80=D0=BE=D0=BA=D0=BE=D0=B2=20=D0=B7=D0=B0=20?= =?UTF-8?q?=D0=B2=D1=81=D1=91=20=D0=B2=D1=80=D0=B5=D0=BC=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/summer/schedule_purchased.html | 20 ++++++----- apps/school/views.py | 33 +++++++++++++++---- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/apps/school/templates/summer/schedule_purchased.html b/apps/school/templates/summer/schedule_purchased.html index 63e963fd..4de81091 100644 --- a/apps/school/templates/summer/schedule_purchased.html +++ b/apps/school/templates/summer/schedule_purchased.html @@ -38,15 +38,17 @@ {% if is_previous and not live_lessons_exists %} Записей уроков пока нет {% else %} - {% for school_schedule in school_schedules %} - {% if is_previous %} - {% if school_schedule.previous_live_lesson in live_lessons %} - {% include './_schedule_purchased_item.html' with school_schedule=school_schedule live_lesson=school_schedule.previous_live_lesson %} - {% endif %} - {% else %} - {% include './_schedule_purchased_item.html' with school_schedule=school_schedule live_lesson=school_schedule.current_live_lesson %} - {% endif %} - {% endfor %} + {% if is_previous %} + {% for live_lesson in live_lessons %} + {% if live_lesson.school_schedule %} + {% include './_schedule_purchased_item.html' with school_schedule=live_lesson.school_schedule live_lesson=live_lesson %} + {% endif %} + {% endfor %} + {% else %} + {% for school_schedule in school_schedules %} + {% include './_schedule_purchased_item.html' with school_schedule=school_schedule live_lesson=school_schedule.current_live_lesson %} + {% endfor %} + {% endif %} {% endif %}
diff --git a/apps/school/views.py b/apps/school/views.py index 7f4ab734..3c1b478a 100644 --- a/apps/school/views.py +++ b/apps/school/views.py @@ -4,7 +4,7 @@ from paymentwall import Pingback from django.contrib.auth import get_user_model from django.contrib.auth.decorators import login_required, user_passes_test from django.db.utils import IntegrityError -from django.db.models import Min, F, Func, Q +from django.db.models import Min, F, Func, Q, Value from django.http import Http404 from django.shortcuts import get_object_or_404 from django.utils.decorators import method_decorator @@ -174,6 +174,8 @@ class SummerSchoolView(TemplateView): context = super().get_context_data() is_previous = 'is_previous' in self.request.GET date_now = now().date() + yesterday = date_now - timedelta(days=1) + month_start = date_now.replace(day=1) now_time = now() try: school_schedule = SchoolSchedule.objects.get(weekday=now_time.isoweekday()) @@ -186,7 +188,24 @@ class SummerSchoolView(TemplateView): (end_at + timedelta(hours=1)).time() >= now_time.time() and school_schedule.current_live_lesson() ) + + school_schedules = SchoolSchedule.objects.all() + school_schedules_dict = {ss.weekday: ss for ss in school_schedules} + school_schedules_dict[0] = school_schedules_dict.get(7) if self.request.user.is_authenticated: + all_schedules_purchased = SchoolPayment.objects.filter( + user=self.request.user, + status__in=[ + Pingback.PINGBACK_TYPE_REGULAR, + Pingback.PINGBACK_TYPE_GOODWILL, + Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED, + ], + date_start__range=[month_start, date_now], + ).annotate( + joined_weekdays=Func(F('weekdays'), function='unnest',) + ).distinct().values_list('joined_weekdays', flat=True) + all_schedules_purchased = map(lambda x: 1 if x == 7 else x+1, all_schedules_purchased) + school_payment = SchoolPayment.objects.filter( user=self.request.user, status__in=[ @@ -221,12 +240,14 @@ class SummerSchoolView(TemplateView): school_payment_exists_future = False school_purchased_future = False school_schedules_purchased = [] - if school_payment_exists and is_previous: + if all_schedules_purchased and is_previous: live_lessons = LiveLesson.objects.filter( - date__gte=school_payment.last().date_start, - date__range=[(now_time - timedelta(days=8)).date(), (now_time - timedelta(days=1)).date()], + date__range=[month_start, yesterday], deactivated_at__isnull=True, - ) + date__week_day__in=all_schedules_purchased, + ).order_by('-date') + for ll in live_lessons: + ll.school_schedule = school_schedules_dict.get(ll.date.isoweekday()) live_lessons_exists = live_lessons.exists() else: live_lessons = None @@ -240,7 +261,7 @@ class SummerSchoolView(TemplateView): 'is_purchased': school_payment_exists, 'is_purchased_future': school_payment_exists_future, 'min_school_price': SchoolSchedule.objects.aggregate(Min('month_price'))['month_price__min'], - 'school_schedules': SchoolSchedule.objects.all(), + 'school_schedules': school_schedules, 'school_schedules_purchased': school_schedules_purchased, 'school_purchased_future': school_purchased_future, 'subscription_ends': school_payment.filter(add_days=False).first().date_end if school_payment_exists else None, From a4c9fc608cd14e75458df9127f5bd08c65e080a7 Mon Sep 17 00:00:00 2001 From: gzbender Date: Wed, 25 Jul 2018 16:00:35 +0500 Subject: [PATCH 06/30] =?UTF-8?q?fix=20in=20LIL-597=20=D0=9F=D0=BE=D0=BA?= =?UTF-8?q?=D0=B0=D0=B7=D1=8B=D0=B2=D0=B0=D1=82=D1=8C=20=D0=B7=D0=B0=D0=BF?= =?UTF-8?q?=D0=B8=D1=81=D0=B8=20=D1=83=D1=80=D0=BE=D0=BA=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=B7=D0=B0=20=D0=B2=D1=81=D1=91=20=D0=B2=D1=80=D0=B5=D0=BC?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/school/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/school/views.py b/apps/school/views.py index 3c1b478a..982a2430 100644 --- a/apps/school/views.py +++ b/apps/school/views.py @@ -192,6 +192,7 @@ class SummerSchoolView(TemplateView): school_schedules = SchoolSchedule.objects.all() school_schedules_dict = {ss.weekday: ss for ss in school_schedules} school_schedules_dict[0] = school_schedules_dict.get(7) + all_schedules_purchased = [] if self.request.user.is_authenticated: all_schedules_purchased = SchoolPayment.objects.filter( user=self.request.user, From 1c20b3c328a25b9f5e694124da89e93cf6958755 Mon Sep 17 00:00:00 2001 From: gzbender Date: Wed, 25 Jul 2018 16:26:43 +0500 Subject: [PATCH 07/30] Fix LIL-560 --- apps/school/templates/blocks/schedule_item.html | 2 +- apps/school/templates/summer/schedule_purchased.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/school/templates/blocks/schedule_item.html b/apps/school/templates/blocks/schedule_item.html index 0cafb9f3..3895f575 100644 --- a/apps/school/templates/blocks/schedule_item.html +++ b/apps/school/templates/blocks/schedule_item.html @@ -28,7 +28,7 @@ {% endif %}
-
+
{% thumbnail live_lesson.cover.image "70x70" crop="center" as im %} diff --git a/apps/school/templates/summer/schedule_purchased.html b/apps/school/templates/summer/schedule_purchased.html index e320bb14..78faff49 100644 --- a/apps/school/templates/summer/schedule_purchased.html +++ b/apps/school/templates/summer/schedule_purchased.html @@ -41,7 +41,7 @@ {% if is_previous %} {% for live_lesson in live_lessons %} {% if live_lesson.school_schedule %} - {% include 'blocks/schedule_item.html' with school_schedule=school_schedule live_lesson=school_schedule.previous_live_lesson purchased=True %} + {% include 'blocks/schedule_item.html' with school_schedule=live_lesson.school_schedule live_lesson=live_lesson purchased=True %} {% endif %} {% endfor %} {% else %} From 5844d2877a08bde84568d58132fe14b0d3bf4dfa Mon Sep 17 00:00:00 2001 From: nikita Date: Fri, 27 Jul 2018 11:13:19 +0300 Subject: [PATCH 08/30] LIL-589 linebreak --- apps/course/templates/course/course_only_lessons.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/course/templates/course/course_only_lessons.html b/apps/course/templates/course/course_only_lessons.html index f0217bcf..fd0d489c 100644 --- a/apps/course/templates/course/course_only_lessons.html +++ b/apps/course/templates/course/course_only_lessons.html @@ -189,7 +189,7 @@
{% endif %} -
{{ lesson.short_description | truncatechars_html:800 | safe }}
+
{{ lesson.short_description | truncatechars_html:800 | safe | linebreaks }}
Перейти к уроку From e43e8901147cb562401fdfbafe0df6d529f24462 Mon Sep 17 00:00:00 2001 From: nikita Date: Fri, 27 Jul 2018 11:25:33 +0300 Subject: [PATCH 09/30] LIL-589 linebreaks --- apps/course/templates/course/content/imagetext.html | 2 +- apps/course/templates/course/course.html | 4 ++-- apps/school/templates/school/livelessons_list.html | 2 +- web/src/components/CourseRedactor.vue | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/course/templates/course/content/imagetext.html b/apps/course/templates/course/content/imagetext.html index 6385391e..80c6797a 100644 --- a/apps/course/templates/course/content/imagetext.html +++ b/apps/course/templates/course/content/imagetext.html @@ -9,7 +9,7 @@
-
{{ content.txt | safe }}
+
{{ content.txt | safe | linebreaks }}
diff --git a/apps/course/templates/course/course.html b/apps/course/templates/course/course.html index f5ba90af..15a54c12 100644 --- a/apps/course/templates/course/course.html +++ b/apps/course/templates/course/course.html @@ -70,7 +70,7 @@
{{ course.title }}
-
{{ course.short_description }}
+
{{ course.short_description | linebreaks }}
{% if course.author.photo %} @@ -270,7 +270,7 @@
{{ course.title }}
-
{{ course.short_description }}
+
{{ course.short_description | linebreaks }}
{% if course.author.photo %} diff --git a/apps/school/templates/school/livelessons_list.html b/apps/school/templates/school/livelessons_list.html index b02e4f8d..b2099cbe 100644 --- a/apps/school/templates/school/livelessons_list.html +++ b/apps/school/templates/school/livelessons_list.html @@ -24,7 +24,7 @@
{{ livelesson.date }} // {{ livelesson.title }}
-
{{ livelesson.short_description }}
+
{{ livelesson.short_description | linebreaks }}
{% endfor %} diff --git a/web/src/components/CourseRedactor.vue b/web/src/components/CourseRedactor.vue index f4291156..28e10243 100644 --- a/web/src/components/CourseRedactor.vue +++ b/web/src/components/CourseRedactor.vue @@ -236,7 +236,7 @@
{{ lesson.title }}
-
{{ lesson.short_description }}
+
{{ lesson.short_description | linebreaks }}
From 0c71c73172ad74ada544eafdad5c97db67dd3908 Mon Sep 17 00:00:00 2001 From: gzbender Date: Tue, 31 Jul 2018 22:12:55 +0500 Subject: [PATCH 10/30] =?UTF-8?q?LIL-603=20=D0=97=D0=B0=D0=BA=D1=80=D1=8B?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D0=BA=D1=83=D0=BF=D0=B8=D1=82=D1=8C=20?= =?UTF-8?q?=D0=BB=D0=B0=D0=B3=D0=B5=D1=80=D1=8C=20=D1=81=2031.07?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/summer/schedule_purchased.html | 3 +++ apps/school/views.py | 8 ++++++- project/context_processors.py | 21 +++++++++++++++++++ project/settings.py | 1 + project/templates/blocks/about.html | 2 ++ project/templates/blocks/header.html | 4 +++- project/templates/blocks/promo.html | 8 +++++-- 7 files changed, 43 insertions(+), 4 deletions(-) diff --git a/apps/school/templates/summer/schedule_purchased.html b/apps/school/templates/summer/schedule_purchased.html index 78faff49..4bd18774 100644 --- a/apps/school/templates/summer/schedule_purchased.html +++ b/apps/school/templates/summer/schedule_purchased.html @@ -25,12 +25,15 @@ {% else %}
Новые уроки
{% endif %} + + {% comment %}
запись уроков новые уроки + {% endcomment %} {% endif %}
diff --git a/apps/school/views.py b/apps/school/views.py index 982a2430..ec7f9233 100644 --- a/apps/school/views.py +++ b/apps/school/views.py @@ -6,7 +6,7 @@ from django.contrib.auth.decorators import login_required, user_passes_test from django.db.utils import IntegrityError from django.db.models import Min, F, Func, Q, Value from django.http import Http404 -from django.shortcuts import get_object_or_404 +from django.shortcuts import get_object_or_404, redirect from django.utils.decorators import method_decorator from django.utils.timezone import now from django.views.generic import ListView, UpdateView, TemplateView, DetailView @@ -170,6 +170,12 @@ class SchoolView(TemplateView): class SummerSchoolView(TemplateView): template_name = 'school/summer_school.html' + def get(self, request, *args, **kwargs): + context = self.get_context_data(**kwargs) + if not context.get('is_purchased'): + return redirect('/') + return self.render_to_response(context) + def get_context_data(self): context = super().get_context_data() is_previous = 'is_previous' in self.request.GET diff --git a/project/context_processors.py b/project/context_processors.py index 0e7e9d32..e4788dc4 100644 --- a/project/context_processors.py +++ b/project/context_processors.py @@ -1,5 +1,9 @@ +from django.utils.timezone import now +from paymentwall.pingback import Pingback + from apps.config.models import Config from apps.content.models import Baner +from apps.payment.models import SchoolPayment def config(request): @@ -8,3 +12,20 @@ def config(request): def baner(request): return {'baner': Baner.objects.filter(use=True).first()} + + +def is_summer_school_purchased(request): + if request.user.is_authenticated: + n = now().date() + school_payment = SchoolPayment.objects.filter( + user=request.user, + status__in=[ + Pingback.PINGBACK_TYPE_REGULAR, + Pingback.PINGBACK_TYPE_GOODWILL, + Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED, + ], + date_start__lte=n, + date_end__gte=n + ) + return {'is_summer_school_purchased': school_payment.exists()} + return {'is_summer_school_purchased': False} diff --git a/project/settings.py b/project/settings.py index 9323745c..1aecdb8c 100644 --- a/project/settings.py +++ b/project/settings.py @@ -93,6 +93,7 @@ TEMPLATES = [ 'context_processors': [ 'project.context_processors.config', 'project.context_processors.baner', + 'project.context_processors.is_summer_school_purchased', 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', diff --git a/project/templates/blocks/about.html b/project/templates/blocks/about.html index 8deec906..5fefa4ca 100644 --- a/project/templates/blocks/about.html +++ b/project/templates/blocks/about.html @@ -44,6 +44,7 @@
+ {% comment %} {% if not is_purchased and not is_purchased_future %} {% endif %} + {% endcomment %}
diff --git a/project/templates/blocks/header.html b/project/templates/blocks/header.html index ae4107d1..5be001d8 100644 --- a/project/templates/blocks/header.html +++ b/project/templates/blocks/header.html @@ -25,13 +25,15 @@