Beispiel #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)
Beispiel #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)
Beispiel #3
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')
Beispiel #4
0
def all(tab):
    location_service_brazil = All()
    product_service = Product(product_id=None)
    industry_service = Industry(cnae_id=None)
    occupation_service = Occupation(occupation_id=None)
    university_service = University(university_id=None)
    basic_course_service = Basic_course(course_sc_id=None)
    major_service = Major(course_hedu_id=None, bra_id=None)
    scholar_service = AllScholar()
    basic_course_service = AllBasicCourse()

    location = Wld.query.filter_by(id='sabra').first_or_404()
    location.id = 'all'
    is_municipality = False
    menu = request.args.get('menu')
    url = request.args.get('url')

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

    profile = {}

    header = {
        'bg_class_image': 'bg-all',
        'gdp': location_service_brazil.gdp(),
        'population': location_service_brazil.population(),
        'gdp_per_capita': location_service_brazil.gdp_per_capita(),
        'eci': 0.151,
        'year_yb': location_service_brazil.year_yb(),
        'year_ybs': location_service_brazil.year_ybs()
    }

    body = {
        'product_year': product_service.year(),
        'main_product_by_export_value': product_service.highest_export_value(),
        'main_product_by_export_value_name': product_service.highest_export_value_name(),
        'main_product_by_import_value': product_service.highest_import_value(),
        'main_product_by_import_value_name': product_service.highest_import_value_name(),
        'total_imports': product_service.all_imported(),
        'total_exports': product_service.all_exported(),
        'all_trade_balance': product_service.all_trade_balance(),

        'industry_year': industry_service.get_year(),
        'main_industry_by_num_jobs': industry_service.main_industry_by_num_jobs(),
        'main_industry_by_num_jobs_name': industry_service.main_industry_by_num_jobs_name(),
        'main_occupation_by_num_jobs': occupation_service.main_occupation_by_num_jobs(),
        'main_occupation_by_num_jobs_name': occupation_service.main_occupation_by_num_jobs_name(),
        'avg_wage': industry_service.avg_wage(),
        'wage': industry_service.all_salary_mass(),
        'total_jobs': industry_service.total_jobs(),

        'university_year': university_service.year(),
        'highest_enrolled_by_university': university_service.highest_enrolled_by_university(),
        'highest_enrolled_by_university_name': university_service.highest_enrolled_by_university_name(),
        'highest_enrolled_by_major': major_service.highest_enrolled_by_major(),
        'highest_enrolled_by_major_name': major_service.highest_enrolled_by_major_name(),
        'highest_enrolled_by_school': scholar_service.highest_enrolled_by_school(),
        'highest_enrolled_by_school_name': scholar_service.highest_enrolled_by_school_name(),
        'highest_enrolled_by_basic_course': basic_course_service.highest_enrolled_by_basic_course(),
        'highest_enrolled_by_basic_course_name': basic_course_service.highest_enrolled_by_basic_course_name()
    }

    if body['total_exports'] is None and body['total_imports'] is None and body['total_jobs'] is None and \
            body['highest_enrolled_by_university'] is None and body['highest_enrolled_by_basic_course'] is None and \
            body['highest_enrolled_by_major'] is None:
            abort(404)
    
    if tab not in tabs:
        abort(404)

    if menu and menu not in tabs[tab]:
        abort(404)
    
    else:
        return render_template('location/index.html',
                            header=header, body=body, profile=profile, location=location, is_municipality=is_municipality, tab=tab, graph=graph)
