Example #1
0
def project(request, project_code=None, format="csv", recursive=None):
    """ Return language statistics for one project """
    # Try to find the project
    try:
        project = Project.objects.get(code=project_code)
    except:
        # Project code inexistent, return 404
        return page_not_found(request, _("There is no project with %s code.") % project_code)
    # Create the report data
    data = report_project(project=project, user=request.user, recursive=recursive)
    # Create the generator and return the result
    generator = ReportGenerator(request, data)
    return generator.build(format, subject="%s" % (project.name,))
Example #2
0
def statistics_project(context):
    """ Report languages statistics for one specified project """
    # Try to find if the user is specified
    if 'user' in context:
        report = report_project(project = context.get('project'), user = context['user'])[0]
        if report is None:
            # Not authorized
            context['fallback'] = {'type': 'deny', 'message': str(_('You are not allowed to access the languages for this project.'))}
        elif len(report['items']) == 0:
            # Empty list
            context['fallback'] = {'type': 'important', 'message': str(_('There are no languages for this project.'))}
        else:
            # Update the context
            context.update(report)
            context['units_switch'] = units_switch
    # Return the context
    return context