Exemplo n.º 1
0
def make_language_item(translation_project):
    href = translation_project.get_absolute_url()
    href_all = translation_project.get_translate_url()
    href_todo = translation_project.get_translate_url(state='incomplete')

    project_stats = get_raw_stats(translation_project)

    tooltip_dict = {
        'percentage': project_stats['translated']['percentage']
    }

    info = {
        'project': translation_project.project.code,
        'code': translation_project.language.code,
        'href': href,
        'href_all': href_all,
        'href_todo': href_todo,
        'title': tr_lang(translation_project.language.fullname),
        'stats': project_stats,
        'lastactivity': get_last_action(translation_project),
        'tags': translation_project.tag_like_objects,
        'pk': translation_project.pk,
        'tooltip': _('%(percentage)d%% complete', tooltip_dict),
    }

    errors = project_stats.get('errors', 0)

    if errors:
        info['errortooltip'] = ungettext('Error reading %d file',
                                         'Error reading %d files', errors,
                                         errors)

    info.update(stats_descriptions(project_stats))

    return info
Exemplo n.º 2
0
def make_language_item(request, translation_project):
    href = translation_project.get_absolute_url()
    href_all = translation_project.get_translate_url()
    href_todo = translation_project.get_translate_url(state='incomplete')

    project_stats = get_raw_stats(translation_project)

    tooltip_dict = {'percentage': project_stats['translated']['percentage']}

    info = {
        'project': translation_project.project.code,
        'code': translation_project.language.code,
        'href': href,
        'href_all': href_all,
        'href_todo': href_todo,
        'title': tr_lang(translation_project.language.fullname),
        'stats': project_stats,
        'lastactivity': get_last_action(translation_project),
        'tags': translation_project.tags.all().order_by('name'),
        'pk': translation_project.pk,
        'tooltip': _('%(percentage)d%% complete', tooltip_dict),
    }

    errors = project_stats.get('errors', 0)

    if errors:
        info['errortooltip'] = ungettext('Error reading %d file',
                                         'Error reading %d files', errors,
                                         errors)

    info.update(stats_descriptions(project_stats))

    return info
Exemplo n.º 3
0
def make_generic_item(path_obj, action):
    """Template variables for each row in the table.

    :func:`make_directory_item` and :func:`make_store_item` will add onto these
    variables.
    """
    try:
        stats = get_raw_stats(path_obj, include_suggestions=True)
        info = {
            'href': action,
            'href_all': dispatch.translate(path_obj),
            'href_todo': dispatch.translate(path_obj, state='incomplete'),
            'href_sugg': dispatch.translate(path_obj, state='suggestions'),
            'stats': stats,
            'tooltip': _('%(percentage)d%% complete',
                         {'percentage': stats['translated']['percentage']}),
            'title': path_obj.name,
        }

        errors = stats.get('errors', 0)
        if errors:
            info['errortooltip'] = ungettext('Error reading %d file',
                                             'Error reading %d files',
                                             errors, errors)

        info.update(stats_descriptions(stats))
    except IOError, e:
        info = {
            'href': action,
            'title': path_obj.name,
            'errortooltip': e.strerror,
            'data': {'errors': 1},
            }
Exemplo n.º 4
0
def make_project_item(translation_project):
    project = translation_project.project
    href = translation_project.get_absolute_url()
    href_all = translation_project.get_translate_url()
    href_todo = translation_project.get_translate_url(state='incomplete')

    project_stats = get_raw_stats(translation_project)

    info = {
        'code': project.code,
        'href': href,
        'href_all': href_all,
        'href_todo': href_todo,
        'title': project.fullname,
        'description': project.description,
        'stats': project_stats,
        'lastactivity': get_last_action(translation_project),
        'isproject': True,
        'tooltip': _('%(percentage)d%% complete',
                     {'percentage': project_stats['translated']['percentage']}),
    }

    errors = project_stats.get('errors', 0)

    if errors:
        info['errortooltip'] = ungettext('Error reading %d file',
                                         'Error reading %d files',
                                         errors, errors)

    info.update(stats_descriptions(project_stats))

    return info
Exemplo n.º 5
0
def make_project_item(translation_project):
    project = translation_project.project
    href = translation_project.get_absolute_url()
    href_all = translation_project.get_translate_url()
    href_todo = translation_project.get_translate_url(state="incomplete")

    project_stats = get_raw_stats(translation_project)

    info = {
        "code": project.code,
        "href": href,
        "href_all": href_all,
        "href_todo": href_todo,
        "title": project.fullname,
        "description": project.description,
        "stats": project_stats,
        "lastactivity": get_last_action(translation_project),
        "isproject": True,
        "tooltip": _("%(percentage)d%% complete", {"percentage": project_stats["translated"]["percentage"]}),
    }

    errors = project_stats.get("errors", 0)

    if errors:
        info["errortooltip"] = ungettext("Error reading %d file", "Error reading %d files", errors, errors)

    info.update(stats_descriptions(project_stats))

    return info
Exemplo n.º 6
0
def make_language_item(request, translation_project):
    href = '/%s/%s/' % (translation_project.language.code,
                        translation_project.project.code)
    href_all = dispatch.translate(translation_project)
    href_todo = dispatch.translate(translation_project, state='incomplete')

    project_stats = get_raw_stats(translation_project)

    tooltip_dict = {
        'percentage': project_stats['translated']['percentage']
    }

    info = {
        'code': translation_project.language.code,
        'href': href,
        'href_all': href_all,
        'href_todo': href_todo,
        'title': tr_lang(translation_project.language.fullname),
        'stats': project_stats,
        'lastactivity': get_last_action(translation_project),
        'tooltip': _('%(percentage)d%% complete', tooltip_dict),
    }

    errors = project_stats.get('errors', 0)

    if errors:
        info['errortooltip'] = ungettext('Error reading %d file',
                                         'Error reading %d files', errors,
                                         errors)

    info.update(stats_descriptions(project_stats))

    return info
