<commit_before>from pyramid.renderers import get_renderer
from pyramid.view import view_config

from . import get_report_info
from . import list_employees
from . import list_reports

def get_main_template(request):
    main_template = get_renderer('templates/main.pt')
    return main_template.implementation()


@view_config(route_name='home', renderer='templates/home.pt')
def home_page(request):
    return {}


@view_config(route_name='employees', renderer='templates/employees.pt')
def show_employees(request):
    return {'employees': list_employees()}


@view_config(route_name='employee', renderer='templates/employee.pt')
def show_employee(request):
    employee_id = request.matchdict['employee_id']
    return {'employee_id': employee_id,
            'reports': list_reports(employee_id),
           }


@view_config(route_name='report', renderer='templates/report.pt')
def show_report(request):
    employee_id = request.matchdict['employee_id']
    report_id = request.matchdict['report_id']
    return {'report': get_report_info(employee_id, report_id)}


def includeme(config):
    config.add_request_method(callable=get_main_template,
                              name='main_template',
                              property=True,
                              reify=True,
                             )<commit_msg>Improve status display for reports.<commit_after>from pyramid.renderers import get_renderer
from pyramid.view import view_config

from . import get_report_info
from . import list_employees
from . import list_reports

def get_main_template(request):
    main_template = get_renderer('templates/main.pt')
    return main_template.implementation()


@view_config(route_name='home', renderer='templates/home.pt')
def home_page(request):
    return {}


@view_config(route_name='employees', renderer='templates/employees.pt')
def show_employees(request):
    return {'employees': list_employees()}


def fixup_report(report):
    if report['status'] == 'paid':
        report['status'] = 'paid, check #%s' % report.pop('memo')
    elif report['status'] == 'rejected':
        report['status'] = 'rejected, #%s' % report.pop('memo')
    return report

@view_config(route_name='employee', renderer='templates/employee.pt')
def show_employee(request):
    employee_id = request.matchdict['employee_id']
    return {'employee_id': employee_id,
            'reports': [fixup_report(report)
                        for report in list_reports(employee_id)],
           }


@view_config(route_name='report', renderer='templates/report.pt')
def show_report(request):
    employee_id = request.matchdict['employee_id']
    report_id = request.matchdict['report_id']
    return {'report': fixup_report(get_report_info(employee_id, report_id))}


def includeme(config):
    config.add_request_method(callable=get_main_template,
                              name='main_template',
                              property=True,
                              reify=True,
                             )
{'fraction_non_alphanumeric': 0.11553784860557768, 'fraction_numerical': 0.0, 'mean_word_length': 3.5376506024096384, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4004434', 'n_tokens_mistral': 913, 'n_tokens_neox': 860, 'n_words': 155}