Merge branch 'master' of gitlab.com:lilcity/backend into feature/drawing-camp

remotes/origin/hotfix/delete-image-error-30-05-19
gzbender 7 years ago
commit 1f08e948ff
  1. 1
      apps/course/filters.py
  2. 2
      apps/course/templates/course/inclusion/category_menu_items.html
  3. 5
      apps/course/views.py
  4. 10
      web/src/js/modules/courses.js

@ -5,6 +5,7 @@ from .models import Course
class CourseFilter(django_filters.FilterSet):
category = django_filters.CharFilter(field_name='category')
cat = django_filters.CharFilter(field_name='category__title')
age = django_filters.ChoiceFilter(field_name='age', choices=Course.AGE_CHOICES)
class Meta:

@ -2,7 +2,7 @@
<div class="header__title">Все курсы</div>
</a>
{% for cat in category_items %}
<a class="header__link{% if category == cat.id %} active{% endif %}" data-category-name="{{ cat.title }}" href="{% url 'courses' %}?category={{ cat.id }}">
<a class="header__link{% if category == cat.id %} active{% endif %}" data-category-name="{{ cat.title }}" href="{% url 'courses' %}?cat={{ cat.title }}">
<div class="header__title">{{ cat.title }}</div>
</a>
{% endfor %}

@ -16,7 +16,7 @@ from django.utils.translation import gettext as _
from django.utils.timezone import now
from apps.payment.models import AuthorBalance, CoursePayment
from .models import Course, Like, Lesson, CourseComment, LessonComment
from .models import Course, Like, Lesson, CourseComment, LessonComment, Category
from .filters import CourseFilter
User = get_user_model()
@ -327,6 +327,9 @@ class CoursesView(ListView):
context['age_name'] = dict(Course.AGE_CHOICES).get(age, '')
else:
context['age_name'] = ''
if not context.get('category') and context.get('cat'):
context['category'] = Category.objects.filter(title__iexact=context.get('cat')[0]).values_list(
'id', flat=True)[:1]
if self.request.user.is_authenticated:
can_buy_again_courses = list(CoursePayment.objects.filter(user=self.request.user,
status__in=CoursePayment.PW_PAID_STATUSES,

@ -12,7 +12,7 @@ moment.locale('ru');
const history = createHistory();
$(document).ready(function () {
const categoryName = $('div.js-select-option.active[data-category-option]').attr('data-category-name');
let categoryName = $('div.js-select-option.active[data-category-option]').attr('data-category-name');
let category = $('div.js-select-option.active[data-category-option]').attr('data-category');
let age = $('div.js-select-option.active[data-age-option]').data('age');
let page = 1;
@ -39,10 +39,10 @@ $(document).ready(function () {
// Обработчик выбора категории
$('div.js-select-option[data-category-option]').on('click', function (e) {
e.preventDefault();
const categoryName = $(this).attr('data-category-name');
const cat = $(this).attr('data-category-name');
$('[data-category-name]').removeClass('active');
$(`[data-category-name='${categoryName}']`).addClass('active');
category = $(this).attr('data-category');
$(`[data-category-name='${cat}']`).addClass('active');
categoryName = $(this).attr('data-category-name');
page = 1;
loadCourses(true);
});
@ -116,7 +116,7 @@ $(document).ready(function () {
$('.courses__list').css('opacity', '0.9');
const buttonElement = $('.courses').find('button.load__btn');
let coursesUrl = window.LIL_STORE.urls.courses + '?' + $.param({
category,
cat: categoryName,
age,
});
if (page > 1) {

Loading…
Cancel
Save