If the organization user is also the owner, this should not be deleted
        unless it's part of a cascade from the Organization.

        If there is no owner then the deletion should proceed.
775894
def delete(self, using=None):
        
        from organizations.exceptions import OwnershipRequired

        try:
            if self.organization.owner.organization_user.pk == self.pk:
                raise OwnershipRequired(
                    _(
                        "Cannot delete organization owner "
                        "before organization or transferring ownership."
                    )
                )
        # TODO This line presumes that OrgOwner model can't be modified
        except self._org_owner_model.DoesNotExist:
            pass
        super(AbstractBaseOrganizationUser, self).delete(using=using)
656282
function deleteUser(username, done) {
  return getUser(username, function(getUserErr, user) {
    if (getUserErr) {
      return done(getUserErr);
    }

    if (!user) {
      return done(new Error(`user '${username}' not found`));
    }

    user.tokens.forEach((token) => token.destroy());
    user.groups.forEach((group) => { group.members.remove(user.id); group.save(); });
    user.leading.forEach((group) => { group.leaders.remove(user.id); group.save(); });
    user.destroy(done);
  });
}
102639
public static function removeOwner($owner_id, $owner, $owner_attribute)
    {
        $mediafiles = Owners::findOne([
            'owner_id' => $owner_id,
            'owner' => $owner,
            'owner_attribute' => $owner_attribute,
        ]);

        if ($mediafiles) {
            return $mediafiles->delete();
        }

        return false;
    }
1015364
def groups_remove_owner(self, room_id, user_id, **kwargs):
        """"""
        return self.__call_api_post('groups.removeOwner', roomId=room_id, userId=user_id, kwargs=kwargs)
981310
def UsersDelete (self, user_id):
        
        if self.__SenseApiCall__('/users/{user_id}.json'.format(user_id = user_id), 'DELETE'):
            return True
        else:
            self.__error__ = "api call unsuccessful"
            return False
1268079
def channels_remove_owner(self, room_id, user_id, **kwargs):
        """"""
        return self.__call_api_post('channels.removeOwner', roomId=room_id, userId=user_id, kwargs=kwargs)
498179
def organization_membership_delete(self, id, **kwargs):
        ""
        api_path = "/api/v2/organization_memberships/{id}.json"
        api_path = api_path.format(id=id)
        return self.call(api_path, method="DELETE", **kwargs)
262489
private boolean checkPartitionOwner() {
        InternalPartitionServiceImpl partitionService = getService();
        PartitionStateManager partitionStateManager = partitionService.getPartitionStateManager();
        InternalPartitionImpl partition = partitionStateManager.getPartitionImpl(getPartitionId());
        PartitionReplica owner = partition.getOwnerReplicaOrNull();

        NodeEngine nodeEngine = getNodeEngine();
        if (owner == null || !owner.isIdentical(nodeEngine.getLocalMember())) {
            ILogger logger = getLogger();
            if (logger.isFinestEnabled()) {
                logger.finest("This node is not owner partition. Cannot process request. partitionId="
                        + getPartitionId() + ", replicaIndex=" + getReplicaIndex() + ", namespaces=" + namespaces);
            }
            return false;
        }
        return true;
    }
709516
def owner(self):
        
        if self._owner:
            return self._owner
        elif not self.abstract:
            return self.read_meta()._owner

        raise EmptyDocumentException()
767675
function (newDoc, oldDoc, userCtx, secObj) {
    if (newDoc._deleted === true) {
      // allow deletes by admins and matching users
      // without checking the other fields
      if (userCtx.roles.indexOf('_admin') !== -1) {
        return;
      }
      throw ({forbidden: 'Only admins may delete other user docs.'});
    }

    var is_server_or_database_admin = function (userCtx, secObj) {
      // see if the user is a server admin
      if (userCtx.roles.indexOf('_admin') !== -1) {
        return true; // a server admin
      }

      // see if the user is a database admin specified by name
      if (secObj && secObj.admins && secObj.admins.names) {
        if (secObj.admins.names.indexOf(userCtx.name) !== -1) {
          return true; // database admin
        }
      }

      // see if the user is a database admin specified by role
      if (secObj && secObj.admins && secObj.admins.roles) {
        var db_roles = secObj.admins.roles;
        var idx;
        for (idx = 0; idx < userCtx.roles.length; idx++) {
          var user_role = userCtx.roles[idx];
          if (db_roles.indexOf(user_role) !== -1) {
            return true; // role matches!
          }
        }
      }

      return false; // default to no admin
    };

    if (!is_server_or_database_admin(userCtx, secObj)) {
      throw ({
        forbidden: 'You may only read documents.'
      });
    }
  }
780817
def deletePerson(self, name):
        
        self.organizer.deletePerson(self.organizer.personByName(name))
1208559
public function afterDelete()
    {
        $owner = $this->owner;
        $condition = $this->getCondition();
        $condition[] = ['>', $this->sortAttribute, $owner->{$this->sortAttribute}];
        $owner->updateAllCounters([$this->sortAttribute => -1], $condition);
    }
1133791
def is_owned_by_current_user(self):
        

        from bambou.nurest_root_object import NURESTRootObject
        root_object = NURESTRootObject.get_default_root_object()
        return self._owner == root_object.id
1172031
def organization_subscription_delete(self, id, **kwargs):
        ""
        api_path = "/api/v2/organization_subscriptions/{id}.json"
        api_path = api_path.format(id=id)
        return self.call(api_path, method="DELETE", **kwargs)
372236
def delete(user_id):
        '''
        
        '''
        try:
            del_count = TabMember.delete().where(TabMember.uid == user_id)
            del_count.execute()
            return True
        except:
            return False
1001267
private void verifyPartitionOwner() {
        InternalPartition partition = getPartition();
        PartitionReplica owner = partition.getOwnerReplicaOrNull();
        if (owner == null) {
            throw new RetryableHazelcastException("Cannot migrate at the moment! Owner of the partition is null => "
                    + migrationInfo);
        }

        if (!owner.isIdentical(getNodeEngine().getLocalMember())) {
            throw new RetryableHazelcastException("Owner of partition is not this node! => " + toString());
        }
    }
375764
private boolean ownerCanReadTable(String ownerId, String table) {
        return _internalAuthorizer.hasPermissionById(ownerId, getReadPermission(table));
    }