def index(request): """Index page; displays a list of courses available to the user Uses the template courses/index.html. """ ctx = {} ctx["courses"] = Course.get_courses(request.user); # Check if the user needs to change their password if request.user.extra.password_forced and not settings.USE_REMOTE_USER: return HttpResponseRedirect(u"{}?forced=1".format(reverse("users:edit"))) return render(request, "courses/index.html", ctx)
def course(request, course): """Course page; displays a description and list of lessons that the user can see Uses the template courses/course.html. """ ctx = {} ctx["all_courses"] = Course.get_courses(request.user) ctx["course"] = get_object_or_404(Course, slug=course) ctx["lessons"] = [\ (l, l.complete_states(request.user))\ for l in filter(lambda l : l.can_see(request.user), ctx["course"].lessons.all()) ] if not ctx["course"].can_see(request.user): raise Http404 return render(request, "courses/course.html", ctx)
def index(request): """Index page, simply render a template (staff/index.html) with all the courses""" ctx = {} ctx["courses"] = Course.get_courses(request.user) return render(request, "staff/index.html", ctx)