Example #1
0
    def beforeDelete(sender, **kwargs):
        '''
        Used to invoke the Service class "Destroy" before deleting it from database.

        In this case, this method ensures that the user has no userServices assigned and, if it has,
        mark those services for removal

        :note: If destroy raises an exception, the deletion is not taken.
        '''
        toDelete = kwargs['instance']

        # first, we invoke removeUser. If this raises an exception, user will not
        # be removed
        toDelete.getManager().removeUser(toDelete.name)

        # now removes all "child" of this user, if it has children
        User.objects.filter(parent=toDelete.id).delete()

        # Remove related logs
        log.clearLogs(toDelete)

        # Removes all user services assigned to this user (unassign it and mark for removal)
        for us in toDelete.userServices.all():
            us.assignToUser(None)
            us.remove()

        logger.debug('Deleted user {0}'.format(toDelete))
Example #2
0
    def beforeDelete(sender, **kwargs):
        '''
        Used to invoke the Provider class "Destroy" before deleting it from database.

        The main purpuse of this hook is to call the "destroy" method of the object to delete and
        to clear related data of the object (environment data such as own storage, cache, etc...

        :note: If destroy raises an exception, the deletion is not taken.
        '''
        from uds.core.util.permissions import clean

        toDelete = kwargs['instance']
        logger.debug('Before delete service provider {}'.format(toDelete))

        # Only tries to get instance if data is not empty
        if toDelete.data != '':
            s = toDelete.getInstance()
            s.destroy()
            s.env().clearRelatedData()

        # Clears related logs
        log.clearLogs(toDelete)

        # Clears related permissions
        clean(toDelete)
Example #3
0
    def beforeDelete(sender, **kwargs):
        """
        Used to invoke the Service class "Destroy" before deleting it from database.

        In this case, this method ensures that the user has no userServices assigned and, if it has,
        mark those services for removal

        :note: If destroy raises an exception, the deletion is not taken.
        """
        toDelete = kwargs['instance']

        # first, we invoke removeUser. If this raises an exception, user will not
        # be removed
        toDelete.getManager().removeUser(toDelete.name)

        # now removes all "child" of this user, if it has children
        User.objects.filter(parent=toDelete.id).delete()

        # Remove related logs
        log.clearLogs(toDelete)

        # Removes all user services assigned to this user (unassign it and mark for removal)
        for us in toDelete.userServices.all():
            us.assignToUser(None)
            us.remove()

        logger.debug('Deleted user %s', toDelete)
Example #4
0
    def beforeDelete(sender, **kwargs):
        """
        Used to invoke the Service class "Destroy" before deleting it from database.

        The main purpuse of this hook is to call the "destroy" method of the object to delete and
        to clear related data of the object (environment data such as own storage, cache, etc...

        :note: If destroy raises an exception, the deletion is not taken.
        """
        from uds.core.util.permissions import clean
        toDelete = kwargs['instance']

        logger.debug('Before delete auth %s', toDelete)

        # Only tries to get instance if data is not empty
        if toDelete.data != '':
            s = toDelete.getInstance()
            s.destroy()
            s.env.clearRelatedData()

        # Clears related logs
        log.clearLogs(toDelete)

        # Clears related permissions
        clean(toDelete)
Example #5
0
    def beforeDelete(sender, **kwargs):
        """
        Used to invoke the Service class "Destroy" before deleting it from database.

        The main purpuse of this hook is to call the "destroy" method of the object to delete and
        to clear related data of the object (environment data such as own storage, cache, etc...

        :note: If destroy raises an exception, the deletion is not taken.
        """
        toDelete = kwargs['instance']
        toDelete.getEnvironment().clearRelatedData()

        # Clear related logs to this user service
        log.clearLogs(toDelete)

        logger.debug('Deleted user service %s', toDelete)
Example #6
0
    def beforeDelete(sender, **kwargs):
        '''
        Used to invoke the Service class "Destroy" before deleting it from database.

        The main purpuse of this hook is to call the "destroy" method of the object to delete and
        to clear related data of the object (environment data such as own storage, cache, etc...

        :note: If destroy raises an exception, the deletion is not taken.
        '''
        toDelete = kwargs['instance']
        toDelete.getEnvironment().clearRelatedData()

        # Clear related logs to this user service
        log.clearLogs(toDelete)

        logger.debug('Deleted user service {0}'.format(toDelete))
