Ejemplo n.º 1
0
def _reinit_daq_daemons(sender, instance, **kwargs):
    """
    update the daq daemon configuration when changes be applied in the models
    """
    if type(instance) is LaboremMotherboardDevice:
        post_save.send_robust(sender=Device, instance=instance.laboremmotherboard_device)
    elif type(instance) is LaboremMotherboardVariable:
        post_save.send_robust(sender=Variable, instance=instance.laboremmotherboard_variable)
Ejemplo n.º 2
0
def _reinit_daq_daemons(sender, instance, **kwargs):
    """
    update the daq daemon configuration when changes be applied in the models
    """
    if type(instance) is GPIODevice:
        post_save.send_robust(sender=Device, instance=instance.gpio_device)
    elif type(instance) is GPIOVariable:
        post_save.send_robust(sender=Variable, instance=instance.gpio_variable)
Ejemplo n.º 3
0
def _reinit_daq_daemons(sender, instance, **kwargs):
    """
    update the daq daemon configuration when changes be applied in the models
    """
    if type(instance) is PySenseDevice:
        post_save.send_robust(sender=Device, instance=instance.PySense_device)
    elif type(instance) is ExtendedPySenseDevice:
        post_save.send_robust(sender=Device,
                              instance=Device.objects.get(pk=instance.pk))
Ejemplo n.º 4
0
def force_user_post_save_callback(user=None, *args, **kwargs):
    """
    Send the signal post_save in order to force the execution of user_post_save_callback, see it in
    https://github.com/eduNEXT/edunext-platform/blob/4169327231de00991c46b6192327fe50b0406561/common/djangoapps/student/models.py#L652
    this allows the automatic enrollments if a user is registered by a third party auth.

    It's recommended to place this step after the social core step that creates the users: (social_core.pipeline.user.create_user).

    the discussion left three options:

    1)
        user._changed_fields = {'is_active': user.is_active}  # pylint: disable=protected-access
        post_save.send_robust(
            sender=user.__class__,
            instance=user,
            created=False
        )

    2)
        user.is_active = False
        user.save()
        user.is_active = True
        user.save()

    3)
        registration = Registration.objects.get_or_create(user=user)
        user.is_active = False
        user.save()
        registration.activate()

    The first one was selected because the second executed multiple unnecessary process and third one
    needs to implement a new backend.
    """
    is_new = kwargs.get('is_new')

    if user and is_new:
        user._changed_fields = {'is_active': user.is_active}  # pylint: disable=protected-access
        post_save.send_robust(sender=user.__class__,
                              instance=user,
                              created=False)
        logging_pipeline_step(
            "info",
            "Post_save signal sent in order to force the execution of user_post_save_callback.",
            **locals())
Ejemplo n.º 5
0
def _reinit_daq_daemons(sender, instance, **kwargs):
    """
    update the daq daemon configuration when changes be applied in the models
    """
    if type(instance) is ModbusDevice:
        post_save.send_robust(sender=Device, instance=instance.modbus_device)
    elif type(instance) is ModbusVariable:
        post_save.send_robust(sender=Variable, instance=instance.modbus_variable)
    elif type(instance) is ExtendedModbusVariable:
        post_save.send_robust(sender=Variable, instance=Variable.objects.get(pk=instance.pk))
    elif type(instance) is ExtendedModbusDevice:
        post_save.send_robust(sender=Device, instance=Device.objects.get(pk=instance.pk))
Ejemplo n.º 6
0
def _reinit_daq_daemons(sender, instance, **kwargs):
    """
    update the daq daemon configuration when changes be applied in the models
    """
    if type(instance) is SMbusDevice:
        post_save.send_robust(sender=Device, instance=instance.smbus_device)
    elif type(instance) is SMbusVariable:
        post_save.send_robust(sender=Variable, instance=instance.smbus_variable)
    elif type(instance) is ExtendedSMbusVariable:
        post_save.send_robust(sender=Variable, instance=Variable.objects.get(pk=instance.pk))
    elif type(instance) is ExtendedSMBusDevice:
        post_save.send_robust(sender=Device, instance=Device.objects.get(pk=instance.pk))
