mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-15 22:37:40 +02:00
commit
cf4c23d1ac
@ -63,7 +63,8 @@ class FoodListView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMixin, Li
|
|||||||
valid_regex = is_regex(pattern)
|
valid_regex = is_regex(pattern)
|
||||||
suffix = '__iregex' if valid_regex else '__istartswith'
|
suffix = '__iregex' if valid_regex else '__istartswith'
|
||||||
prefix = '^' if valid_regex else ''
|
prefix = '^' if valid_regex else ''
|
||||||
qs = qs.filter(Q(**{f'name{suffix}': prefix + pattern}))
|
qs = qs.filter(Q(**{f'name{suffix}': prefix + pattern})
|
||||||
|
| Q(**{f'owner__name{suffix}': prefix + pattern}))
|
||||||
else:
|
else:
|
||||||
qs = qs.none()
|
qs = qs.none()
|
||||||
search_table = qs.filter(PermissionBackend.filter_queryset(self.request, Food, 'view'))
|
search_table = qs.filter(PermissionBackend.filter_queryset(self.request, Food, 'view'))
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from oauth2_provider.oauth2_validators import OAuth2Validator
|
from oauth2_provider.oauth2_validators import OAuth2Validator
|
||||||
from oauth2_provider.scopes import BaseScopes
|
from oauth2_provider.scopes import BaseScopes
|
||||||
from member.models import Club
|
from member.models import Club
|
||||||
|
from note.models import Alias
|
||||||
from note_kfet.middlewares import get_current_request
|
from note_kfet.middlewares import get_current_request
|
||||||
|
|
||||||
from .backends import PermissionBackend
|
from .backends import PermissionBackend
|
||||||
@ -35,7 +36,18 @@ class PermissionScopes(BaseScopes):
|
|||||||
|
|
||||||
|
|
||||||
class PermissionOAuth2Validator(OAuth2Validator):
|
class PermissionOAuth2Validator(OAuth2Validator):
|
||||||
oidc_claim_scope = None # fix breaking change of django-oauth-toolkit 2.0.0
|
oidc_claim_scope = OAuth2Validator.oidc_claim_scope
|
||||||
|
oidc_claim_scope.update({"name": 'openid',
|
||||||
|
"normalized_name": 'openid',
|
||||||
|
"email": 'openid',
|
||||||
|
})
|
||||||
|
|
||||||
|
def get_additional_claims(self, request):
|
||||||
|
return {
|
||||||
|
"name": request.user.username,
|
||||||
|
"normalized_name": Alias.normalize(request.user.username),
|
||||||
|
"email": request.user.email,
|
||||||
|
}
|
||||||
|
|
||||||
def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):
|
def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user