Ejemplo n.º 1
0
def index(request):
    # get all schools
    cursor = connection.cursor()
    cursor.execute("""
        SELECT DISTINCT(owning_school_clevel)
        FROM %s
        ORDER BY owning_school_clevel ASC
        """ % GradeResults._meta.db_table)
    schools = []
    for row in cursor.fetchall():
        schools.append(row[0])

    # get query date
    query_date = None
    rs = TableStatus.objects.all().filter(table=GradeResults._meta.db_table)
    for r in rs:
        query_date = r.timestamp
        break

    # configure template
    template = loader.get_template('al/index.html')
    context = applist.template_context('al')
    context['schools'] = schools
    context['query_date'] = query_date
    context['last_school'] = read_last_parameter(request.user, 'al.school', "")
    context['last_cutoff'] = read_last_parameter(request.user, 'al.cutoff', "")
    context['last_min_age'] = read_last_parameter(request.user, 'al.min_age',
                                                  MIN_AGE)
    context['last_min_gpa'] = read_last_parameter(request.user, 'al.min_gpa',
                                                  "")
    context['last_min_points'] = read_last_parameter(request.user,
                                                     'al.min_points',
                                                     MIN_CREDITS)
    return HttpResponse(template.render(context, request))
Ejemplo n.º 2
0
def search_by_faculty(request):
    # get parameters
    response, schools = get_variable_with_error(request, 'supervisors', 'school', as_list=True)
    if response is not None:
        return response

    # get year from earliest start date
    max_years = get_max_years()

    # configure template
    template = loader.get_template('supervisors/search_by_faculty.html')
    context = applist.template_context('supervisors')
    context['schools'] = schools
    context['departments'] = get_departments(schools)
    context['max_years'] = int(max_years) if max_years is not None else YEARS_BACK
    context['scholarships'] = get_scholarships()
    context['last_programs'] = read_last_parameter(request.user, 'supervisors.search_by_paper.programs', PROGRAM_TYPES)
    context['last_supervisor_type'] = read_last_parameter(request.user, 'supervisors.search_by_paper.supervisor_type', SUPERVISOR_TYPES)
    context['last_study_type'] = read_last_parameter(request.user, 'supervisors.search_by_paper.study_type', STUDY_TYPES)
    context['last_only_current'] = read_last_parameter(request.user, 'supervisors.search_by_paper.only_current', True)
    context['last_min_months'] = read_last_parameter(request.user, 'supervisors.search_by_paper.min_months', -1)
    context['last_scholarship'] = read_last_parameter(request.user, 'supervisors.search_by_paper.scholarship', DEFAULT_SCHOLARSHIP)
    context['last_sort_column'] = read_last_parameter(request.user, 'supervisors.search_by_paper.sort_column', "supervisor")
    context['last_sort_order'] = read_last_parameter(request.user, 'supervisors.search_by_paper.sort_order', "asc")
    return HttpResponse(template.render(context, request))
Ejemplo n.º 3
0
def database_bulk(request):
    template = loader.get_template('dbbackend/import_bulk.html')
    context = applist.template_context()
    context['title'] = 'Bulk import'
    context['email_notification'] = read_last_parameter(
        request.user, 'dbbackend.database_bulk.email', '')
    return HttpResponse(template.render(context, request))
Ejemplo n.º 4
0
def index(request):
    # configure template
    template = loader.get_template('hyperlinkgrades/index.html')
    context = applist.template_context('hyperlinkgrades')
    context['last_expression'] = read_last_parameter(
        request.user,
        'hyperlinkgrades.expression',
        def_value=DEFAULT_EXPRESSION)
    context['last_casesensitive_matching'] = bool(
        read_last_parameter(request.user,
                            'hyperlinkgrades.casesensitive_matching',
                            def_value='False'))
    context['last_exclude_completions'] = bool(
        read_last_parameter(request.user,
                            'hyperlinkgrades.exclude_completions',
                            def_value='True'))
    return HttpResponse(template.render(context, request))
Ejemplo n.º 5
0
def database_associatedrole(request):
    template = loader.get_template('dbbackend/import_associatedrole.html')
    tablestatus = dbimport.get_tablestatus(AssociatedRole._meta.db_table)
    context = applist.template_context()
    context['title'] = 'Import associated role'
    context['active_import'] = tablestatus is not None
    context['email_notification'] = read_last_parameter(
        request.user, 'dbbackend.database_associatedrole.email', '')
    return HttpResponse(template.render(context, request))
Ejemplo n.º 6
0
def database_studentdates(request):
    template = loader.get_template('dbbackend/update_studentdates.html')
    tablestatus = dbimport.get_tablestatus(StudentDates._meta.db_table)
    context = applist.template_context()
    context['title'] = 'Update student dates'
    context['active_import'] = tablestatus is not None
    context['email_notification'] = read_last_parameter(
        request.user, 'dbbackend.database_studentdates.email', '')
    return HttpResponse(template.render(context, request))
