def remove_perm(perm, user_or_group, forum=None):
    """ Remove a permission to a user (anonymous or not) or a group. """
    user, group = get_identity(user_or_group)
    perm = ForumPermission.objects.get(codename=perm)
    if user:
        UserForumPermission.objects.filter(
            forum=forum,
            permission=perm,
            user=user if not user.is_anonymous else None,
            anonymous_user=user.is_anonymous,
        ).delete()
    if group:
        GroupForumPermission.objects.filter(forum=forum, permission=perm, group=group).delete()
Remove a permission to a user (anonymous or not) or a group.