Example #7
0
    def beforeDelete(sender, **kwargs):
        """
        Used to invoke the Service class "Destroy" before deleting it from database.

        The main purpuse of this hook is to call the "destroy" method of the object to delete and
        to clear related data of the object (environment data such as own storage, cache, etc...

        :note: If destroy raises an exception, the deletion is not taken.
        """
        from uds.core.util.permissions import clean
        toDelete = kwargs['instance']

        # Clears related logs
        log.clearLogs(toDelete)

        # Clears related permissions
        clean(toDelete)
Example #8
0
    def beforeDelete(sender, **kwargs):
        """
        Used to invoke the Service class "Destroy" before deleting it from database.

        The main purpuse of this hook is to call the "destroy" method of the object to delete and
        to clear related data of the object (environment data such as own storage, cache, etc...

        :note: If destroy raises an exception, the deletion is not taken.
        """
        from uds.core.util.permissions import clean
        toDelete = kwargs['instance']

        # Clears related logs
        log.clearLogs(toDelete)

        # Clears related permissions
        clean(toDelete)
Example #9
0
    def beforeDelete(sender, **kwargs):
        """
        Used to invoke the Service class "Destroy" before deleting it from database.

        In this case, this is a dummy method, waiting for something useful to do :-)

        :note: If destroy raises an exception, the deletion is not taken.
        """
        toDelete = kwargs['instance']
        # Todelete is a group

        # We invoke removeGroup. If this raises an exception, group will not
        # be removed
        toDelete.getManager().removeGroup(toDelete.name)

        # Clears related logs
        log.clearLogs(toDelete)

        logger.debug('Deleted group {0}'.format(toDelete))
Example #10
0
    def beforeDelete(sender, **kwargs):
        """
        Used to invoke the Service class "Destroy" before deleting it from database.

        In this case, this is a dummy method, waiting for something useful to do :-)

        :note: If destroy raises an exception, the deletion is not taken.
        """
        toDelete = kwargs['instance']
        # Todelete is a group

        # We invoke removeGroup. If this raises an exception, group will not
        # be removed
        toDelete.getManager().removeGroup(toDelete.name)

        # Clears related logs
        log.clearLogs(toDelete)

        logger.debug('Deleted group {0}'.format(toDelete))
    def beforeDelete(sender, **kwargs):
        """
        Used to invoke the Service class "Destroy" before deleting it from database.

        The main purpuse of this hook is to call the "destroy" method of the object to delete and
        to clear related data of the object (environment data such as own storage, cache, etc...

        :note: If destroy raises an exception, the deletion is not taken.
        """
        toDelete: ServicePoolPublication = kwargs['instance']
        toDelete.getEnvironment().clearRelatedData()

        # Delete method is invoked directly by PublicationManager,
        # Destroying a publication is not obligatory an 1 step action.
        # It's handled as "publish", and as so, it can be a multi-step process

        # Clears related logs
        log.clearLogs(toDelete)

        logger.debug('Deleted publication %s', toDelete)
    def beforeDelete(sender, **kwargs):
        '''
        Used to invoke the Service class "Destroy" before deleting it from database.

        The main purpuse of this hook is to call the "destroy" method of the object to delete and
        to clear related data of the object (environment data such as own storage, cache, etc...

        :note: If destroy raises an exception, the deletion is not taken.
        '''
        toDelete = kwargs['instance']
        toDelete.getEnvironment().clearRelatedData()

        # Delete method is invoked directly by PublicationManager,
        # Destroying a publication is not obligatory an 1 step action.
        # It's handled as "publish", and as so, it can be a multi-step process

        # Clears related logs
        log.clearLogs(toDelete)

        logger.debug('Deleted publication {0}'.format(toDelete))
Example #13
0
        Used to invoke the Service class "Destroy" before deleting it from database.

        The main purpuse of this hook is to call the "destroy" method of the object to delete and
        to clear related data of the object (environment data such as own storage, cache, etc...

        :note: If destroy raises an exception, the deletion is not taken.
        """
        from uds.core.util.permissions import clean
        toDelete = kwargs['instance']

        logger.debug('Before delete auth {}'.format(toDelete))

        # Only tries to get instance if data is not empty
        if toDelete.data != '':
            s = toDelete.getInstance()
            s.destroy()
            s.env.clearRelatedData()

        # Clears related logs
        log.clearLogs(toDelete)

        # Clears related permissions
        clean(toDelete)

    def __str__(self):
        return u"{0} of type {1} (id:{2})".format(self.name, self.data_type, self.id)


# Connects a pre deletion signal to Authenticator
signals.pre_delete.connect(Authenticator.beforeDelete, sender=Authenticator)