docs: def assign_perm(perm, user_or_group, forum=None, has_perm=True):
      """ Assigns 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:
          return UserForumPermission.objects.create(
              forum=forum,
              permission=perm,
              user=user if not user.is_anonymous else None,
              anonymous_user=user.is_anonymous,
              has_perm=has_perm,
          )
      if group:
          return GroupForumPermission.objects.create(
              forum=forum, permission=perm, group=group, has_perm=has_perm,
          )