from django.template import RequestContext from django.shortcuts import render_to_response # from django.utils.translation import ugettext as _ from django.contrib.auth.decorators import login_required from courses.models import UserProfile, Course @login_required def courses_main(request): """ This is the main view presented to users after login. Instructors will be shown a link to view grades and student progress, students will be shown their current progress in all of the games that they have records in. """ template = 'courses/courses_main.html' c = {} new_profile = None is_student = None try: profile = request.user.get_profile() except UserProfile.DoesNotExist: profile = UserProfile.objects.create(user=request.user) new_profile = True summary = False if not request.user.is_staff: summary = profile.usergradesummary_set.all() if summary.count() == 0: new_profile = True is_student = True c = { 'user': request.user, 'profile': profile, 'new_profile': new_profile, 'is_student': is_student, 'summaries': summary, 'courses': request.user.studentships.all() } return render_to_response(template, c, context_instance=RequestContext(request))