Exemplo n.º 1
0
def projects(request, format="csv", recursive=None):
    """ Return statistics for all projects """
    # Create the report data
    data = report_projects(user=request.user, recursive=recursive)
    # Create the generator and return the result
    generator = ReportGenerator(request, data)
    return generator.build(format, subject="Projects")
Exemplo n.º 2
0
def statistics_projects(context):
    """ Report statistics for all projects """
    # Try to find if the user is specified
    if 'user' in context:
        report = report_projects(user = context['user'])[0]
        if report is None:
            # Not authorized
            context['fallback'] = {'type': 'deny', 'message': str(_('You are not allowed to access the projects list.'))}
        elif len(report['items']) == 0:
            # Empty list
            context['fallback'] = {'type': 'important', 'message': str(_('There are no projects.'))}
        else:
            # Update the context
            context.update(report)
            context['units_switch'] = units_switch
    # Return the context
    return context