示例#1
0
文件: views.py 项目: cstroie/tranpy
def languages(request, format="csv", recursive=None):
    """ Return statistics for all languages """
    # Create the report data
    data = report_languages(user=request.user, recursive=recursive)
    # Create the generator and return the result
    generator = ReportGenerator(request, data)
    return generator.build(format, subject="Languages")
示例#2
0
def statistics_languages(context):
    """ Report statistics for all languages """
    # Try to find if the user is specified
    if 'user' in context:
        report = report_languages(user = context['user'])[0]
        if report is None:
            # Not authorized
            context['fallback'] = {'type': 'deny', 'message': str(_('You are not allowed to access the languages list.'))}
        elif len(report['items']) == 0:
            # Empty list
            context['fallback'] = {'type': 'important', 'message': str(_('There are no languages.'))}
        else:
            # Update the context
            context.update(report)
            context['units_switch'] = units_switch
    # Return the context
    return context