Exemplo n.º 7
0
def make_project_item(translation_project):
    project = translation_project.project
    href = translation_project.pootle_path
    href_all = dispatch.translate(translation_project)
    href_todo = dispatch.translate(translation_project, state='incomplete')

    project_stats = get_raw_stats(translation_project)

    info = {
        'code': project.code,
        'href': href,
        'href_all': href_all,
        'href_todo': href_todo,
        'title': project.fullname,
        'description': project.description,
        'stats': project_stats,
        'lastactivity': get_last_action(translation_project),
        'isproject': True,
        'tooltip': _('%(percentage)d%% complete',
                     {'percentage': project_stats['translated']['percentage']}),
    }

    errors = project_stats.get('errors', 0)

    if errors:
        info['errortooltip'] = ungettext('Error reading %d file',
                                         'Error reading %d files',
                                         errors, errors)

    info.update(stats_descriptions(project_stats))

    return info
Exemplo n.º 8
0
def make_generic_item(path_obj):
    """Template variables for each row in the table.

    :func:`make_directory_item` and :func:`make_store_item` will add onto these
    variables.
    """
    action = path_obj.pootle_path
    try:
        stats = get_raw_stats(path_obj, include_suggestions=True)
        info = {
            "href": action,
            "href_all": path_obj.get_translate_url(),
            "href_todo": path_obj.get_translate_url(state="incomplete"),
            "href_sugg": path_obj.get_translate_url(state="suggestions"),
            "stats": stats,
            "tooltip": _("%(percentage)d%% complete", {"percentage": stats["translated"]["percentage"]}),
            "title": path_obj.name,
        }

        errors = stats.get("errors", 0)
        if errors:
            info["errortooltip"] = ungettext("Error reading %d file", "Error reading %d files", errors, errors)

        info.update(stats_descriptions(stats))
    except IOError as e:
        info = {"href": action, "errortooltip": e.strerror, "data": {"errors": 1}, "title": path_obj.name}

    return info
Exemplo n.º 9
0
def make_goal_dir_item(directory, goal):
    """Template variables for each row in the table."""
    try:
        stats = goal.get_raw_stats_for_path(directory.pootle_path)
        item = {
            "href_all": goal.get_translate_url_for_path(directory.pootle_path),
            "href_todo": goal.get_translate_url_for_path(directory.pootle_path, state="incomplete"),
            "href_sugg": goal.get_translate_url_for_path(directory.pootle_path, state="suggestions"),
            "stats": stats,
            "tooltip": _("%(percentage)d%% complete", {"percentage": stats["translated"]["percentage"]}),
        }

        errors = stats.get("errors", 0)
        if errors:
            msg = ungettext("Error reading %d file", "Error reading %d files", errors, errors)
            item["errortooltip"] = msg

        item.update(stats_descriptions(stats))
    except IOError as e:
        item = {"errortooltip": e.strerror, "data": {"errors": 1}}

    item.update(
        {
            "href": goal.get_drill_down_url_for_path(directory.pootle_path),
            "title": directory.name,
            "icon": "folder",
            "isdir": True,
        }
    )
    return item
Exemplo n.º 10
0
def make_goal_item(goal, pootle_path):
    """Create the item row for a goal."""
    try:
        stats = goal.get_raw_stats_for_path(pootle_path)
        info = {
            "href_all": goal.get_translate_url_for_path(pootle_path),
            "href_todo": goal.get_translate_url_for_path(pootle_path, state="incomplete"),
            "href_sugg": goal.get_translate_url_for_path(pootle_path, state="suggestions"),
            "stats": stats,
            "tooltip": _("%(percentage)d%% complete", {"percentage": stats["translated"]["percentage"]}),
        }

        errors = stats.get("errors", 0)
        if errors:
            msg = ungettext("Error reading %d file", "Error reading %d files", errors, errors)
            info["errortooltip"] = msg

        info.update(stats_descriptions(stats))
    except IOError as e:
        info = {"errortooltip": e.strerror, "data": {"errors": 1}}

    info.update(
        {
            "href": goal.get_drill_down_url_for_path(pootle_path),
            "isdir": True,
            "priority": goal.priority,
            "title": goal.goal_name,
        }
    )
    return info
Exemplo n.º 11
0
def make_language_item(request, translation_project):
    href = '/%s/%s/' % (translation_project.language.code,
                        translation_project.project.code)
    href_all = dispatch.translate(translation_project)
    href_todo = dispatch.translate(translation_project, state='incomplete')

    project_stats = get_raw_stats(translation_project)

    info = {
        'code':
        translation_project.language.code,
        'href':
        href,
        'href_all':
        href_all,
        'href_todo':
        href_todo,
        'title':
        tr_lang(translation_project.language.fullname),
        'stats':
        project_stats,
        'lastactivity':
        get_last_action(translation_project),
        'tooltip':
        _('%(percentage)d%% complete',
          {'percentage': project_stats['translated']['percentage']}),
    }

    errors = project_stats.get('errors', 0)

    if errors:
        info['errortooltip'] = ungettext('Error reading %d file',
                                         'Error reading %d files', errors,
                                         errors)

    info.update(stats_descriptions(project_stats))

    return info