def get(self, request, org_id): org = CourseOrg.objects.filter(id=org_id).first() return render( request, 'org-detail-desc.html', { 'course_org': org, 'current_page': 'desc', 'has_star': has_star(request.user, fav_id=org_id, fav_type=3) })
def get(self, request, course_id): course = Course.objects.filter(id=course_id).first() # 点击数加1 course.hits += 1 course.save() # 收藏判断 is_course_star = has_star(request.user, course.id, 1) is_org_star = has_star(request.user, course.org_id, 3) relate_course = None if course.tag: relate_course = [i for i in Course.objects.filter(tag=course.tag) if i.id != course_id][0] return render(request, 'course-detail.html', { 'course': course, 'relate_course': relate_course, 'is_course_star': is_course_star, 'is_org_star': is_org_star })
def get(self, request, org_id): org = CourseOrg.objects.filter(id=org_id).first() all_teachers = org.teacher_set.all() return render( request, 'org-detail-teachers.html', { 'course_org': org, 'all_teachers': all_teachers, 'current_page': 'teacher', 'has_star': has_star(request.user, fav_id=org_id, fav_type=3) })
def get(self, request, teacher_id): teacher = Teacher.objects.filter(id=teacher_id).first() # 查询是否已收藏 has_teacher_star = has_star(request.user, fav_id=teacher_id, fav_type=2) has_org_star = has_star(request.user, fav_id=teacher.organization_id, fav_type=3) # 讲师排行榜,根据点击数进行排序 hot_teachers = Teacher.objects.all().order_by('-hits')[:3] return render( request, 'teacher-detail.html', { "teacher": teacher, 'hot_teachers': hot_teachers, 'has_teacher_star': has_teacher_star, 'has_org_star': has_org_star, })
def get(self, request, org_id): # 查询机构 org = CourseOrg.objects.filter(id=org_id).first() # 点击数加1 org.hits += 1 org.save() # 机构首页课程, 使用机构进行反向查询 all_courses = org.course_set.all()[:3] # 显示3个教师 all_teachers = org.teacher_set.all()[:3] return render( request, 'org-detail-homepage.html', { 'course_org': org, 'all_courses': all_courses, 'all_teachers': all_teachers, 'current_page': 'home', # 是否已收藏 'has_star': has_star(request.user, fav_id=org_id, fav_type=3) })