Esempio n. 1
0
def index(university_id):

    university = UniversityModel.query.filter_by(id=university_id).first_or_404()

    university_service = University(university.id)
    majors_service = UniversityMajors(university.id)

    header = {
        'year': university_service.year(),
        'type': university_service.university_type(),
        'enrolled': university_service.enrolled(),
        'entrants': university_service.entrants(),
        'graduates': university_service.graduates()
    }

    body = {
        'major_with_more_enrollments': majors_service.major_with_more_enrollments(),
        'highest_enrollment_number_by_major': majors_service.highest_enrolled_number(),
        'major_with_more_entrants': majors_service.major_with_more_entrants(),
        'highest_entrant_number_by_major': majors_service.highest_entrants_number(),
        'major_with_more_graduates': majors_service.major_with_more_graduates(),
        'highest_graduate_number_by_major': majors_service.highest_graduates_number(),
        'year': majors_service.year(),
    }

    hedu_max_year = db.session.query(func.max(Yu.year)).first()[0]

    if header['enrolled'] is None or hedu_max_year != body['year']:
        abort(404)
    else:
        return render_template('university/index.html', university=university, header=header, body=body)
Esempio n. 2
0
def index(university_id, tab):

    university = UniversityModel.query.filter_by(id=university_id).first_or_404()

    university_service = University(university.id)
    majors_service = UniversityMajors(university.id)

    menu = request.args.get('menu')
    url = request.args.get('url')
    graph = {}

    if menu:
        graph['menu'] = menu
    if url:
        graph['url'] = url

    header = {
        'year': university_service.year(),
        'type': university_service.university_type(),
        'enrolled': university_service.enrolled(),
        'entrants': university_service.entrants(),
        'graduates': university_service.graduates()
    }

    body = {
        'major_with_more_enrollments': majors_service.major_with_more_enrollments(),
        'highest_enrollment_number_by_major': majors_service.highest_enrolled_number(),
        'major_with_more_entrants': majors_service.major_with_more_entrants(),
        'highest_entrant_number_by_major': majors_service.highest_entrants_number(),
        'major_with_more_graduates': majors_service.major_with_more_graduates(),
        'highest_graduate_number_by_major': majors_service.highest_graduates_number(),
        'year': majors_service.year(),
    }

    tabs = {
        'general': [],
        'enrollments': [
            'category-major-tree_map',
            'category-major-stacked',
            'category-status-line',
            'category-shift-stacked',
        ],
    }

    hedu_max_year = db.session.query(func.max(Yu.year)).first()[0]

    if tab not in tabs:
        abort(404)

    if menu and menu not in tabs[tab]:
        abort(404)

    if header['enrolled'] is None or hedu_max_year != body['year']:
        abort(404)
    else:
        return render_template('university/index.html', university=university, header=header, body=body, tab=tab, graph=graph)
Esempio n. 3
0
def index(university_id, tab):

    university = UniversityModel.query.filter_by(id=university_id).first_or_404()

    university_service = University(university.id)
    majors_service = UniversityMajors(university.id)

    menu = request.args.get('menu')
    url = request.args.get('url')
    graph = {}

    if menu:
        graph['menu'] = menu
    if url:
        url_prefix = menu.split('-')[-1] + '/' if menu and menu.startswith('new-api-') else 'embed/'
        graph['url'] = url_prefix + url

    header = {
        'type': university_service.university_type(),
        'enrolled': university_service.enrolled(),
        'graduates': university_service.graduates()
    }

    body = {
        'major_with_more_enrollments': majors_service.major_with_more_enrollments(),
        'highest_enrollment_number_by_major': majors_service.highest_enrolled_number(),
        'year': '2016',
    }

    tabs = {
        'general': [],
        'enrollments': [
            'category-major-tree_map',
            'category-major-stacked',
            'category-status-line',
            'new-api-category-status-line',
            'category-shift-stacked',
        ],
    }

    hedu_max_year = '2016'

    if tab not in tabs:
        abort(404)

    if menu and menu not in tabs[tab]:
        abort(404)

    if header['enrolled'] is None:
        abort(404)
    else:
        return render_template('university/index.html', university=university, header=header, body=body, tab=tab, graph=graph)
Esempio n. 4
0
def index():
    university_service = University(university_id='00575')
    majors_service = UniversityMajors(university_id='00575')

    header = {
        'name' : university_service.name(),
        'type' : university_service.university_type(),
        'enrolled' : university_service.enrolled(),
        'entrants' : university_service.entrants(),
        'graduates' : university_service.graduates(),
        'year' : university_service.year()
    }

    content = {
        'major_with_more_enrollments' : majors_service.major_with_more_enrollments(),
        'highest_enrollment_number_by_major' : majors_service.highest_enrolled_number(),
        'major_with_more_entrants' : majors_service.major_with_more_entrants(),
        'highest_entrant_number_by_major' : majors_service.highest_entrants_number(),
        'major_with_more_graduates' : majors_service.major_with_more_graduates(),
        'highest_graduate_number_by_major' : majors_service.highest_graduates_number()
    }
    return render_template('index.html', header=header, content=content, body_class='perfil_estado')
Esempio n. 5
0
def index(university_id, tab):

    university = UniversityModel.query.filter_by(
        id=university_id).first_or_404()

    university_service = University(university.id)
    majors_service = UniversityMajors(university.id)

    menu = request.args.get('menu')
    url = request.args.get('url')
    graph = {}

    if menu:
        graph['menu'] = menu
    if url:
        url_prefix = menu.split('-')[-1] + '/' if menu and menu.startswith(
            'new-api-') else 'embed/'
        graph['url'] = url_prefix + url

    header = {
        'year': university_service.year(),
        'type': university_service.university_type(),
        'enrolled': university_service.enrolled(),
        'entrants': university_service.entrants(),
        'graduates': university_service.graduates()
    }

    body = {
        'major_with_more_enrollments':
        majors_service.major_with_more_enrollments(),
        'highest_enrollment_number_by_major':
        majors_service.highest_enrolled_number(),
        'major_with_more_entrants':
        majors_service.major_with_more_entrants(),
        'highest_entrant_number_by_major':
        majors_service.highest_entrants_number(),
        'major_with_more_graduates':
        majors_service.major_with_more_graduates(),
        'highest_graduate_number_by_major':
        majors_service.highest_graduates_number(),
        'year':
        majors_service.year(),
    }

    tabs = {
        'general': [],
        'enrollments': [
            'category-major-tree_map',
            'category-major-stacked',
            'category-status-line',
            'new-api-category-status-line',
            'category-shift-stacked',
        ],
    }

    hedu_max_year = db.session.query(func.max(Yu.year)).first()[0]

    if tab not in tabs:
        abort(404)

    if menu and menu not in tabs[tab]:
        abort(404)

    if header['enrolled'] is None or hedu_max_year != body['year']:
        abort(404)
    else:
        return render_template('university/index.html',
                               university=university,
                               header=header,
                               body=body,
                               tab=tab,
                               graph=graph)