From e9b96870085f42cea8706cb72d3132177eda23af Mon Sep 17 00:00:00 2001 From: gzbender Date: Wed, 27 Jun 2018 16:30:44 +0500 Subject: [PATCH] =?UTF-8?q?LIL-516=20=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D1=82=D1=8C=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BA=D0=BB=D1=8E?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B5=D0=B6=D0=B4=D1=83?= =?UTF-8?q?=20=D1=83=D1=80=D0=BE=D0=BA=D0=B0=D0=BC=D0=B8=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B5=20=D1=83=D1=80?= =?UTF-8?q?=D0=BE=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/course/templates/course/lesson.html | 8 ++++---- apps/course/views.py | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/course/templates/course/lesson.html b/apps/course/templates/course/lesson.html index 6c9511ae..c9f98e01 100644 --- a/apps/course/templates/course/lesson.html +++ b/apps/course/templates/course/lesson.html @@ -14,8 +14,8 @@
Вернуться к списку уроков
- {% comment %} {% if next_lesson %} - + {% if next_lesson %} +
Перейти к следующему уроку
@@ -23,7 +23,7 @@
- {% endif %} {% endcomment %} + {% endif %}
{{ lesson.title }}
@@ -32,7 +32,7 @@ {% if lesson.cover %} {% else %} - + {% endif %} diff --git a/apps/course/views.py b/apps/course/views.py index 90957d68..60b7e308 100644 --- a/apps/course/views.py +++ b/apps/course/views.py @@ -299,7 +299,9 @@ class LessonView(DetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['next'] = self.request.GET.get('next', None) - context['next_lesson'] = self.request.GET.get('next_lesson', None) + lessons = list(self.object.course.lessons.values_list('id', flat=True)) + index = lessons.index(self.object.id) + context['next_lesson'] = lessons[index + 1] if index < len(lessons) - 1 else None return context