Example #1
0
def projects_browse(request, project_set):
    """Page listing all projects"""
    items = [make_project_list_item(project)
             for project in project_set.children]
    items.sort(lambda x, y: locale.strcoll(x['title'], y['title']))

    table_fields = ['name', 'progress', 'total', 'need-translation',
                    'suggestions', 'critical', 'last-updated', 'activity']
    table = {
        'id': 'projects',
        'fields': table_fields,
        'headings': get_table_headings(table_fields),
        'items': items,
    }

    ctx = get_browser_context(request)
    ctx.update({
        'table': table,
        'stats': jsonify(request.resource_obj.get_stats()),

        'browser_extends': 'projects/all/base.html',
    })

    response = render(request, 'browser/index.html', ctx)
    response.set_cookie('pootle-language', 'projects')

    return response
Example #2
0
def projects_overview(request, project_set):
    """Page listing all projects"""
    items = [
        make_project_list_item(project) for project in project_set.children
    ]
    items.sort(lambda x, y: locale.strcoll(x['title'], y['title']))

    table_fields = [
        'name', 'progress', 'total', 'need-translation', 'suggestions',
        'critical', 'last-updated', 'activity'
    ]
    table = {
        'id': 'projects',
        'fields': table_fields,
        'headings': get_table_headings(table_fields),
        'items': items,
    }

    ctx = get_overview_context(request)
    ctx.update({
        'table': table,
        'stats': jsonify(request.resource_obj.get_stats()),
        'browser_extends': 'projects/all/base.html',
    })

    response = render(request, 'browser/overview.html', ctx)
    response.set_cookie('pootle-language', 'projects')

    return response
Example #3
0
 def object_children(self):
     items = [
         make_project_list_item(project) for project in self.object.children
     ]
     items = self.add_child_stats(items)
     items.sort(cmp_by_last_activity)
     return items
Example #4
0
def projects_overview(request, project_set):
    """Page listing all projects."""
    items = [
        make_project_list_item(project)
        for project in project_set.get_children()
    ]

    table_fields = [
        'name', 'progress', 'total', 'need-translation', 'suggestions',
        'critical', 'last-updated', 'activity'
    ]

    ctx = get_overview_context(request)
    ctx.update({
        'table': {
            'id': 'projects',
            'fields': table_fields,
            'headings': get_table_headings(table_fields),
            'items': items,
        },
        'browser_extends': 'projects/all/base.html',
    })

    response = render(request, 'browser/overview.html', ctx)
    response.set_cookie('pootle-language', 'projects')

    return response
Example #5
0
 def object_children(self):
     items = [
         make_project_list_item(project)
         for project
         in self.object.children]
     items.sort(
         lambda x, y: locale.strcoll(x['title'], y['title']))
     return self.add_child_stats(items)
Example #6
0
 def items(self):
     items = [
         make_project_list_item(project)
         for project
         in self.object.children]
     items.sort(
         lambda x, y: locale.strcoll(x['title'], y['title']))
     return items
Example #7
0
 def object_children(self):
     items = [
         make_project_list_item(project)
         for project
         in self.object.children]
     items = self.add_child_stats(items)
     items.sort(cmp_by_last_activity)
     return items