Beispiel #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)
Beispiel #6
0
def all(tab):
    location_service_brazil = All()
    product_service = Product(product_id=None)
    industry_service = Industry(cnae_id=None)
    occupation_service = Occupation(occupation_id=None)
    university_service = University(university_id=None)
    basic_course_service = Basic_course(course_sc_id=None)
    major_service = Major(course_hedu_id=None, bra_id=None)
    scholar_service = AllScholar()
    basic_course_service = AllBasicCourse()

    location = Wld.query.filter_by(id='sabra').first_or_404()
    location.id = 'all'
    is_municipality = False
    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-') or tab == 'health' else 'embed/'
        graph['url'] = url_prefix + url

    profile = {}

    header = {
        'bg_class_image': 'bg-all',
        'gdp': location_service_brazil.gdp(),
        'population': location_service_brazil.population(),
        'gdp_per_capita': location_service_brazil.gdp_per_capita(),
        'eci': 0.151,
        'year_yb': location_service_brazil.year_yb(),
        'year_ybs': location_service_brazil.year_ybs()
    }

    body = {
        'product_year':
        product_service.year(),
        'total_imports':
        product_service.all_imported(),
        'total_exports':
        product_service.all_exported(),
        'all_trade_balance':
        product_service.all_trade_balance(),
        'industry_year':
        industry_service.get_year(),
        'main_industry_by_num_jobs_name':
        industry_service.main_industry_by_num_jobs_name(),
        'total_jobs':
        industry_service.total_jobs(),
        'university_year':
        university_service.year(),
    }

    if body['total_exports'] is None and body['total_imports'] is None and body['total_jobs'] is None and \
            body['highest_enrolled_by_university'] is None and body['highest_enrolled_by_basic_course'] is None and \
            body['highest_enrolled_by_major'] is None:
        abort(404)

    if tab not in tabs:
        abort(404)

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

    else:
        return render_template('location/index.html',
                               header=header,
                               body=body,
                               profile=profile,
                               location=location,
                               is_municipality=is_municipality,
                               tab=tab,
                               graph=graph)
Beispiel #7
0
def all():
    location_service_brazil = All()
    product_service = Product(product_id=None)
    industry_service = Industry(cnae_id=None)
    occupation_service = Occupation(occupation_id=None)
    university_service = University(university_id=None)
    basic_course_service = Basic_course(course_sc_id=None)
    major_service = Major(course_hedu_id=None, bra_id=None)
    scholar_service = AllScholar()
    basic_course_service = AllBasicCourse()

    location = Wld.query.filter_by(id='sabra').first_or_404()
    location.id = 'all'

    header = {
        'bg_class_image': 'bg-all',
        'gdp': location_service_brazil.gdp(),
        'population': location_service_brazil.population(),
        'gdp_per_capita': location_service_brazil.gdp_per_capita(),
        'eci': 0.151,
        'year_yb': location_service_brazil.year_yb(),
        'year_ybs': location_service_brazil.year_ybs()
    }

    body = {
        'product_year':
        product_service.year(),
        'main_product_by_export_value':
        product_service.highest_export_value(),
        'main_product_by_export_value_name':
        product_service.highest_export_value_name(),
        'main_product_by_import_value':
        product_service.highest_import_value(),
        'main_product_by_import_value_name':
        product_service.highest_import_value_name(),
        'total_imports':
        product_service.all_imported(),
        'total_exports':
        product_service.all_exported(),
        'all_trade_balance':
        product_service.all_trade_balance(),
        'industry_year':
        industry_service.get_year(),
        'main_industry_by_num_jobs':
        industry_service.main_industry_by_num_jobs(),
        'main_industry_by_num_jobs_name':
        industry_service.main_industry_by_num_jobs_name(),
        'main_occupation_by_num_jobs':
        occupation_service.main_occupation_by_num_jobs(),
        'main_occupation_by_num_jobs_name':
        occupation_service.main_occupation_by_num_jobs_name(),
        'avg_wage':
        industry_service.avg_wage(),
        'wage':
        industry_service.all_salary_mass(),
        'total_jobs':
        industry_service.total_jobs(),
        'university_year':
        university_service.year(),
        'highest_enrolled_by_university':
        university_service.highest_enrolled_by_university(),
        'highest_enrolled_by_university_name':
        university_service.highest_enrolled_by_university_name(),
        'highest_enrolled_by_major':
        major_service.highest_enrolled_by_major(),
        'highest_enrolled_by_major_name':
        major_service.highest_enrolled_by_major_name(),
        'highest_enrolled_by_school':
        scholar_service.highest_enrolled_by_school(),
        'highest_enrolled_by_school_name':
        scholar_service.highest_enrolled_by_school_name(),
        'highest_enrolled_by_basic_course':
        basic_course_service.highest_enrolled_by_basic_course(),
        'highest_enrolled_by_basic_course_name':
        basic_course_service.highest_enrolled_by_basic_course_name()
    }

    profile = {}

    if body['total_exports'] is None and body['total_imports'] is None and body['total_jobs'] is None and \
            body['highest_enrolled_by_university'] is None and body['highest_enrolled_by_basic_course'] is None and \
            body['highest_enrolled_by_major'] is None:
        abort(404)
    else:
        return render_template('location/index.html',
                               header=header,
                               body=body,
                               profile=profile,
                               location=location)