(self, domain_info, group_names)
Add/remove user from groups without save and return change message for changes, if any
Add/remove user from groups without save and return change message for changes, if any
Add / remove user from groups without save and return change message for changes if any
def update_user_groups(self, domain_info, group_names):
        """
        Add/remove user from groups without save and return change message for changes, if any
        """
        old_group_ids = set()
        for group in domain_info.group_memoizer.by_user_id(self.user.user_id):
            old_group_ids.add(group.get_id)
            if group.name not in group_names:
                group.remove_user(self.user)
                domain_info.group_memoizer.updated_groups.add(group.get_id)

        new_groups = {}
        for group_name in group_names:
            group = domain_info.group_memoizer.by_name(group_name)
            new_groups[group.get_id] = group
            if group.add_user(self.user, save=False):
                domain_info.group_memoizer.group_updated(group.get_id)

        if set(new_groups) != old_group_ids:
            return UserChangeMessage.groups_info(list(new_groups.values()))
def update_user_groups ( self , domain_info , group_names ) : old_group_ids = set ( ) for group in domain_info . group_memoizer . by_user_id ( self . user . user_id ) : old_group_ids . add ( group . get_id ) if group . name not in group_names : group . remove_user ( self . user ) domain_info . group_memoizer . updated_groups . add ( group . get_id ) new_groups = { } for group_name in group_names : group = domain_info . group_memoizer . by_name ( group_name ) new_groups [ group . get_id ] = group if group . add_user ( self . user , save = False ) : domain_info . group_memoizer . group_updated ( group . get_id ) if set ( new_groups ) != old_group_ids : return UserChangeMessage . groups_info ( list ( new_groups . values ( ) ) )