Ejemplo n.º 7
0
def database_coursedefs(request):
    years = []
    for year in range(2003, date.today().year + 1):
        years.append(year)
    years.reverse()
    tablestatus = dbimport.get_tablestatus(CourseDefs._meta.db_table)
    template = loader.get_template('dbbackend/import_coursedefs.html')
    context = applist.template_context()
    context['title'] = 'Import course definitions'
    context['years'] = years
    context['active_import'] = tablestatus is not None
    context['email_notification'] = read_last_parameter(
        request.user, 'dbbackend.database_coursedefs.email', '')
    return HttpResponse(template.render(context, request))
Ejemplo n.º 8
0
def index(request):
    # get all years
    cursor = connection.cursor()
    cursor.execute("""
        SELECT DISTINCT(year)
        FROM %s
        ORDER BY year DESC
        """ % GradeResults._meta.db_table)
    years = []
    for row in cursor.fetchall():
        years.append(str(row[0]))

    # get all schools
    cursor = connection.cursor()
    cursor.execute("""
        SELECT DISTINCT(owning_school_clevel)
        FROM %s
        ORDER BY owning_school_clevel ASC
        """ % GradeResults._meta.db_table)
    schools = []
    for row in cursor.fetchall():
        schools.append(row[0])

    # get query date
    query_date = None
    rs = TableStatus.objects.all().filter(table=GradeResults._meta.db_table)
    for r in rs:
        query_date = r.timestamp
        break

    # configure template
    template = loader.get_template('lpp/index.html')
    context = applist.template_context('lpp')
    context['years'] = years
    context['schools'] = schools
    context['query_date'] = query_date
    context['last_year'] = read_last_parameter(request.user, 'lpp.year', str(years[0]))
    context['last_schools'] = read_last_parameter(request.user, 'lpp.schools', schools)
    context['last_paper'] = read_last_parameter(request.user, 'lpp.paper', "")
    context['last_type'] = read_last_parameter(request.user, 'lpp.type', DEFAULT_TYPE)
    context['last_columns'] = read_last_parameter(request.user, 'lpp.columns', DEFAULT_COLUMNS)
    context['last_filter1'] = read_last_parameter(request.user, 'lpp.filter1', "")
    context['last_operator1'] = read_last_parameter(request.user, 'lpp.operator1', "lt")
    context['last_value1'] = read_last_parameter(request.user, 'lpp.value1', "")
    return HttpResponse(template.render(context, request))
Ejemplo n.º 9
0
def search_by_supervisor(request):
    # get parameters
    response, name = get_variable_with_error(request, 'supervisors', 'name')
    if response is not None:
        return response

    if len(name) == 0:
        return create_error_response(request, 'supervisors', 'No supervisor name provided!')

    # get year from earliest start date
    max_years = get_max_years()

    sql = """
        select distinct(a.person)
        from %s sd, %s a
        where lower(a.person) like '%%%s%%'
        and a.active = True
        order by a.person
        """ % (StudentDates._meta.db_table, AssociatedRole._meta.db_table, escape_quotes(name.lower()))
    cursor = connection.cursor()
    cursor.execute(sql)
    results = list()
    for row in cursor.fetchall():
        data = dict()
        data['supervisor'] = row[0]
        results.append(data)

    # configure template
    template = loader.get_template('supervisors/search_by_supervisor.html')
    context = applist.template_context('supervisors')
    context['results'] = results
    context['max_years'] = max_years
    context['scholarships'] = get_scholarships()
    context['last_programs'] = read_last_parameter(request.user, 'search_by_supervisor.programs', PROGRAM_TYPES)
    context['last_supervisor_type'] = read_last_parameter(request.user, 'search_by_supervisor.supervisor_type', SUPERVISOR_TYPES)
    context['last_study_type'] = read_last_parameter(request.user, 'search_by_supervisor.study_type', STUDY_TYPES)
    context['last_only_current'] = read_last_parameter(request.user, 'search_by_supervisor.only_current', True)
    context['last_min_months'] = read_last_parameter(request.user, 'search_by_supervisor.min_months', -1)
    context['last_scholarship'] = read_last_parameter(request.user, 'search_by_supervisor.scholarship', DEFAULT_SCHOLARSHIP)
    context['last_sort_column'] = read_last_parameter(request.user, 'search_by_supervisor.sort_column', "supervisor")
    context['last_sort_order'] = read_last_parameter(request.user, 'search_by_supervisor.sort_order', "asc")
    return HttpResponse(template.render(context, request))