def on_asset_permission_users_changed(sender, action, reverse, pk_set, **kwargs): if reverse: raise M2MReverseNotAllowed if need_rebuild_mapping_node(action): UserGrantedTreeRefreshController.add_need_refresh_orgs_for_users( [current_org.id], pk_set)
def on_user_group_delete(sender, instance: UserGroup, using, **kwargs): exists = AssetPermission.user_groups.through.objects.filter( usergroup_id=instance.id).exists() if not exists: return org_id = instance.org_id user_ids = UserGroup.users.through.objects.filter( usergroup_id=instance.id).values_list('user_id', flat=True) UserGrantedTreeRefreshController.add_need_refresh_orgs_for_users( [org_id], list(user_ids))
def on_asset_permission_user_groups_changed(sender, action, pk_set, reverse, **kwargs): if reverse: raise M2MReverseNotAllowed if need_rebuild_mapping_node(action): user_ids = User.groups.through.objects.filter( usergroup_id__in=pk_set).distinct().values_list('user_id', flat=True) UserGrantedTreeRefreshController.add_need_refresh_orgs_for_users( [current_org.id], user_ids)
def on_user_groups_change(sender, instance, action, reverse, pk_set, **kwargs): if action.startswith('post'): if reverse: group_ids = [instance.id] user_ids = pk_set else: group_ids = pk_set user_ids = [instance.id] exists = AssetPermission.user_groups.through.objects.filter( usergroup_id__in=group_ids).exists() if exists: org_ids = [current_org.id] UserGrantedTreeRefreshController.add_need_refresh_orgs_for_users( org_ids, user_ids)
def on_user_groups_change(sender, instance, action, reverse, pk_set, **kwargs): if not action.startswith('post'): return if reverse: group_ids = [instance.id] user_ids = pk_set org_id = instance.org_id else: group_ids = pk_set user_ids = [instance.id] group = UserGroup.objects.get(id=list(group_ids)[0]) org_id = group.org_id exists = AssetPermission.user_groups.through.objects.filter(usergroup_id__in=group_ids).exists() if not exists: return org_ids = [org_id] UserGrantedTreeRefreshController.add_need_refresh_orgs_for_users(org_ids, user_ids)