Ejemplo n.º 1
0
def student(request, error_message=None):
    user_name = request.user
    if not request.user.is_authenticated():
        return HttpResponseRedirect(reverse('login')) # Send to CAS
    if Student.objects.filter(netID=user_name).count() != 1:
        info = gdi(user_name) # get personal info from LDAP
        s = Student(netID=user_name, first_name=info.get('givenName'),
                    last_name=info.get('sn')) # need to include other fields, too!
        s.save()
        # Add the special event
        c = Course.objects.get(courseID='S1499')
        Registration(course=c, student=s).save()
    student = Student.objects.get(netID=user_name)
    identity = (student.netID, student.first_name, student.last_name)
    my_registrations = student.registration_set.all()
    my_courses = student.course_set.all()
    table = CourseTable(my_courses)
    RequestConfig(request).configure(table)
    # Only active courses
    active_courses = Course.objects.filter(cancelled=False)
    c_ids = [o.courseID for o in active_courses if not o.is_full()] # can remove
    # Only non-full active courses
    avail_courses = active_courses.filter(courseID__in=c_ids)       # can remove
    context = {
        'identity' : identity,
        'my_registrations' : my_registrations,
        'active_courses' : avail_courses, # or active_courses
        'error_message' : error_message,
        'table' : table,
    }
    return render(request, 'wintersession/student.html', context)
Ejemplo n.º 2
0
def student(request, error_message=None):
    user_name = request.user
    if not request.user.is_authenticated():
        return HttpResponseRedirect(reverse('login'))  # Send to CAS
    if Student.objects.filter(netID=user_name).count() != 1:
        info = gdi(user_name)  # get personal info from LDAP
        s = Student(
            netID=user_name,
            first_name=info.get('givenName'),
            last_name=info.get('sn'))  # need to include other fields, too!
        s.save()
        # Add the special event
        c = Course.objects.get(courseID='S1499')
        Registration(course=c, student=s).save()
    student = Student.objects.get(netID=user_name)
    identity = (student.netID, student.first_name, student.last_name)
    my_registrations = student.registration_set.all()
    my_courses = student.course_set.all()
    table = CourseTable(my_courses)
    RequestConfig(request).configure(table)
    # Only active courses
    active_courses = Course.objects.filter(cancelled=False)
    c_ids = [o.courseID for o in active_courses
             if not o.is_full()]  # can remove
    # Only non-full active courses
    avail_courses = active_courses.filter(courseID__in=c_ids)  # can remove
    context = {
        'identity': identity,
        'my_registrations': my_registrations,
        'active_courses': avail_courses,  # or active_courses
        'error_message': error_message,
        'table': table,
    }
    return render(request, 'wintersession/student.html', context)
Ejemplo n.º 3
0
def register(request):
    user_name = request.user
    if not request.user.is_authenticated():
        return HttpResponseRedirect(reverse('login')) # Send to CAS
    if Student.objects.filter(netID=user_name).count() != 1:
        info = gdi(user_name) # get personal info from LDAP
        s = Student(netID=user_name, first_name=info.get('givenName'),
                    last_name=info.get('sn')) # need to include other fields, too!
        s.save()
        # Add the special event
        c = Course.objects.get(courseID='S1499')
        Registration(course=c, student=s).save()
    context = {
        'REGSTART': REGSTART,
        'REGEND': REGEND
    }
    return render(request, 'wintersession/register.html', context)