Skip to content
Snippets Groups Projects
Commit fad89499 authored by Podosochnyy Maxim's avatar Podosochnyy Maxim
Browse files

Правки

parent 55691c4a
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ import typing
from deepdiff import DeepDiff
from perxis.collections import collections_pb2_grpc, collections_pb2
from perxis.roles import roles_pb2_grpc, roles_pb2
from perxis.common import common_pb2
from perxis.clients import clients_pb2_grpc, clients_pb2
from perxis.environments import environments_pb2_grpc, environments_pb2
......@@ -112,6 +113,25 @@ class ExtensionSetup:
cloned_role.environments[:] = role.environments
# Произвести мерж правил доступа
for exist_rule in role.rules:
was_found = False
for local_rule in cloned_role.rules:
if local_rule.collection_id == exist_rule.collection_id:
was_found = True
local_rule.actions[:] = list(set(local_rule.actions + exist_rule.actions))
break
# Если правило для коллекций не было найдено - его нужно добавить
if not was_found:
cloned_role.rules.append(common_pb2.Rule(
collection_id=exist_rule.collection_id,
actions=exist_rule.actions
))
try:
self.roles_service.Update.with_call(
roles_pb2.UpdateRequest(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment