Exemplo n.º 1
0
def language_index(request, language_code):
    language = get_object_or_404(Language, code=language_code)
    request.permissions = get_matching_permissions(get_profile(request.user), language.directory)

    if not check_permission("view", request):
        raise PermissionDenied

    projects = language.translationproject_set.order_by('project__fullname')
    projectcount = len(projects)
    items = (make_project_item(translate_project) for translate_project in projects.iterator())

    totals = language.getquickstats()
    average = nice_percentage(totals['translatedsourcewords'] * 100.0 / max(totals['totalsourcewords'], 1))
    topstats = gentopstats_language(language)

    templatevars = {
        'language': {
          'code': language.code,
          'name': tr_lang(language.fullname),
          'description': language.description,
          'stats': ungettext('%(projects)d project, %(average)d%% translated',
                             '%(projects)d projects, %(average)d%% translated',
                             projectcount, {"projects": projectcount, "average": average}),
        },
        'feed_path': '%s/' % language.code,
        'description': language.description,
        'projects': items,
        'statsheadings': get_stats_headings(),
        'topstats': topstats,
        }
    if check_permission('administrate', request):
        from pootle_language.forms import DescriptionForm
        templatevars['form'] = DescriptionForm(instance=language)

    return render_to_response("language/language_index.html", templatevars, context_instance=RequestContext(request))
Exemplo n.º 2
0
def language_index(request, language_code):
    language = get_object_or_404(Language, code=language_code)
    request.permissions = get_matching_permissions(get_profile(request.user), language.directory)

    if not check_permission("view", request):
        raise PermissionDenied

    projects = language.translationproject_set.order_by('project__fullname')
    projectcount = len(projects)
    items = (make_project_item(translate_project) for translate_project in projects.iterator())

    totals = language.getquickstats()
    average = nice_percentage(totals['translatedsourcewords'] * 100.0 / max(totals['totalsourcewords'], 1))
    topstats = gentopstats_language(language)

    templatevars = {
        'language': {
          'code': language.code,
          'name': tr_lang(language.fullname),
          'stats': ungettext('%(projects)d project, %(average)d%% translated',
                             '%(projects)d projects, %(average)d%% translated',
                             projectcount, {"projects": projectcount, "average": average}),
        },
        'feed_path': '%s/' % language.code,
        'projects': items,
        'statsheadings': get_stats_headings(),
        'topstats': topstats,
        'instancetitle': pagelayout.get_title(),
        }
    return render_to_response("language/language_index.html", templatevars, context_instance=RequestContext(request))
Exemplo n.º 3
0
def overview(request, language):
    can_edit = check_permission('administrate', request)

    projects = language.translationproject_set.order_by('project__fullname')
    projectcount = len(projects)
    items = (make_project_item(translate_project)
             for translate_project in projects.iterator())

    totals = language.getquickstats()
    average = nice_percentage(totals['translatedsourcewords'] * 100.0 /
                              max(totals['totalsourcewords'], 1))
    topstats = gentopstats_language(language)

    table_fields = [
        'name', 'progress', 'total', 'need-translation', 'activity'
    ]
    table = {
        'id': 'language',
        'proportional': False,
        'fields': table_fields,
        'headings': get_table_headings(table_fields),
        'items': items,
    }

    templatevars = {
        'language': {
            'code':
            language.code,
            'name':
            tr_lang(language.fullname),
            'description':
            language.description,
            'summary':
            ungettext('%(projects)d project, %(average)d%% translated',
                      '%(projects)d projects, %(average)d%% translated',
                      projectcount, {
                          "projects": projectcount,
                          "average": average
                      }),
        },
        'feed_path': '%s/' % language.code,
        'topstats': topstats,
        'can_edit': can_edit,
        'table': table,
    }

    if can_edit:
        from pootle_language.forms import DescriptionForm
        templatevars['form'] = DescriptionForm(instance=language)

    return render_to_response("language/overview.html",
                              templatevars,
                              context_instance=RequestContext(request))
Exemplo n.º 4
0
def language_index(request, language_code):
    language = get_object_or_404(Language, code=language_code)
    request.permissions = get_matching_permissions(get_profile(request.user),
                                                   language.directory)

    if not check_permission("view", request):
        raise PermissionDenied

    can_edit = check_permission('administrate', request)

    projects = language.translationproject_set.order_by('project__fullname')
    projectcount = len(projects)
    items = (make_project_item(translate_project) for translate_project in projects.iterator())

    totals = language.getquickstats()
    average = nice_percentage(totals['translatedsourcewords'] * 100.0 / max(totals['totalsourcewords'], 1))
    topstats = gentopstats_language(language)

    table_fields = ['name', 'progress', 'total', 'need-translation', 'activity']
    table = {
        'id': 'language',
        'proportional': False,
        'fields': table_fields,
        'headings': get_table_headings(table_fields),
        'items': items,
    }

    templatevars = {
        'language': {
          'code': language.code,
          'name': tr_lang(language.fullname),
          'description_html': language.description_html,
          'summary': ungettext('%(projects)d project, %(average)d%% translated',
                               '%(projects)d projects, %(average)d%% translated',
                               projectcount, {
                                   "projects": projectcount,
                                   "average": average}),
        },
        'feed_path': '%s/' % language.code,
        'topstats': topstats,
        'can_edit': can_edit,
        'table': table,
    }

    if can_edit:
        from pootle_language.forms import DescriptionForm
        templatevars['form'] = DescriptionForm(instance=language)

    return render_to_response("language/language_index.html", templatevars,
                              context_instance=RequestContext(request))