Example #8
0
def test_view_projects_browse(client, request_users):
    user = request_users["user"]
    client.login(username=user.username, password=request_users["password"])
    response = client.get(reverse("pootle-projects-browse"))
    assert response.cookies["pootle-language"].value == "projects"
    ctx = response.context
    request = response.wsgi_request
    user_projects = Project.accessible_by_user(request.user)
    user_projects = (Project.objects.for_user(
        request.user).filter(code__in=user_projects))
    obj = ProjectSet(user_projects)
    items = [make_project_list_item(project) for project in obj.children]
    items.sort(lambda x, y: locale.strcoll(x['title'], y['title']))
    stats = obj.data_tool.get_stats(user=request.user)
    for item in items:
        if item["code"] in stats["children"]:
            item["stats"] = stats["children"][item["code"]]
    table_fields = [
        'name', 'progress', 'total', 'need-translation', 'suggestions',
        'critical', 'last-updated', 'activity'
    ]
    table = {
        'id': 'projects',
        'fields': table_fields,
        'headings': get_table_headings(table_fields),
        'items': items
    }

    if request.user.is_superuser:
        url_action_continue = obj.get_translate_url(state='incomplete')
        url_action_fixcritical = obj.get_critical_url()
        url_action_review = obj.get_translate_url(state='suggestions')
        url_action_view_all = obj.get_translate_url(state='all')
    else:
        (url_action_continue, url_action_fixcritical, url_action_review,
         url_action_view_all) = [None] * 4
    checks = ChecksDisplay(obj).checks_by_category
    stats = StatsDisplay(obj, stats=stats).stats
    del stats["children"]
    User = get_user_model()
    top_scorers = User.top_scorers(limit=10)
    assertions = dict(page="browse",
                      pootle_path="/projects/",
                      resource_path="",
                      resource_path_parts=[],
                      object=obj,
                      table=table,
                      browser_extends="projects/all/base.html",
                      top_scorers=top_scorers,
                      top_scorers_data=get_top_scorers_data(top_scorers, 10),
                      translation_states=get_translation_states(obj),
                      url_action_continue=url_action_continue,
                      url_action_fixcritical=url_action_fixcritical,
                      url_action_review=url_action_review,
                      url_action_view_all=url_action_view_all,
                      checks=checks,
                      stats=stats)
    view_context_test(ctx, **assertions)
Example #9
0
def test_view_projects_browse(client, request_users):
    user = request_users["user"]
    client.login(
        username=user.username,
        password=request_users["password"])
    response = client.get(reverse("pootle-projects-browse"))
    assert response.cookies["pootle-language"].value == "projects"
    ctx = response.context
    request = response.wsgi_request
    user_projects = Project.accessible_by_user(request.user)
    user_projects = (
        Project.objects.for_user(request.user)
                       .filter(code__in=user_projects))
    obj = ProjectSet(user_projects)
    items = [
        make_project_list_item(project)
        for project in obj.children]
    items.sort(lambda x, y: locale.strcoll(x['title'], y['title']))
    table_fields = [
        'name', 'progress', 'total', 'need-translation',
        'suggestions', 'critical', 'last-updated', 'activity']
    table = {
        'id': 'projects',
        'fields': table_fields,
        'headings': get_table_headings(table_fields),
        'items': items}

    if request.user.is_superuser:
        url_action_continue = obj.get_translate_url(state='incomplete')
        url_action_fixcritical = obj.get_critical_url()
        url_action_review = obj.get_translate_url(state='suggestions')
        url_action_view_all = obj.get_translate_url(state='all')
    else:
        (url_action_continue,
         url_action_fixcritical,
         url_action_review,
         url_action_view_all) = [None] * 4

    User = get_user_model()
    top_scorers = User.top_scorers(limit=10)
    assertions = dict(
        page="browse",
        pootle_path="/projects/",
        resource_path="",
        resource_path_parts=[],
        object=obj,
        table=table,
        browser_extends="projects/all/base.html",
        stats=obj.data_tool.get_stats(user=request.user),
        checks=get_qualitycheck_list(obj),
        top_scorers=top_scorers,
        top_scorers_data=get_top_scorers_data(top_scorers, 10),
        translation_states=get_translation_states(obj),
        url_action_continue=url_action_continue,
        url_action_fixcritical=url_action_fixcritical,
        url_action_review=url_action_review,
        url_action_view_all=url_action_view_all)
    view_context_test(ctx, **assertions)