Ejemplo n.º 7
0
def force_user_post_save_callback(auth_entry, is_new, user=None, *args, **kwargs):
    """
    Send the signal post_save in order to force the execution of user_post_save_callback, see it in
    https://github.com/eduNEXT/edunext-platform/blob/4169327231de00991c46b6192327fe50b0406561/common/djangoapps/student/models.py#L652
    this allows the automatic enrollments if a user is registered by a third party auth.
    This depends on "third_party_auth.pipeline.parse_query_params".

    the discussion left three options:

    1)
        user._changed_fields = {'is_active': user.is_active}  # pylint: disable=protected-access
        post_save.send_robust(
            sender=user.__class__,
            instance=user,
            created=False
        )

    2)
        user.is_active = False
        user.save()
        user.is_active = True
        user.save()

    3)
        registration = Registration.objects.get_or_create(user=user)
        user.is_active = False
        user.save()
        registration.activate()

    The first one was selected because the second executed multiple unnecessary process and third one
    needs to implement a new backend.
    """
    if auth_entry == 'register' and user and is_new:
        user._changed_fields = {'is_active': user.is_active}  # pylint: disable=protected-access
        post_save.send_robust(
            sender=user.__class__,
            instance=user,
            created=False
        )
Ejemplo n.º 8
0
def _reinit_daq_daemons(sender, instance, **kwargs):
    """
    update the daq daemon configuration when changes be applied in the models
    """
    if type(instance) is VISADevice:
        post_save.send_robust(sender=Device, instance=instance.visa_device)
    elif type(instance) is VISAVariable:
        post_save.send_robust(sender=Variable, instance=instance.visa_variable)
    elif type(instance) is VISADeviceHandler:
        # todo
        pass
    elif type(instance) is ExtendedVISAVariable:
        post_save.send_robust(sender=Variable, instance=Variable.objects.get(pk=instance.pk))
    elif type(instance) is ExtendedVISADevice:
        post_save.send_robust(sender=Device, instance=Device.objects.get(pk=instance.pk))
Ejemplo n.º 9
0
def _reinit_daq_daemons(sender, instance, **kwargs):
    """
    update the daq daemon configuration when changes be applied in the models
    """
    if type(instance) is VISADevice:
        post_save.send_robust(sender=Device, instance=instance.visa_device)
    elif type(instance) is VISAVariable:
        post_save.send_robust(sender=Variable, instance=instance.visa_variable)
    elif type(instance) is VISADeviceHandler:
        # todo
        pass
    elif type(instance) is ExtendedVISAVariable:
        post_save.send_robust(sender=Variable,
                              instance=Variable.objects.get(pk=instance.pk))
    elif type(instance) is ExtendedVISADevice:
        post_save.send_robust(sender=Device,
                              instance=Device.objects.get(pk=instance.pk))
Ejemplo n.º 10
0
def _reinit_daq_daemons(sender, instance, **kwargs):
    """
    update the daq daemon configuration when changes be applied in the models
    """
    if type(instance) is WebServiceDevice:
        post_save.send_robust(sender=Device,
                              instance=instance.webservice_device)
    elif type(instance) is WebServiceVariable:
        post_save.send_robust(sender=Variable,
                              instance=instance.webservice_variable)
    elif type(instance) is WebServiceAction:
        # TODO : select only devices of selected variables
        pass
    elif type(instance) is ExtendedWebServiceVariable:
        post_save.send_robust(sender=Variable,
                              instance=Variable.objects.get(pk=instance.pk))
    elif type(instance) is ExtendedWebServiceDevice:
        post_save.send_robust(sender=Device,
                              instance=Device.objects.get(pk=instance.pk))
Ejemplo n.º 11
0
 def save(self, *args, **kwargs):
     # TODO : select only devices of selected variables
     post_save.send_robust(sender=WebServiceAction,
                           instance=WebServiceDevice.objects.first())
     super(WebServiceAction, self).save(*args, **kwargs)