LIL-607 Доступ к вкладке уроки работает неправильно

remotes/origin/feature/lil-592
gzbender 8 years ago
parent f90bc9d8ed
commit 22f314637b
  1. 4
      apps/course/templates/course/course.html
  2. 4
      apps/course/templates/course/course_only_lessons.html
  3. 13
      apps/course/views.py

@ -158,13 +158,13 @@
{% else %}
<a
class="course__action btn btn_lg{% if only_lessons %} btn_stroke{% else %} btn_gray{% endif %}"
{% if paid %}
{% if paid or not course.price %}
href="{% url 'course-only-lessons' course.id %}"
{% else %}
data-popup=".js-popup-course-lock"
{% endif %}
>УРОКИ
{% if not paid %}
{% if not paid and course.price %}
<svg class="icon icon-lock">
<use xlink:href="{% static 'img/sprite.svg' %}#icon-lock"></use>
</svg>

@ -154,10 +154,10 @@
</a>
{% else %}
<a
href="{% if paid %}{% url 'course-only-lessons' course.id %}{% else %}#{% endif %}"
href="{% if paid or not course.price %}{% url 'course-only-lessons' course.id %}{% else %}#{% endif %}"
class="course__action btn btn_lg{% if only_lessons %} btn_stroke{% else %} btn_gray{% endif %}"
>УРОКИ
{% if not paid %}
{% if not paid and course.price %}
<svg class="icon icon-lock">
<use xlink:href="{% static 'img/sprite.svg' %}#icon-lock"></use>
</svg>

@ -190,7 +190,8 @@ class CourseView(DetailView):
response = super().get(request, *args, **kwargs)
context = self.get_context_data()
if (not request.user.is_authenticated and self.object.status != Course.PUBLISHED) or\
(request.user.is_authenticated and request.user.role < User.AUTHOR_ROLE and self.object.author != request.user and self.only_lessons and not context['paid']):
(request.user.is_authenticated and request.user.role != User.ADMIN_ROLE and self.object.author != request.user
and self.only_lessons and self.object.price and not context['paid']):
raise Http404
return response
@ -292,7 +293,15 @@ class LessonView(DetailView):
def get(self, request, *args, **kwargs):
response = super().get(request, *args, **kwargs)
if (self.object.course.status != Course.PUBLISHED and not
paid = self.object.course.payments.filter(
user=self.request.user,
status__in=[
Pingback.PINGBACK_TYPE_REGULAR,
Pingback.PINGBACK_TYPE_GOODWILL,
Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED,
],
).exists()
if ((self.object.course.status != Course.PUBLISHED or (self.object.course.price and not paid)) and not
(request.user.role == User.ADMIN_ROLE or
self.object.course.author == request.user)):
raise Http404

Loading…
Cancel
Save