Commit f7410615f1a900aa6849065570b65634df303b83
1 parent
9d81616c
Exists in
master
and in
5 other branches
Fixed bug when listing categories, now lists by category name correctly [Issue:#228]
Showing
1 changed file
with
5 additions
and
3 deletions
Show diff stats
courses/views.py
... | ... | @@ -445,17 +445,19 @@ class IndexCatView(LoginRequiredMixin, generic.ListView): |
445 | 445 | |
446 | 446 | login_url = reverse_lazy("core:home") |
447 | 447 | redirect_field_name = 'next' |
448 | - queryset = CourseCategory.objects.all() | |
448 | + queryset = sorted(CourseCategory.objects.all(),key = lambda x:x.name) | |
449 | 449 | template_name = 'category/index.html' |
450 | 450 | context_object_name = 'categories' |
451 | 451 | paginate_by = 5 |
452 | - | |
452 | + | |
453 | + ''' | |
453 | 454 | def get_context_data(self, **kwargs): |
454 | 455 | context = super(IndexCatView, self).get_context_data(**kwargs) |
455 | 456 | list_cat = CourseCategory.objects.filter(course_category = True).order_by('name') |
456 | 457 | paginator = Paginator(list_cat, self.paginate_by) |
457 | 458 | page = self.request.GET.get('page') |
458 | 459 | |
460 | + print(list_cat) | |
459 | 461 | try: |
460 | 462 | list_cat = paginator.page(page) |
461 | 463 | except PageNotAnInteger: |
... | ... | @@ -466,7 +468,7 @@ class IndexCatView(LoginRequiredMixin, generic.ListView): |
466 | 468 | context['list_cat'] = list_cat |
467 | 469 | |
468 | 470 | return context |
469 | - | |
471 | + ''' | |
470 | 472 | class CreateCatView(LoginRequiredMixin, HasRoleMixin, generic.edit.CreateView): |
471 | 473 | |
472 | 474 | allowed_roles = ['professor', 'system_admin'] | ... | ... |