Example #10
0
def test_view_projects_browse(client, request_users):
    user = request_users["user"]
    client.login(
        username=user.username,
        password=request_users["password"])
    response = client.get(reverse("pootle-projects-browse"))
    assert response.cookies["pootle-language"].value == "projects"
    ctx = response.context
    request = response.wsgi_request
    user_projects = Project.accessible_by_user(request.user)
    user_projects = (
        Project.objects.for_user(request.user)
                       .filter(code__in=user_projects))
    ob = ProjectSet(user_projects)
    items = [
        make_project_list_item(project)
        for project in ob.children]
    items.sort(lambda x, y: locale.strcoll(x['title'], y['title']))
    table_fields = [
        'name', 'progress', 'total', 'need-translation',
        'suggestions', 'critical', 'last-updated', 'activity']
    table = {
        'id': 'projects',
        'fields': table_fields,
        'headings': get_table_headings(table_fields),
        'items': items}

    if request.user.is_superuser:
        url_action_continue = ob.get_translate_url(state='incomplete')
        url_action_fixcritical = ob.get_critical_url()
        url_action_review = ob.get_translate_url(state='suggestions')
        url_action_view_all = ob.get_translate_url(state='all')
    else:
        (url_action_continue,
         url_action_fixcritical,
         url_action_review,
         url_action_view_all) = [None] * 4

    assertions = dict(
        page="browse",
        pootle_path="/projects/",
        resource_path="",
        resource_path_parts=[],
        object=ob,
        table=table,
        browser_extends="projects/all/base.html",
        stats=jsonify(ob.get_stats()),
        check_categories=get_qualitycheck_schema(ob),
        translation_states=get_translation_states(ob),
        url_action_continue=url_action_continue,
        url_action_fixcritical=url_action_fixcritical,
        url_action_review=url_action_review,
        url_action_view_all=url_action_view_all)
    view_context_test(ctx, **assertions)
Example #11
0
def test_view_project_set_children(project0, store0, rf, request_users):
    request = rf.get('/projects/')
    request.user = request_users["user"]
    view = ProjectsBrowseView()
    view.request = request
    view.object = view.get_object()
    assert isinstance(view.object, ProjectSet)
    items = [
        make_project_list_item(project) for project in view.object.children
    ]
    view.add_child_stats(items)
    items.sort(cmp_by_last_activity)
    assert view.object_children == items
Example #12
0
def test_view_project_set_children(project0, store0, rf, request_users):
    request = rf.get('/projects/')
    request.user = request_users["user"]
    view = ProjectsBrowseView()
    view.request = request
    view.object = view.get_object()
    assert isinstance(view.object, ProjectSet)
    items = [
        make_project_list_item(project)
        for project
        in view.object.children]
    view.add_child_stats(items)
    items.sort(cmp_by_last_activity)
    assert view.object_children == items
Example #13
0
def test_view_project_set_children(project0, store0, rf, request_users):
    request = rf.get('/projects/')
    request.user = request_users["user"]
    view = ProjectsBrowseView()
    view.request = request
    view.object = view.get_object()
    assert isinstance(view.object, ProjectSet)
    items = [
        make_project_list_item(project)
        for project
        in view.object.children]
    items.sort(
        lambda x, y: locale.strcoll(x['title'], y['title']))
    view.add_child_stats(items)
    assert view.object_children == items
Example #14
0
def projects_index(request, root):
    """Page listing all projects."""
    user_accessible_projects = Project.accessible_by_user(request.user)
    user_projects = Project.objects.filter(code__in=user_accessible_projects)
    items = [make_project_list_item(project) for project in user_projects]

    table_fields = ['name']

    ctx = {
        'table': {
            'id': 'projects',
            'fields': table_fields,
            'headings': get_table_headings(table_fields),
            'items': items,
        },
    }

    return render(request, "projects/list.html", ctx)
Example #15
0
def projects_index(request, root):
    """Page listing all projects."""
    user_accessible_projects = Project.accessible_by_user(request.user)
    user_projects = Project.objects.filter(code__in=user_accessible_projects)
    items = [make_project_list_item(project) for project in user_projects]

    table_fields = ["name"]

    ctx = {
        "table": {
            "id": "projects",
            "fields": table_fields,
            "headings": get_table_headings(table_fields),
            "items": items,
        }
    }

    return render(request, "projects/list.html", ctx)
