Formatting
Some checks failed
Test before pr merge / test-lint (pull_request) Successful in 44s
Test before pr merge / test-translation-lint (pull_request) Successful in 40s
Test before pr merge / test-before-merge (pull_request) Failing after 1m38s

This commit is contained in:
Sven Heidemann 2025-03-08 09:50:01 +01:00
parent 86bd5fb545
commit 7de31f5d32
12 changed files with 128 additions and 108 deletions

View File

@ -16,9 +16,12 @@ class GroupQuery(DbModelQueryABC):
self.field( self.field(
ResolverFieldBuilder("shortUrls") ResolverFieldBuilder("shortUrls")
.with_resolver(self._get_urls) .with_resolver(self._get_urls)
.with_require_any([ .with_require_any(
[
Permissions.groups, Permissions.groups,
], [group_by_assignment_resolver]) ],
[group_by_assignment_resolver],
)
) )
self.set_field("roles", self._get_roles) self.set_field("roles", self._get_roles)

View File

@ -120,7 +120,7 @@ class Query(QueryABC):
Permissions.short_urls_create, Permissions.short_urls_create,
Permissions.short_urls_update, Permissions.short_urls_update,
], ],
[group_by_assignment_resolver] [group_by_assignment_resolver],
) )
) )
self.field( self.field(

View File

@ -12,11 +12,19 @@ async def group_by_assignment_resolver(ctx: QueryContext) -> bool:
groups = [await x.group for x in ctx.data.nodes] groups = [await x.group for x in ctx.data.nodes]
role_ids = {x.id for x in await ctx.user.roles} role_ids = {x.id for x in await ctx.user.roles}
filtered_groups = [ filtered_groups = [
g.id for g in groups if g.id
g is not None and (roles := await groupDao.get_roles(g.id)) and all(r.id in role_ids for r in roles) for g in groups
if g is not None
and (roles := await groupDao.get_roles(g.id))
and all(r.id in role_ids for r in roles)
] ]
ctx.data.nodes = [node for node in ctx.data.nodes if (await node.group) is not None and (await node.group).id in filtered_groups] ctx.data.nodes = [
node
for node in ctx.data.nodes
if (await node.group) is not None
and (await node.group).id in filtered_groups
]
return True return True
return True return True

View File

@ -9,7 +9,7 @@ TRequireAnyResolvers = list[
Union[ Union[
Callable[[QueryContext], bool], Callable[[QueryContext], bool],
Awaitable[[QueryContext], bool], Awaitable[[QueryContext], bool],
Callable[[QueryContext], Coroutine[Any, Any, bool]] Callable[[QueryContext], Coroutine[Any, Any, bool]],
] ]
] ]
TRequireAny = tuple[TRequireAnyPermissions, TRequireAnyResolvers] TRequireAny = tuple[TRequireAnyPermissions, TRequireAnyResolvers]

View File

@ -506,7 +506,11 @@ class DataAccessObjectABC(ABC, Database, Generic[T_DBM]):
" OR ".join( " OR ".join(
self._build_fuzzy_conditions( self._build_fuzzy_conditions(
[ [
self.__db_names[x] if x in self.__db_names else self.__db_names[camel_to_snake(x)] (
self.__db_names[x]
if x in self.__db_names
else self.__db_names[camel_to_snake(x)]
)
for x in get_value(values, "fields", list[str]) for x in get_value(values, "fields", list[str])
], ],
get_value(values, "term", str), get_value(values, "term", str),

View File

@ -38,8 +38,13 @@ def get_value(
if ( if (
cast_type if not hasattr(cast_type, "__origin__") else cast_type.__origin__ cast_type if not hasattr(cast_type, "__origin__") else cast_type.__origin__
) == list: ) == list:
if not (value.startswith("[") and value.endswith("]")) and list_delimiter not in value: if (
raise ValueError("List values must be enclosed in square brackets or use a delimiter.") not (value.startswith("[") and value.endswith("]"))
and list_delimiter not in value
):
raise ValueError(
"List values must be enclosed in square brackets or use a delimiter."
)
if value.startswith("[") and value.endswith("]"): if value.startswith("[") and value.endswith("]"):
value = value[1:-1] value = value[1:-1]

View File

@ -4,5 +4,6 @@ import re
def first_to_lower(s: str) -> str: def first_to_lower(s: str) -> str:
return s[0].lower() + s[1:] if s else s return s[0].lower() + s[1:] if s else s
def camel_to_snake(s: str) -> str: def camel_to_snake(s: str) -> str:
return re.sub(r'(?<!^)(?=[A-Z])', '_', s).lower() return re.sub(r"(?<!^)(?=[A-Z])", "_", s).lower()

View File

@ -8,7 +8,6 @@ import { ShortUrlsDataService } from 'src/app/modules/admin/short-urls/short-url
import { ShortUrlsColumns } from 'src/app/modules/admin/short-urls/short-urls.columns'; import { ShortUrlsColumns } from 'src/app/modules/admin/short-urls/short-urls.columns';
import { AuthService } from 'src/app/service/auth.service'; import { AuthService } from 'src/app/service/auth.service';
import { Filter } from 'src/app/model/graphql/filter/filter.model'; import { Filter } from 'src/app/model/graphql/filter/filter.model';
import { SettingsService } from 'src/app/service/settings.service';
import QrCodeWithLogo from 'qrcode-with-logos'; import QrCodeWithLogo from 'qrcode-with-logos';
import { FileUpload, FileUploadHandlerEvent } from 'primeng/fileupload'; import { FileUpload, FileUploadHandlerEvent } from 'primeng/fileupload';
import { ConfigService } from 'src/app/service/config.service'; import { ConfigService } from 'src/app/service/config.service';

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { User } from 'src/app/model/auth/user'; import { User } from 'src/app/model/auth/user';
import { BehaviorSubject, concatWith, firstValueFrom, Observable } from 'rxjs'; import { BehaviorSubject, firstValueFrom, Observable } from 'rxjs';
import { Apollo, gql } from 'apollo-angular'; import { Apollo, gql } from 'apollo-angular';
import { PermissionsEnum } from 'src/app/model/auth/permissionsEnum'; import { PermissionsEnum } from 'src/app/model/auth/permissionsEnum';
import { KeycloakService } from 'keycloak-angular'; import { KeycloakService } from 'keycloak-angular';