Merge branch 'feature/LIL-712' into 'master'

LIL-712 Формирование красивых ссылок в уроках и школе

Closes LIL-712

See merge request lilschool/site!238
remotes/origin/course_old_price
Danil 7 years ago
commit b55caec6b7
  1. 2
      apps/course/models.py
  2. 4
      apps/course/templates/course/_items.html
  3. 2
      apps/course/templates/course/course.html
  4. 2
      apps/course/templates/course/course_only_lessons.html
  5. 2
      apps/payment/templates/payment/course_payment_success.html
  6. 2
      apps/payment/templates/payment/payment_success.html
  7. 6
      apps/school/models.py
  8. 2
      apps/school/templates/blocks/open_lesson.html
  9. 2
      apps/school/templates/school/livelessons_list.html
  10. 2
      apps/school/templates/summer/open_lesson.html
  11. 1
      apps/school/urls.py
  12. 7
      apps/school/views.py

@ -132,7 +132,7 @@ class Course(BaseModel, DeactivatedMixin):
return self.get_absolute_url()
def get_absolute_url(self):
return reverse_lazy('course', args=[self.id])
return reverse_lazy('course', args=[self.slug or self.id])
@property
def is_free(self):

@ -7,7 +7,7 @@
data-course data-course-id={{ course.id }}
{% if course.is_deferred_start and course.status == 2 %}data-future-course data-future-course-time={{ course.deferred_start_at.timestamp }}{% endif %}
>
<a class="courses__preview" href="{% if course.status <= 1 %}{% url 'course_edit' course.id %}{% else %}{% url 'course' course.id %}?next={{ request.get_full_path }}{% endif %}">
<a class="courses__preview" href="{% if course.status <= 1 %}{% url 'course_edit' course.id %}{% else %}{{ course.url }}{% endif %}">
{% thumbnail course.cover.image "300x200" crop="center" as im %}
<img class="courses__pic" src="{{ im.url }}" width="{{ im.width }}" />
{% empty %}
@ -53,7 +53,7 @@
<div class="courses__price">{{ course.price|floatformat:"-2" }}₽</div>
{% endif %}
</div>
<a class="courses__title" href="{% url 'course' course.id %}?next={{ request.get_full_path }}">{{ course.title }}</a>
<a class="courses__title" href="{{ course.url }}">{{ course.title }}</a>
<div class="courses__content">{{ course.short_description | safe | linebreaks | truncatechars_html:300 }}
</div>
<div class="courses__user user">

@ -142,7 +142,7 @@
</div>
</div>
<div class="course__actions">
<a href="{% url 'course' course.id %}" class="course__action btn btn_lg{% if not only_lessons %} btn_stroke{% else %} btn_gray{% endif %}">Описание курса</a>
<a href="{{ course.url }}" class="course__action btn btn_lg{% if not only_lessons %} btn_stroke{% else %} btn_gray{% endif %}">Описание курса</a>
{% if request.user.is_authenticated %}
{% if course.author == request.user and request.user.role >= request.user.AUTHOR_ROLE %}
<a

@ -132,7 +132,7 @@
</div>
</div>
<div class="course__actions">
<a href="{% url 'course' course.id %}" class="course__action btn btn_lg{% if not only_lessons %} btn_stroke{% else %} btn_gray{% endif %}">Описание курса</a>
<a href="{{ course.url }}" class="course__action btn btn_lg{% if not only_lessons %} btn_stroke{% else %} btn_gray{% endif %}">Описание курса</a>
{% if course.author == request.user and request.user.role >= request.user.AUTHOR_ROLE %}
<a
href="{% url 'course-only-lessons' course.id %}"

@ -4,7 +4,7 @@
<div class="done">
<div class="done__title title">Вы успешно приобрели курс!</div>
<div class="done__foot">
<a class="done__btn btn btn_md btn_stroke" href="{% url 'course' course.id %}">ПЕРЕЙТИ К КУРСУ</a>
<a class="done__btn btn btn_md btn_stroke" href="{{ course.url }}">ПЕРЕЙТИ К КУРСУ</a>
</div>
</div>
</div>

@ -11,7 +11,7 @@
{% if course %}
<div class="done__title title">Вы успешно приобрели курс!</div>
<div class="done__foot">
<a class="done__btn btn btn_md btn_stroke" href="{% url 'course' course.id %}">ПЕРЕЙТИ К КУРСУ</a>
<a class="done__btn btn btn_md btn_stroke" href="{{ course.url }}">ПЕРЕЙТИ К КУРСУ</a>
</div>
{% endif %}
{% if gift_certificate %}

@ -142,8 +142,12 @@ class LiveLesson(BaseModel, DeactivatedMixin):
self.date = (datetime.combine(self.date, now().time()) + timedelta(days=1)).date()
super().save(*args, **kwargs)
@property
def url(self):
return self.get_absolute_url()
def get_absolute_url(self):
return reverse_lazy('school:lesson-detail', args=[str(self.id)])
return reverse_lazy('school:lesson-detail', args=[self.date.strftime('%d-%m-%y')])
def stream_index(self):
return self.stream.split('/')[-1]

@ -1,4 +1,4 @@
<a
class="timing__btn btn btn_light"
href="{% url 'school:lesson-detail' live_lesson.id %}"
href="{{ live_lesson.url }}"
>смотреть урок</a>

@ -11,7 +11,7 @@
{% for livelesson in livelesson_list %}
<div class="lessons__item">
<div class="lessons__actions lessons__actions__no-hover">
<a target="_blank" class="lessons__action" href="{% url 'school:lesson-detail' livelesson.id %}">
<a target="_blank" class="lessons__action" href="{{ live_lesson.url }}">
<svg class="icon icon-eye">
<use xlink:href="{% static 'img/sprite.svg' %}#icon-eye"></use>
</svg>

@ -1,4 +1,4 @@
<a
class="timing__btn btn btn_light"
href="{% url 'school:lesson-detail' live_lesson.id %}"
href="{{ live_lesson.url }}"
>подробнее</a>

@ -13,4 +13,5 @@ urlpatterns = [
path('lessons/create', LiveLessonEditView.as_view(), name='lessons-create'),
path('lessons/<int:pk>/edit', LiveLessonEditView.as_view(), name='lessons-edit'),
path('lessons/<int:pk>/', LiveLessonsDetailView.as_view(), name='lesson-detail'),
path('<str:lesson_date>', LiveLessonsDetailView.as_view(), name='lesson-detail'),
]

@ -61,8 +61,11 @@ class LiveLessonsDetailView(DetailView):
model = LiveLesson
template_name = 'school/livelesson_detail.html'
def get(self, request, pk=None):
self.object = self.get_object()
def get(self, request, pk=None, lesson_date=None):
if pk:
self.object = self.get_object()
if lesson_date:
self.object = LiveLesson.objects.get(date=datetime.strptime(lesson_date, '%d-%m-%y'))
if request.user.is_authenticated:
is_purchased = SchoolPayment.objects.filter(
user=request.user,

Loading…
Cancel
Save