From c8018451e4826f1fc9cd3eecddd3f2e43bf19077 Mon Sep 17 00:00:00 2001 From: gzbender Date: Fri, 8 Feb 2019 03:19:38 +0500 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D1=82=D1=8C=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D0=B5=20"=D0=BF=D1=80=D0=BE=D0=B4=D0=BE?= =?UTF-8?q?=D0=BB=D0=B6=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B4=D0=BE=D1=81=D1=82=D1=83=D0=BF=D0=B0"=20?= =?UTF-8?q?=D1=83=20=D0=BA=D1=83=D1=80=D1=81=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/course/templates/course/course.html | 81 ++++++++++++------- .../templates/course/course_only_lessons.html | 48 +++++++---- apps/payment/views.py | 5 +- web/src/components/CourseRedactor.vue | 1 + 4 files changed, 91 insertions(+), 44 deletions(-) diff --git a/apps/course/templates/course/course.html b/apps/course/templates/course/course.html index ca13e0f3..fb9c351f 100644 --- a/apps/course/templates/course/course.html +++ b/apps/course/templates/course/course.html @@ -126,7 +126,7 @@ -
{{ course.duration | rupluralize:"день,дня,дней" }}
+
{{ course.access_duration | rupluralize:"день,дня,дней" }}
{% endif %}
@@ -317,37 +317,64 @@
- -
- - - -
-
{{ course.duration | rupluralize:"день,дня,дней" }}
-
{% if course.price %} -
-
- - - + {% if paid %} + +
+ + + +
+
{{ access_duration | rupluralize:"день,дня,дней" }}
+
+ {% else %} + +
+ + + +
+
{{ course.access_duration | rupluralize:"день,дня,дней" }}
+
+ {% endif %} +
+
+ + + +
+
+ {% if can_buy_again %} + {{ course.price|floatformat:"-2" }}₽ + {% else %} + {% if course.old_price %}{{ course.old_price|floatformat:"-2" }}₽{% endif %} + {% endif %} + {{ course_price|floatformat:"-2" }}₽ +
-
{{ course.price|floatformat:"-2" }}₽
-
{% endif %}
- {% if course.author != request.user and not paid and course.price %} - + {% if pending %}ОЖИДАЕТСЯ ПОДТВЕРЖДЕНИЕ ОПЛАТЫ{% else %} + {% if paid and can_buy_again %}ПРОДЛИТЬ ДОСТУП{% else %}КУПИТЬ КУРС{% endif %} + {% endif %} + {% if not paid %} + Подарить другу {% endif %} - >{% if pending %}ОЖИДАЕТСЯ ПОДТВЕРЖДЕНИЕ ОПЛАТЫ{% else %}КУПИТЬ КУРС{% endif %} +
+ {% endif %} {% endif %}
diff --git a/apps/course/templates/course/course_only_lessons.html b/apps/course/templates/course/course_only_lessons.html index 58a3e1a4..5942dd74 100644 --- a/apps/course/templates/course/course_only_lessons.html +++ b/apps/course/templates/course/course_only_lessons.html @@ -95,23 +95,41 @@
- -
- - - -
-
{{ course.duration | rupluralize:"день,дня,дней" }}
-
{% if course.price %} -
-
- - - + {% if paid %} + +
+ + + +
+
{{ access_duration | rupluralize:"день,дня,дней" }}
+
+ {% else %} + +
+ + + +
+
{{ course.access_duration | rupluralize:"день,дня,дней" }}
+
+ {% endif %} +
+
+ + + +
+
+ {% if can_buy_again %} + {{ course.price|floatformat:"-2" }}₽ + {% else %} + {% if course.old_price %}{{ course.old_price|floatformat:"-2" }}₽{% endif %} + {% endif %} + {{ course_price|floatformat:"-2" }}₽ +
-
{{ course.price|floatformat:"-2" }}₽
-
{% endif %}
diff --git a/apps/payment/views.py b/apps/payment/views.py index 31a0f389..f1399ff2 100644 --- a/apps/payment/views.py +++ b/apps/payment/views.py @@ -69,8 +69,9 @@ class CourseBuyView(TemplateView): return redirect(reverse_lazy('course', args=[course.id])) prev_payment = CoursePayment.objects.filter(user=request.user, course=course, status__in=Payment.PW_PAID_STATUSES).order_by('-access_expire').first() - access_expire = prev_payment.access_expire + timedelta(days=course.access_duration) if prev_payment \ - else now().date() + timedelta(days=course.access_duration - 1) + access_duration = course.access_duration or 90 + access_expire = prev_payment.access_expire + timedelta(days=access_duration) if prev_payment \ + else now().date() + timedelta(days=access_duration - 1) course_payment = CoursePayment.objects.create( user=request.user, course=course, diff --git a/web/src/components/CourseRedactor.vue b/web/src/components/CourseRedactor.vue index bf4bc7d7..3e319cea 100644 --- a/web/src/components/CourseRedactor.vue +++ b/web/src/components/CourseRedactor.vue @@ -424,6 +424,7 @@ required }, access_duration: { + required: this.course.is_paid ? required : false, numeric, minValue: minValue(1) },