Example #16
0
def test_view_projects_browse(site_permissions, site_matrix_with_vfolders,
                              site_matrix_with_announcements,
                              client, nobody, default):
    response = client.get(reverse("pootle-projects-browse"))
    assert response.cookies["pootle-language"].value == "projects"
    ctx = response.context
    request = response.wsgi_request
    user_projects = Project.accessible_by_user(request.user)
    user_projects = (
        Project.objects.for_user(request.user)
                       .filter(code__in=user_projects))
    ob = ProjectSet(user_projects)
    items = [
        make_project_list_item(project)
        for project in ob.children]
    items.sort(lambda x, y: locale.strcoll(x['title'], y['title']))
    table_fields = [
        'name', 'progress', 'total', 'need-translation',
        'suggestions', 'critical', 'last-updated', 'activity']
    table = {
        'id': 'projects',
        'fields': table_fields,
        'headings': get_table_headings(table_fields),
        'items': items}
    assertions = dict(
        page="browse",
        pootle_path="/projects/",
        resource_path="",
        resource_path_parts=[],
        object=ob,
        table=table,
        browser_extends="projects/all/base.html",
        stats=jsonify(ob.get_stats()),
        check_categories=get_qualitycheck_schema(ob),
        translation_states=get_translation_states(ob),
        url_action_continue=ob.get_translate_url(state='incomplete'),
        url_action_fixcritical=ob.get_critical_url(),
        url_action_review=ob.get_translate_url(state='suggestions'),
        url_action_view_all=ob.get_translate_url(state='all'))
    view_context_test(ctx, **assertions)
Example #17
0
def test_view_projects_browse(
    site_permissions, site_matrix_with_vfolders, site_matrix_with_announcements, client, nobody, default
):
    response = client.get(reverse("pootle-projects-browse"))
    assert response.cookies["pootle-language"].value == "projects"
    ctx = response.context
    request = response.wsgi_request
    user_projects = Project.accessible_by_user(request.user)
    user_projects = Project.objects.for_user(request.user).filter(code__in=user_projects)
    ob = ProjectSet(user_projects)
    items = [make_project_list_item(project) for project in ob.children]
    items.sort(lambda x, y: locale.strcoll(x["title"], y["title"]))
    table_fields = [
        "name",
        "progress",
        "total",
        "need-translation",
        "suggestions",
        "critical",
        "last-updated",
        "activity",
    ]
    table = {"id": "projects", "fields": table_fields, "headings": get_table_headings(table_fields), "items": items}
    assertions = dict(
        page="browse",
        pootle_path="/projects/",
        resource_path="",
        resource_path_parts=[],
        resource_obj=ob,
        table=table,
        browser_extends="projects/all/base.html",
        stats=jsonify(ob.get_stats()),
        check_categories=get_qualitycheck_schema(ob),
        translation_states=get_translation_states(ob),
        url_action_continue=ob.get_translate_url(state="incomplete"),
        url_action_fixcritical=ob.get_critical_url(),
        url_action_review=ob.get_translate_url(state="suggestions"),
        url_action_view_all=ob.get_translate_url(state="all"),
    )
    view_context_test(ctx, **assertions)
Example #18
0
def projects_overview(request, project_set):
    """Page listing all projects."""
    items = [make_project_list_item(project)
             for project in project_set.get_children()]

    table_fields = ['name', 'progress', 'total', 'need-translation',
                    'suggestions', 'critical', 'last-updated', 'activity']

    ctx = get_overview_context(request)
    ctx.update({
        'table': {
            'id': 'projects',
            'fields': table_fields,
            'headings': get_table_headings(table_fields),
            'items': items,
        },

        'browser_extends': 'projects/all/base.html',
    })

    response = render(request, 'browser/overview.html', ctx)
    response.set_cookie('pootle-language', 'projects')

    return response