def _test_translate_view(tp, request, response, kwargs, settings): ctx = response.context kwargs["project_code"] = tp.project.code kwargs["language_code"] = tp.language.code resource_path = "%(dir_path)s%(filename)s" % kwargs request_path = "%s%s" % (tp.pootle_path, resource_path) vfolder, pootle_path = extract_vfolder_from_path(request_path) current_vfolder_pk = vfolder.pk if vfolder else "" display_priority = not current_vfolder_pk and ( VirtualFolderTreeItem.objects.filter(pootle_path__startswith=pootle_path).exists() ) assertions = dict( page="translate", translation_project=tp, language=tp.language, project=tp.project, is_admin=False, profile=request.profile, ctx_path=tp.pootle_path, pootle_path=request_path, resource_path=resource_path, resource_path_parts=get_path_parts(resource_path), editor_extends="translation_projects/base.html", check_categories=get_qualitycheck_schema(), previous_url=get_previous_url(request), current_vfolder_pk=current_vfolder_pk, display_priority=display_priority, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL, ) view_context_test(ctx, **assertions)
def test_view_projects_translate(client, settings, request_users): user = request_users["user"] client.login( username=user.username, password=request_users["password"]) response = client.get(reverse("pootle-projects-translate")) if not user.is_superuser: assert response.status_code == 403 return ctx = response.context request = response.wsgi_request assertions = dict( page="translate", has_admin_access=user.is_superuser, language=None, project=None, pootle_path="/projects/", ctx_path="/projects/", resource_path="", resource_path_parts=[], editor_extends="projects/all/base.html", check_categories=get_qualitycheck_schema(), previous_url=get_previous_url(request), display_priority=False, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), current_vfolder_pk="", POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL) view_context_test(ctx, **assertions)
def _test_translate_view(tp, request, response, kwargs, settings): ctx = response.context kwargs["project_code"] = tp.project.code kwargs["language_code"] = tp.language.code resource_path = "%(dir_path)s%(filename)s" % kwargs request_path = "%s%s" % (tp.pootle_path, resource_path) vfolder, pootle_path = extract_vfolder_from_path(request_path) current_vfolder_pk = (vfolder.pk if vfolder else "") display_priority = (not current_vfolder_pk and not kwargs['filename'] and ctx['object'].has_vfolders) assertions = dict(page="translate", translation_project=tp, language=tp.language, project=tp.project, is_admin=check_permission('administrate', request), ctx_path=tp.pootle_path, pootle_path=request_path, resource_path=resource_path, resource_path_parts=get_path_parts(resource_path), editor_extends="translation_projects/base.html", check_categories=get_qualitycheck_schema(), previous_url=get_previous_url(request), current_vfolder_pk=current_vfolder_pk, display_priority=display_priority, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL) view_context_test(ctx, **assertions)
def _test_translate_view(project, request, response, kwargs, settings): ctx = response.context user = request.profile kwargs["project_code"] = project.code ctx_path = "/projects/%(project_code)s/" % kwargs resource_path = "%(dir_path)s%(filename)s" % kwargs pootle_path = "%s%s" % (ctx_path, resource_path) view_context_test( ctx, **dict( page="translate", is_admin=False, language=None, project=project, profile=user, pootle_path="%s%s" % (ctx_path, resource_path), ctx_path=ctx_path, resource_path=resource_path, resource_path_parts=get_path_parts(resource_path), editor_extends="projects/base.html", check_categories=get_qualitycheck_schema(), previous_url=get_previous_url(request), display_priority=(VirtualFolderTreeItem.objects.filter(pootle_path__startswith=pootle_path).exists()), cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), current_vfolder_pk="", POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL, ) )
def _test_translate_view(project, request, response, kwargs, settings): ctx = response.context kwargs["project_code"] = project.code ctx_path = ("/projects/%(project_code)s/" % kwargs) resource_path = ("%(dir_path)s%(filename)s" % kwargs) pootle_path = "%s%s" % (ctx_path, resource_path) view_context_test( ctx, **dict(page="translate", is_admin=False, language=None, project=project, pootle_path=pootle_path, ctx_path=ctx_path, resource_path=resource_path, resource_path_parts=get_path_parts(resource_path), editor_extends="projects/base.html", check_categories=get_qualitycheck_schema(), previous_url=get_previous_url(request), display_priority=(VirtualFolderTreeItem.objects.filter( pootle_path__startswith=pootle_path).exists()), cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), current_vfolder_pk="", POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL))
def _test_translate_view(project, request, response, kwargs, settings): if not request.user.is_superuser: assert response.status_code == 403 return ctx = response.context kwargs["project_code"] = project.code ctx_path = ("/projects/%(project_code)s/" % kwargs) resource_path = ("%(dir_path)s%(filename)s" % kwargs) pootle_path = "%s%s" % (ctx_path, resource_path) display_priority = False view_context_test( ctx, **dict(page="translate", has_admin_access=request.user.is_superuser, language=None, project=project, pootle_path=pootle_path, ctx_path=ctx_path, resource_path=resource_path, resource_path_parts=get_path_parts(resource_path), editor_extends="projects/base.html", check_categories=get_qualitycheck_schema(), previous_url=get_previous_url(request), display_priority=display_priority, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), current_vfolder_pk="", POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL))
def test_view_projects_translate(site_permissions, site_matrix_with_vfolders, client, nobody, default, settings): response = client.get(reverse("pootle-projects-translate")) ctx = response.context request = response.wsgi_request assertions = dict( page="translate", is_admin=False, language=None, project=None, profile=request.profile, pootle_path="/projects/", ctx_path="/projects/", resource_path="", resource_path_parts=[], editor_extends="projects/all/base.html", check_categories=get_qualitycheck_schema(), previous_url=get_previous_url(request), display_priority=False, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), current_vfolder_pk="", POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL, ) view_context_test(ctx, **assertions)
def test_view_projects_translate(client, settings, request_users): user = request_users["user"] client.login(username=user.username, password=request_users["password"]) response = client.get(reverse("pootle-projects-translate")) if not user.is_superuser: assert response.status_code == 403 return ctx = response.context request = response.wsgi_request assertions = dict(page="translate", is_admin=False, language=None, project=None, pootle_path="/projects/", ctx_path="/projects/", resource_path="", resource_path_parts=[], editor_extends="projects/all/base.html", check_categories=get_qualitycheck_schema(), previous_url=get_previous_url(request), display_priority=False, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), current_vfolder_pk="", POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL) view_context_test(ctx, **assertions)
def _test_vf_translate_view(tp, request, response, kwargs, settings): from .tp import view_context_test ctx = response.context obj = ctx["object"] kwargs["project_code"] = tp.project.code kwargs["language_code"] = tp.language.code resource_path = "%(dir_path)s%(filename)s" % kwargs request_path = "%s%s" % (tp.pootle_path, resource_path) checks = get_qualitychecks() schema = {sc["code"]: sc for sc in get_qualitycheck_schema()} vfolder_pk = response.context["current_vfolder_pk"] check_data = DirectoryVFDataTool(obj).get_checks(user=request.user).get( vfolder_pk, {}) _checks = {} for check, checkid in checks.items(): if check not in check_data: continue _checkid = schema[checkid]["name"] _checks[_checkid] = _checks.get( _checkid, dict(checks=[], title=schema[checkid]["title"])) _checks[_checkid]["checks"].append( dict(code=check, title=CHECK_NAMES[check], count=check_data[check])) _checks = OrderedDict( (k, _checks[k]) for k in CATEGORY_IDS.keys() if _checks.get(k)) vfolder = VirtualFolder.objects.get( name=request.resolver_match.kwargs["vfolder_name"]) current_vfolder_pk = vfolder.pk display_priority = False unit_api_root = reverse("vfolder-pootle-xhr-units", kwargs=dict(vfolder_name=vfolder.name)) resource_path = ("/".join([ "++vfolder", vfolder.name, ctx['object'].pootle_path.replace(tp.pootle_path, "") ])) assertions = dict(page="translate", translation_project=tp, language=tp.language, project=tp.project, has_admin_access=check_permission( 'administrate', request), ctx_path=tp.pootle_path, pootle_path=request_path, resource_path=resource_path, resource_path_parts=get_path_parts(resource_path), editor_extends="translation_projects/base.html", checks=_checks, previous_url=get_previous_url(request), current_vfolder_pk=current_vfolder_pk, display_priority=display_priority, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), unit_api_root=unit_api_root, POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL) view_context_test(ctx, **assertions)
def _test_translate_view(language, request, response, kwargs, settings): ctx = response.context view_context_test( ctx, **dict( project=None, language=language, page="translate", ctx_path=language.directory.pootle_path, pootle_path=language.directory.pootle_path, resource_path="", resource_path_parts=[], profile=request.profile, editor_extends="languages/base.html", check_categories=get_qualitycheck_schema(), previous_url=get_previous_url(request), display_priority=False, is_admin=check_permission('administrate', request), cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), current_vfolder_pk="", POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL))
def test_view_projects_translate(client, settings, request_users): user = request_users["user"] client.login( username=user.username, password=request_users["password"]) response = client.get(reverse("pootle-projects-translate")) if not user.is_superuser: assert response.status_code == 403 return 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) checks = get_qualitychecks() schema = {sc["code"]: sc for sc in get_qualitycheck_schema()} check_data = obj.data_tool.get_checks() _checks = {} for check, checkid in checks.items(): if check not in check_data: continue _checkid = schema[checkid]["name"] _checks[_checkid] = _checks.get( _checkid, dict(checks=[], title=schema[checkid]["title"])) _checks[_checkid]["checks"].append( dict( code=check, title=check_names[check], count=check_data[check])) _checks = OrderedDict( (k, _checks[k]) for k in CATEGORY_IDS.keys() if _checks.get(k)) assertions = dict( page="translate", has_admin_access=user.is_superuser, language=None, project=None, pootle_path="/projects/", ctx_path="/projects/", resource_path="", resource_path_parts=[], editor_extends="projects/all/base.html", checks=_checks, previous_url=get_previous_url(request), display_priority=False, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), current_vfolder_pk="", POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL) view_context_test(ctx, **assertions)
def _test_translate_view(tp, request, response, kwargs, settings): ctx = response.context obj = ctx["object"] kwargs["project_code"] = tp.project.code kwargs["language_code"] = tp.language.code resource_path = "%(dir_path)s%(filename)s" % kwargs request_path = "%s%s" % (tp.pootle_path, resource_path) checks = get_qualitychecks() schema = {sc["code"]: sc for sc in get_qualitycheck_schema()} check_data = obj.data_tool.get_checks() _checks = {} for check, checkid in checks.items(): if check not in check_data: continue _checkid = schema[checkid]["name"] _checks[_checkid] = _checks.get( _checkid, dict(checks=[], title=schema[checkid]["title"])) _checks[_checkid]["checks"].append( dict( code=check, title=CHECK_NAMES[check], count=check_data[check])) _checks = OrderedDict( (k, _checks[k]) for k in CATEGORY_IDS.keys() if _checks.get(k)) current_vfolder_pk = "" display_priority = False if not kwargs["filename"]: vf_view = vfolders_data_view.get(obj.__class__)(obj, request.user) display_priority = vf_view.has_data unit_api_root = "/xhr/units/" assertions = dict( page="translate", translation_project=tp, language=tp.language, project=tp.project, has_admin_access=check_permission('administrate', request), ctx_path=tp.pootle_path, pootle_path=request_path, resource_path=resource_path, resource_path_parts=get_path_parts(resource_path), editor_extends="translation_projects/base.html", checks=_checks, previous_url=get_previous_url(request), current_vfolder_pk=current_vfolder_pk, display_priority=display_priority, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), unit_api_root=unit_api_root, POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL) view_context_test(ctx, **assertions)
def _test_translate_view(project, request, response, kwargs, settings): if not request.user.is_superuser: assert response.status_code == 403 return ctx = response.context kwargs["project_code"] = project.code ctx_path = ( "/projects/%(project_code)s/" % kwargs) resource_path = ( "%(dir_path)s%(filename)s" % kwargs) pootle_path = "%s%s" % (ctx_path, resource_path) display_priority = False checks = get_qualitychecks() schema = {sc["code"]: sc for sc in get_qualitycheck_schema()} check_data = ctx["object"].data_tool.get_checks() _checks = {} for check, checkid in checks.items(): if check not in check_data: continue _checkid = schema[checkid]["name"] _checks[_checkid] = _checks.get( _checkid, dict(checks=[], title=schema[checkid]["title"])) _checks[_checkid]["checks"].append( dict( code=check, title=check_names[check], count=check_data[check])) _checks = OrderedDict( (k, _checks[k]) for k in CATEGORY_IDS.keys() if _checks.get(k)) view_context_test( ctx, **dict( page="translate", has_admin_access=request.user.is_superuser, language=None, project=project, pootle_path=pootle_path, ctx_path=ctx_path, resource_path=resource_path, resource_path_parts=get_path_parts(resource_path), editor_extends="projects/base.html", checks=_checks, previous_url=get_previous_url(request), display_priority=display_priority, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), current_vfolder_pk="", POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL))
def _test_translate_view(tp, request, response, kwargs, settings): ctx = response.context obj = ctx["object"] kwargs["project_code"] = tp.project.code kwargs["language_code"] = tp.language.code resource_path = "%(dir_path)s%(filename)s" % kwargs request_path = "%s%s" % (tp.pootle_path, resource_path) checks = get_qualitychecks() schema = {sc["code"]: sc for sc in get_qualitycheck_schema()} check_data = obj.data_tool.get_checks() _checks = {} for check, checkid in checks.items(): if check not in check_data: continue _checkid = schema[checkid]["name"] _checks[_checkid] = _checks.get( _checkid, dict(checks=[], title=schema[checkid]["title"])) _checks[_checkid]["checks"].append( dict(code=check, title=check_names[check], count=check_data[check])) _checks = OrderedDict( (k, _checks[k]) for k in CATEGORY_IDS.keys() if _checks.get(k)) current_vfolder_pk = "" display_priority = False if not kwargs["filename"]: vf_view = vfolders_data_view.get(obj.__class__)(obj, request.user) display_priority = vf_view.has_data unit_api_root = "/xhr/units/" assertions = dict(page="translate", translation_project=tp, language=tp.language, project=tp.project, has_admin_access=check_permission( 'administrate', request), ctx_path=tp.pootle_path, pootle_path=request_path, resource_path=resource_path, resource_path_parts=get_path_parts(resource_path), editor_extends="translation_projects/base.html", checks=_checks, previous_url=get_previous_url(request), current_vfolder_pk=current_vfolder_pk, display_priority=display_priority, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), unit_api_root=unit_api_root, POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL) view_context_test(ctx, **assertions)
def _test_translate_view(tp, request, response, kwargs, settings): ctx = response.context obj = ctx["object"] kwargs["project_code"] = tp.project.code kwargs["language_code"] = tp.language.code resource_path = "%(dir_path)s%(filename)s" % kwargs request_path = "%s%s" % (tp.pootle_path, resource_path) if request.path.startswith("/++vfolder"): vfolder = VirtualFolder.objects.get( name=request.resolver_match.kwargs["vfolder_name"]) current_vfolder_pk = vfolder.pk display_priority = False unit_api_root = reverse( "vfolder-pootle-xhr-units", kwargs=dict(vfolder_name=vfolder.name)) resource_path = ( "/".join( ["++vfolder", vfolder.name, ctx['object'].pootle_path.replace(tp.pootle_path, "")])) else: vfolder = None current_vfolder_pk = "" display_priority = False if not kwargs["filename"]: vf_view = vfolders_data_view.get(obj.__class__)(obj, request.user) display_priority = vf_view.has_data unit_api_root = "/xhr/units/" assertions = dict( page="translate", translation_project=tp, language=tp.language, project=tp.project, has_admin_access=check_permission('administrate', request), ctx_path=tp.pootle_path, pootle_path=request_path, resource_path=resource_path, resource_path_parts=get_path_parts(resource_path), editor_extends="translation_projects/base.html", check_categories=get_qualitycheck_schema(), previous_url=get_previous_url(request), current_vfolder_pk=current_vfolder_pk, display_priority=display_priority, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), unit_api_root=unit_api_root, POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL) view_context_test(ctx, **assertions)
def test_view_projects_translate(client, settings, request_users): user = request_users["user"] client.login(username=user.username, password=request_users["password"]) response = client.get(reverse("pootle-projects-translate")) if not user.is_superuser: assert response.status_code == 403 return 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) checks = get_qualitychecks() schema = {sc["code"]: sc for sc in get_qualitycheck_schema()} check_data = obj.data_tool.get_checks() _checks = {} for check, checkid in checks.items(): if check not in check_data: continue _checkid = schema[checkid]["name"] _checks[_checkid] = _checks.get( _checkid, dict(checks=[], title=schema[checkid]["title"])) _checks[_checkid]["checks"].append( dict(code=check, title=check_names[check], count=check_data[check])) _checks = OrderedDict( (k, _checks[k]) for k in CATEGORY_IDS.keys() if _checks.get(k)) assertions = dict(page="translate", has_admin_access=user.is_superuser, language=None, project=None, pootle_path="/projects/", ctx_path="/projects/", resource_path="", resource_path_parts=[], editor_extends="projects/all/base.html", checks=_checks, previous_url=get_previous_url(request), display_priority=False, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), current_vfolder_pk="", POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL) view_context_test(ctx, **assertions)
def _test_translate_view(tp, request, response, kwargs, settings): ctx = response.context obj = ctx["object"] kwargs["project_code"] = tp.project.code kwargs["language_code"] = tp.language.code resource_path = "%(dir_path)s%(filename)s" % kwargs request_path = "%s%s" % (tp.pootle_path, resource_path) if request.path.startswith("/++vfolder"): vfolder = VirtualFolder.objects.get( name=request.resolver_match.kwargs["vfolder_name"]) current_vfolder_pk = vfolder.pk display_priority = False unit_api_root = reverse("vfolder-pootle-xhr-units", kwargs=dict(vfolder_name=vfolder.name)) resource_path = ("/".join([ "++vfolder", vfolder.name, ctx['object'].pootle_path.replace(tp.pootle_path, "") ])) else: vfolder = None current_vfolder_pk = "" display_priority = False if not kwargs["filename"]: vf_view = vfolders_data_view.get(obj.__class__)(obj, request.user) display_priority = vf_view.has_data unit_api_root = "/xhr/units/" assertions = dict(page="translate", translation_project=tp, language=tp.language, project=tp.project, has_admin_access=check_permission( 'administrate', request), ctx_path=tp.pootle_path, pootle_path=request_path, resource_path=resource_path, resource_path_parts=get_path_parts(resource_path), editor_extends="translation_projects/base.html", check_categories=get_qualitycheck_schema(), previous_url=get_previous_url(request), current_vfolder_pk=current_vfolder_pk, display_priority=display_priority, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), unit_api_root=unit_api_root, POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL) view_context_test(ctx, **assertions)
def _test_translate_view(project, request, response, kwargs, settings): if not request.user.is_superuser: assert response.status_code == 403 return ctx = response.context kwargs["project_code"] = project.code ctx_path = ("/projects/%(project_code)s/" % kwargs) resource_path = ("%(dir_path)s%(filename)s" % kwargs) pootle_path = "%s%s" % (ctx_path, resource_path) display_priority = False checks = get_qualitychecks() schema = {sc["code"]: sc for sc in get_qualitycheck_schema()} check_data = ctx["object"].data_tool.get_checks() _checks = {} for check, checkid in checks.items(): if check not in check_data: continue _checkid = schema[checkid]["name"] _checks[_checkid] = _checks.get( _checkid, dict(checks=[], title=schema[checkid]["title"])) _checks[_checkid]["checks"].append( dict(code=check, title=check_names[check], count=check_data[check])) _checks = OrderedDict( (k, _checks[k]) for k in CATEGORY_IDS.keys() if _checks.get(k)) view_context_test( ctx, **dict(page="translate", has_admin_access=request.user.is_superuser, language=None, project=project, pootle_path=pootle_path, ctx_path=ctx_path, resource_path=resource_path, resource_path_parts=get_path_parts(resource_path), editor_extends="projects/base.html", checks=_checks, previous_url=get_previous_url(request), display_priority=display_priority, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), current_vfolder_pk="", POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL))
def get_context_data(self, *args, **kwargs): ctx = super(PootleTranslateView, self).get_context_data(*args, **kwargs) ctx.update({ 'page': 'translate', 'ctx_path': self.ctx_path, 'check_categories': get_qualitycheck_schema(), 'cantranslate': check_permission("translate", self.request), 'cansuggest': check_permission("suggest", self.request), 'canreview': check_permission("review", self.request), 'search_form': make_search_form(request=self.request), 'previous_url': get_previous_url(self.request), 'ZING_MT_BACKENDS': settings.ZING_MT_BACKENDS, 'editor_extends': self.template_extends, }) return ctx
def get_context_data(self, *args, **kwargs): ctx = super().get_context_data(*args, **kwargs) ctx.update( { "page": "translate", "ctx_path": self.ctx_path, "check_categories": get_qualitycheck_schema(), "cantranslate": check_permission("translate", self.request), "cansuggest": check_permission("suggest", self.request), "canreview": check_permission("review", self.request), "search_form": make_search_form(request=self.request), "previous_url": get_previous_url(self.request), "ZING_MT_BACKENDS": settings.ZING_MT_BACKENDS, "editor_extends": self.template_extends, } ) return ctx
def get_context_data(self, *args, **kwargs): ctx = super(PootleTranslateView, self).get_context_data(*args, **kwargs) ctx.update( {'page': 'translate', 'current_vfolder_pk': self.vfolder_pk, 'ctx_path': self.ctx_path, 'display_priority': self.display_vfolder_priority, 'check_categories': get_qualitycheck_schema(), 'cantranslate': check_permission("translate", self.request), 'cansuggest': check_permission("suggest", self.request), 'canreview': check_permission("review", self.request), 'search_form': make_search_form(request=self.request), 'previous_url': get_previous_url(self.request), 'POOTLE_MT_BACKENDS': settings.POOTLE_MT_BACKENDS, 'AMAGAMA_URL': settings.AMAGAMA_URL, 'editor_extends': self.template_extends}) return ctx
def get_context_data(self, *args, **kwargs): ctx = super(PootleTranslateView, self).get_context_data(*args, **kwargs) ctx.update( {'page': self.page_name, 'chunk_size': self.chunk_size, 'current_vfolder_pk': self.vfolder_pk, 'ctx_path': self.ctx_path, 'display_priority': self.display_vfolder_priority, 'checks': self.checks, 'cantranslate': check_permission("translate", self.request), 'cansuggest': check_permission("suggest", self.request), 'canreview': check_permission("review", self.request), 'search_form': make_search_form(request=self.request), 'previous_url': get_previous_url(self.request), 'POOTLE_MT_BACKENDS': settings.POOTLE_MT_BACKENDS, 'AMAGAMA_URL': settings.AMAGAMA_URL, 'editor_extends': self.template_extends}) return ctx
def _test_translate_view(language, request, response, kwargs, settings): ctx = response.context checks = get_qualitychecks() schema = {sc["code"]: sc for sc in get_qualitycheck_schema()} check_data = language.data_tool.get_checks() _checks = {} for check, checkid in checks.items(): if check not in check_data: continue _checkid = schema[checkid]["name"] _checks[_checkid] = _checks.get( _checkid, dict(checks=[], title=schema[checkid]["title"])) _checks[_checkid]["checks"].append( dict( code=check, title=check_names[check], count=check_data[check])) _checks = OrderedDict( (k, _checks[k]) for k in CATEGORY_IDS.keys() if _checks.get(k)) view_context_test( ctx, **dict( project=None, language=language, page="translate", ctx_path=language.directory.pootle_path, pootle_path=language.directory.pootle_path, resource_path="", resource_path_parts=[], editor_extends="languages/base.html", checks=_checks, previous_url=get_previous_url(request), display_priority=False, has_admin_access=check_permission('administrate', request), cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), current_vfolder_pk="", POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL))
def get_context_data(self, *args, **kwargs): ctx = super(PootleTranslateView, self).get_context_data(*args, **kwargs) ctx.update( { "page": self.page_name, "current_vfolder_pk": self.vfolder_pk, "ctx_path": self.ctx_path, "display_priority": self.display_vfolder_priority, "checks": self.checks, "cantranslate": check_permission("translate", self.request), "cansuggest": check_permission("suggest", self.request), "canreview": check_permission("review", self.request), "search_form": make_search_form(request=self.request), "previous_url": get_previous_url(self.request), "POOTLE_MT_BACKENDS": settings.POOTLE_MT_BACKENDS, "AMAGAMA_URL": settings.AMAGAMA_URL, "editor_extends": self.template_extends, } ) return ctx
def _test_translate_view(language, request, response, kwargs, settings): ctx = response.context view_context_test( ctx, **dict(project=None, language=language, page="translate", ctx_path=language.directory.pootle_path, pootle_path=language.directory.pootle_path, resource_path="", resource_path_parts=[], editor_extends="languages/base.html", check_categories=get_qualitycheck_schema(), previous_url=get_previous_url(request), display_priority=False, is_admin=check_permission('administrate', request), cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), current_vfolder_pk="", POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL))
def _test_translate_view(project, request, response, kwargs, settings): if not request.user.is_superuser: assert response.status_code == 403 return ctx = response.context kwargs["project_code"] = project.code ctx_path = ( "/projects/%(project_code)s/" % kwargs) resource_path = ( "%(dir_path)s%(filename)s" % kwargs) pootle_path = "%s%s" % (ctx_path, resource_path) display_priority = False view_context_test( ctx, **dict( page="translate", has_admin_access=request.user.is_superuser, language=None, project=project, pootle_path=pootle_path, ctx_path=ctx_path, resource_path=resource_path, resource_path_parts=get_path_parts(resource_path), editor_extends="projects/base.html", check_categories=get_qualitycheck_schema(), previous_url=get_previous_url(request), display_priority=display_priority, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), current_vfolder_pk="", POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL))
def _test_translate_view(tp, request, response, kwargs, settings): ctx = response.context kwargs["project_code"] = tp.project.code kwargs["language_code"] = tp.language.code resource_path = "%(dir_path)s%(filename)s" % kwargs request_path = "%s%s" % (tp.pootle_path, resource_path) vfolder, pootle_path = extract_vfolder_from_path(request_path) current_vfolder_pk = ( vfolder.pk if vfolder else "") display_priority = ( not current_vfolder_pk and not kwargs['filename'] and ctx['object'].has_vfolders) assertions = dict( page="translate", translation_project=tp, language=tp.language, project=tp.project, has_admin_access=check_permission('administrate', request), ctx_path=tp.pootle_path, pootle_path=request_path, resource_path=resource_path, resource_path_parts=get_path_parts(resource_path), editor_extends="translation_projects/base.html", check_categories=get_qualitycheck_schema(), previous_url=get_previous_url(request), current_vfolder_pk=current_vfolder_pk, display_priority=display_priority, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL) view_context_test(ctx, **assertions)
def _test_vf_translate_view(tp, request, response, kwargs, settings): from .tp import view_context_test ctx = response.context obj = ctx["object"] kwargs["project_code"] = tp.project.code kwargs["language_code"] = tp.language.code resource_path = "%(dir_path)s%(filename)s" % kwargs request_path = "%s%s" % (tp.pootle_path, resource_path) checks = get_qualitychecks() schema = {sc["code"]: sc for sc in get_qualitycheck_schema()} vfolder_pk = response.context["current_vfolder_pk"] check_data = DirectoryVFDataTool(obj).get_checks( user=request.user).get(vfolder_pk, {}) _checks = {} for check, checkid in checks.items(): if check not in check_data: continue _checkid = schema[checkid]["name"] _checks[_checkid] = _checks.get( _checkid, dict(checks=[], title=schema[checkid]["title"])) _checks[_checkid]["checks"].append( dict( code=check, title=check_names[check], count=check_data[check])) _checks = OrderedDict( (k, _checks[k]) for k in CATEGORY_IDS.keys() if _checks.get(k)) vfolder = VirtualFolder.objects.get( name=request.resolver_match.kwargs["vfolder_name"]) current_vfolder_pk = vfolder.pk display_priority = False unit_api_root = reverse( "vfolder-pootle-xhr-units", kwargs=dict(vfolder_name=vfolder.name)) resource_path = ( "/".join( ["++vfolder", vfolder.name, ctx['object'].pootle_path.replace(tp.pootle_path, "")])) assertions = dict( page="translate", translation_project=tp, language=tp.language, project=tp.project, has_admin_access=check_permission('administrate', request), ctx_path=tp.pootle_path, pootle_path=request_path, resource_path=resource_path, resource_path_parts=get_path_parts(resource_path), editor_extends="translation_projects/base.html", checks=_checks, previous_url=get_previous_url(request), current_vfolder_pk=current_vfolder_pk, display_priority=display_priority, cantranslate=check_permission("translate", request), cansuggest=check_permission("suggest", request), canreview=check_permission("review", request), search_form=make_search_form(request=request), unit_api_root=unit_api_root, POOTLE_MT_BACKENDS=settings.POOTLE_MT_BACKENDS, AMAGAMA_URL=settings.AMAGAMA_URL) view_context_test(ctx, **assertions)