Esempio n. 1
0
def ajax_get_course_by_id(request):
    try:
        id = int(request.POST['id'])
        c = Course.shortcut(id)
        if c != None:
            return json_response(c.to_json())
        
    except:
        pass
    return json_response({'error': 'BAD'})
Esempio n. 2
0
def ajax_get_courses(request):
    try:
        json_courses = simplejson.loads(request.POST['courses'])
        courses = []
        for c in json_courses:
            section = c['section']
            number = int(c['number'])
            courses.append(Course.objects.get(section__abbreviation__iexact=section,
                                              number=number).to_json())
        return json_response({'courses': courses})
    
    except Course.DoesNotExist:
        return json_response({'error': 'Could not find course'})

    except ValueError:
        return json_response({'error': 'Invalid arguments'})
Esempio n. 3
0
def edit_degree(request, id):
    try:
        degree = Degree.objects.get(pk=id)
    except Degree.DoesNotExist:
        print 'DEGREE DOES NOT EXIST'
        raise Http404
        
    if request.method == 'POST':
        return json_response(degree.xml_to_json())
    else:
        return render_to(request, 'administrator/edit_degree.html', {})
Esempio n. 4
0
def login_user(request):
    username, password = extract(request.POST, 'username', 'password')
    user = authenticate(username=username, password=password)
    error = None
    if user is not None:
        if settings.REQUIRE_ACTIVATION and not user.active:
            # user created, but didn't finish email activation
            error = 'This account has not been activated, please see your email or click <here>.'
        else:
            # success
            login(request, user)
    else:
        error = 'Username/password combination was incorrect.'
        
    resp = None
    if error is not None:
        resp = {'status': 'error',
                'message': error}
    else:
        # CHANGE REDIRECT BASED ON USER'S GROUP
        resp = {'status': 'okay',
                'redirect': '/student/courses/manage/'}
        
    return json_response(resp)
Esempio n. 5
0
def ajax_sections(request):
    return json_response([section.to_json() for section in Section.objects.all()])
Esempio n. 6
0
def courses_in_section(request, id):
    courses = Course.objects.filter(section=int(id))
    return json_response([c.to_json() for c in courses.all()])
Esempio n. 7
0
def degrees_in_college(request, id):
    degrees = Degree.objects.filter(college=int(id))
    return json_response([d.to_json() for d in degrees.all()])
Esempio n. 8
0
def get_courses(request, section_id):
    courses = Course.objects.filter(section__id=section_id);
    return json_response([c.to_json() for c in courses])