Exemplo n.º 5
0
def overview(request, language):
    can_edit = check_permission('administrate', request)

    translation_projects = language.translationproject_set \
                                   .order_by('project__fullname')
    user_tps = filter(lambda x: x.is_accessible_by(request.user),
                      translation_projects)
    tp_count = len(user_tps)
    items = (make_project_item(tp) for tp in user_tps)

    topstats = gentopstats_language(language)

    table_fields = ['name', 'progress', 'total', 'need-translation', 'activity']
    table = {
        'id': 'language',
        'proportional': False,
        'fields': table_fields,
        'headings': get_table_headings(table_fields),
        'items': items,
    }

    templatevars = {
        'resource_obj': request.resource_obj,
        'language': {
          'code': language.code,
          'name': tr_lang(language.fullname),
          'description': language.description,
          'summary': ungettext('%(projects)d project',
                               '%(projects)d projects',
                               tp_count, {"projects": tp_count}),
        },
        'feed_path': '%s/' % language.code,
        'topstats': topstats,
        'can_edit': can_edit,
        'table': table,
    }

    if can_edit:
        from pootle_language.forms import DescriptionForm
        templatevars.update({
            'form': DescriptionForm(instance=language),
            'form_action': reverse('pootle-language-admin-settings',
                                   args=[language.code]),
        })

    return render_to_response("languages/overview.html", templatevars,
                              context_instance=RequestContext(request))
Exemplo n.º 6
0
def overview(request, language):
    can_edit = check_permission("administrate", request)

    translation_projects = language.translationproject_set.order_by("project__fullname")
    user_tps = filter(lambda x: x.is_accessible_by(request.user), translation_projects)
    tp_count = len(user_tps)
    items = (make_project_item(tp) for tp in user_tps)

    totals = language.getquickstats()
    average = nice_percentage(totals["translatedsourcewords"], totals["totalsourcewords"])
    topstats = gentopstats_language(language)

    table_fields = ["name", "progress", "total", "need-translation", "activity"]
    table = {
        "id": "language",
        "proportional": False,
        "fields": table_fields,
        "headings": get_table_headings(table_fields),
        "items": items,
    }

    templatevars = {
        "language": {
            "code": language.code,
            "name": tr_lang(language.fullname),
            "description": language.description,
            "summary": ungettext(
                "%(projects)d project, %(average)d%% translated",
                "%(projects)d projects, %(average)d%% translated",
                tp_count,
                {"projects": tp_count, "average": average},
            ),
        },
        "feed_path": "%s/" % language.code,
        "topstats": topstats,
        "can_edit": can_edit,
        "table": table,
    }

    if can_edit:
        from pootle_language.forms import DescriptionForm

        templatevars["form"] = DescriptionForm(instance=language)

    return render_to_response("language/overview.html", templatevars, context_instance=RequestContext(request))
Exemplo n.º 7
0
def overview(request, language):
    can_edit = check_permission("administrate", request)

    translation_projects = language.translationproject_set.order_by("project__fullname")
    user_tps = filter(lambda x: x.is_accessible_by(request.user), translation_projects)
    tp_count = len(user_tps)
    items = (make_project_item(tp) for tp in user_tps)

    topstats = gentopstats_language(language)

    table_fields = ["name", "progress", "total", "need-translation", "activity"]
    table = {
        "id": "language",
        "proportional": False,
        "fields": table_fields,
        "headings": get_table_headings(table_fields),
        "items": items,
    }

    templatevars = {
        "resource_obj": request.resource_obj,
        "language": {
            "code": language.code,
            "name": tr_lang(language.fullname),
            "description": language.description,
            "summary": ungettext("%(projects)d project", "%(projects)d projects", tp_count, {"projects": tp_count}),
        },
        "feed_path": "%s/" % language.code,
        "topstats": topstats,
        "can_edit": can_edit,
        "table": table,
    }

    if can_edit:
        from pootle_language.forms import DescriptionForm

        templatevars.update(
            {
                "form": DescriptionForm(instance=language),
                "form_action": reverse("pootle-language-admin-settings", args=[language.code]),
            }
        )

    return render_to_response("languages/overview.html", templatevars, context_instance=RequestContext(request))