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