from django.dispatch import receiver from .signals import siglog from .models import Device, Organization, Network, Model, Wifi, DeviceLog @receiver(siglog) def logger(sender, **kwargs): if sender == Device: logger = DeviceLog else: return logger.objects.create( objid=kwargs["id"], user=kwargs["user"], action=kwargs["action"], oldvalue=kwargs["oldvalue"], newvalue=kwargs["newvalue"] ) # device = models.CharField("Device ID", max_length=64) # user = models.CharField("User Name", max_length=128, null=True) # date = models.DateTimeField("Action Date", auto_now_add=True) # action = models.IntegerField("Action", choices=ACTION_CHOICES) # oldvalue = models.CharField("Old Value", max_length=256, blank=True, null=True) # newvalue = models.CharField("New Value", max_length=256, blank=True, null=True) # ADD = 0 # REMOVE = 1 # NAME = 2 # NET = 3 # REBOOT = 4 # UPDATE = 5 # STATUS = 6 # INTERNALIP = 7 # WIFI = 8