Exemple #1
0
def report_list():
    report_list = [{
        'id':
        row.id,
        'extended_info':
        row['format_availability_paper_or_web'] and 'Yes' or 'No',
        'data':
        schema.ReportSchema.from_flat(row)
    } for row in database.get_all_reports()]
    country = flask.request.args.get('country')
    region = flask.request.args.get('region')
    if country:
        report_list = [
            report for report in report_list
            if country in report['data']['header']['country'].value
            and len(report['data']['header']['country'].value) == 1
        ]
    if region:
        report_list = [
            report for report in report_list
            if region in report['data']['header']['region'].value
        ]
    return flask.render_template(
        'report_list.html', **{
            'report_list': report_list,
            'country': country,
            'region': region,
            'edit_is_allowed': edit_is_allowed(),
        })
Exemple #2
0
def get_reports(with_url=None):
    reports = []
    reviews_dict = database.get_seris_reviews_dict()
    for report in database.get_all_reports():
        header_country = []
        header_region = []
        details_original_language = []
        for i in range(0, 50):
            country = report.get('header_country_%s' % i)
            if country:
                header_country.append(country)
                del (report['header_country_%s' % i])
            region = report.get('header_region_%s' % i)
            if region:
                header_region.append(region)
                del (report['header_region_%s' % i])
            language = report.get('details_original_language_%s' % i)
            if language:
                details_original_language.append(language)
                del (report['details_original_language_%s' % i])
        report['header_country'] = header_country
        report['header_region'] = header_region
        report['details_original_language'] = details_original_language
        if with_url:
            report['url'] = make_external(
                flask.url_for('views.report_view', report_id=report.id))
        seris_review = reviews_dict[str(report.id)]
        reports.append(dict(report, **seris_review))
    return reports
Exemple #3
0
def index():
    eea_countries_list = []
    cooperating_countries_list = []
    report_list = [
        schema.ReportSchema.from_flat(row)
        for row in database.get_all_reports()
    ]
    for country in eea_countries:
        count = 0
        for report in report_list:
            if country in report['header']['country'].value \
                    and len(report['header']['country'].value) == 1:
                count += 1
        eea_countries_list.append((country, count))
    for country in cooperating_countries:
        count = 0
        for report in report_list:
            if country in report['header']['country'].value \
                    and len(report['header']['country'].value) == 1:
                count += 1
        cooperating_countries_list.append((country, count))
    eea_count = 0
    for report in report_list:
        if 'European Environment Agency' in report['header']['region'].value:
            eea_count += 1
    return flask.render_template(
        'index.html', **{
            'eea_countries_list': eea_countries_list,
            'cooperating_countries_list': cooperating_countries_list,
            'regions_list': [('European Environment Agency', eea_count)]
        })
Exemple #4
0
def migrate_country_name_to_code():
    session = database.get_session()
    countries = _load_json('refdata/countries.json')
    old_countries = _load_json('refdata/old_countries.json')
    country_mapping = {}
    for k, v in countries.items():
        country_mapping[v] = k
    country_mapping.update(old_countries)
    for row in database.get_all_reports():
        modified = False
        for index in range(0, len(country_mapping) + 1):
            country_name = row.get('header_country_' + str(index))
            if country_name and country_name in country_mapping.keys():
                row['header_country_' +
                    str(index)] = country_mapping[country_name]
                modified = True
        if modified:
            session.save(row)
            session.commit()
Exemple #5
0
def report_list():
    return flask.render_template('report_list.html', **{
        'report_list': [{'id': row.id,
                         'data': schema.ReportSchema.from_flat(row)}
                        for row in database.get_all_reports()],
    })