def profile(request, user_pk): user_obj = get_object_or_404(User, pk=user_pk) # Задачи all_cat = Category.objects.all() categories = [] for category in all_cat: if category.parent: continue categories.append([category, to_list(category.get_children(), 3)]) solved_progress = int(float(len(user_obj.userprogress.problems_solved_problems.all())) / float(len(Problem.objects.all())) * 100) #Уроки themes = [[i + 5, Theme.objects.filter(klass=(i+5))] for i in range(7)] #Испытания chall_cat = [cb.category for cb in user_obj.userprogress.challenge_best.all()] challenge_categories = {'kenguru': Category.objects.get(slug='kenguru').get_children(), 'olimpiada': Category.objects.get(slug='olimpiada').get_children()} #Избранное favorite_problems = user_obj.favorite_problems.all() #Достижения achievments = Achievment.objects.all() return {'categories': categories, 'user_obj': user_obj, 'solved_progress': solved_progress, 'pr_count': len(Problem.objects.all()), 'themes': themes, 'chall_cat': chall_cat, 'favorites': favorite_problems, 'achievments': achievments, 'challenge_categories': challenge_categories}
def tables(context, objects): rows = to_list(objects.order_by('number'), 10) return {'rows': rows, 'user': context['user']}