Handle a graduated user being deleted.
197824
def handle_delete(self):
        """"""
        from intranet.apps.eighth.models import EighthScheduledActivity
        EighthScheduledActivity.objects.filter(eighthsignup_set__user=self).update(
            archived_member_count=F('archived_member_count')+1)
1132556
def trash_for(self, user):
        
        return self.filter(
            recipient=user,
            recipient_deleted_at__isnull=False,
        ) | self.filter(
            sender=user,
            sender_deleted_at__isnull=False,
        )
1281969
def delete_user(ctx, yes):
    """"""

    if ctx.obj['username'] is None:
        username = _ask("Please enter username:")
    else:
        username = ctx.obj['username']

    del_user = ctx.obj['db'].objectmodels['user'].find_one({'name': username})
    if yes or _ask('Confirm deletion', default=False, data_type='bool'):
        try:
            del_user.delete()
            log("Done")
        except AttributeError:
            log('User not found', lvl=warn)
    else:
        log("Cancelled")
423215
def post_delete(sender, instance, using, **kwargs):
    """"""
    try:
        with transaction.atomic():
            if not should_audit(instance):
                return False

            object_json_repr = serializers.serialize("json", [instance])

            # user
            try:
                user = get_current_user()
                # validate that the user still exists
                user = get_user_model().objects.get(pk=user.pk)
            except:
                user = None

            if isinstance(user, AnonymousUser):
                user = None
            c_t = ContentType.objects.get_for_model(instance)
            sid = transaction.savepoint()
            try:
                with transaction.atomic():
                    # crud event
                    crud_event = CRUDEvent.objects.create(
                        event_type=CRUDEvent.DELETE,
                        object_repr=str(instance),
                        object_json_repr=object_json_repr,
                        content_type_id=c_t.id,
                        object_id=instance.pk,
                        user_id=getattr(user, 'id', None),
                        datetime=timezone.now(),
                        user_pk_as_string=str(user.pk) if user else user
                    )

            except Exception as e:
                logger.exception(
                    "easy audit had a pre-save exception on CRUDEvent creation. instance: {}, instance pk: {}".format(
                        instance, instance.pk))
                transaction.savepoint_rollback(sid)
    except Exception:
        logger.exception('easy audit had a post-delete exception.')
216302
def delete_user(self, user):
        
        self.project_service.set_auth(self._token_project)
        self.project_service.delete_user(user)
581039
def delete(name, remove=False, force=False):
    '''
    
    '''
    if salt.utils.data.is_true(force):
        log.warning(
            'userdel does not support force-deleting user while user is '
            'logged in'
        )
    cmd = ['userdel']
    if remove:
        cmd.append('-r')
    cmd.append(name)
    return __salt__['cmd.retcode'](cmd, python_shell=False) == 0
549062
def delete_unknown_user(_debug)
      @current_users.each do |cu|
        cu.drop unless @managed_users.any? do |mu|
          cu.user == mu.user && cu.host == mu.host
        end
      end
    end
806279
def destroy
      if @user.enabled?
        flash[:danger] = 'Cannot delete an enabled user.'
      elsif @user.disabled_at.blank? || @user.disabled_at > 15.days.ago
        flash[:danger] = 'Cannot delete a user within 15 days of being disabled.'
      else
        @user.destroy
        flash[:success] = "User #{@user} has been deleted."
      end
      if inline_request?
        render 'show', formats: [ :json ]
      else
        redirect_to users_path
      end
    end
58585
def disconnect(self, user):
        
        self.remove_user(user)
        self.send_message(create_message('RoomServer', 'Please all say goodbye to {name}!'.format(name=user.id.name)))
        self.send_message(create_disconnect(user.id.name))
1132203
def account_delete(request, username,
        template_name=accounts_settings.ACCOUNTS_PROFILE_DETAIL_TEMPLATE,
        extra_context=None, **kwargs):
    
    user = get_object_or_404(get_user_model(),
                             username__iexact=username)
    user.is_active = False
    user.save()

    return redirect(reverse('accounts_admin'))
879676
def remove_user(user):
    """"""
    def processor(action, argument):
        ActionUsers.query_by_action(action, argument=argument).filter(
            ActionUsers.user_id == user.id
        ).delete(synchronize_session=False)
    return processor
1342962
def delete(self, username, type):
        """"""
        self.client.delete(self.__distinguished_name(type, username=username))
1311170
def drop_user(self, username):
        
        text = "DROP USER {0}".format(quote_ident(username), method="POST")
        self.query(text, method="POST")
220398
def user_post_delete_handler(sender, **kwargs):
    """"""
    total = get_user_model().objects.all().count()
    data = [{
        'measurement': 'django_auth_user_delete',
        'tags': {'host': settings.INFLUXDB_TAGS_HOST, },
        'fields': {'value': 1, },
        'time': timezone.now().isoformat(),
    }]
    write_points(data)

    data = [{
        'measurement': 'django_auth_user_count',
        'tags': {'host': settings.INFLUXDB_TAGS_HOST, },
        'fields': {'value': total, },
        'time': timezone.now().isoformat(),
    }]
    write_points(data)
910758
private void ensureLastAdminIsNotRemoved(DbSession dbSession, GroupDto group, UserDto user) {
    int remainingAdmins = dbClient.authorizationDao().countUsersWithGlobalPermissionExcludingGroupMember(dbSession,
      group.getOrganizationUuid(), OrganizationPermission.ADMINISTER.getKey(), group.getId(), user.getId());
    checkRequest(remainingAdmins > 0, "The last administrator user cannot be removed");
  }
919325
def delete(self, user):
        
        self._check_auth(must_admin=True)
        is_admin = self._check_admin()
        try:
            referer = cherrypy.request.headers['Referer']
        except Exception as e:
            referer = '/'
        self._deleteuser(user)
        self._add_notification('User Deleted')
        raise cherrypy.HTTPRedirect(referer)
754150
public function deleted(User $user)
    {
        \DB::table((new Revision())->getTable())->insert([
            [
                'revisionable_type' => $user->getMorphClass(),
                'revisionable_id' => $user->id,
                'key' => 'deleted_at',
                'old_value' => $user,
                'new_value' => new \DateTime(),
                'user_id' => (\Auth::check() ? \Auth::user()->id : null),
                'created_at' => new \DateTime(),
                'updated_at' => new \DateTime(),
            ]
        ]);
    }