25 lines
624 B
Python
25 lines
624 B
Python
from django.dispatch import receiver
|
|
from .signals import siglog
|
|
|
|
from .models import Device, Wifi, DeviceLog, UserLog, WifiLog
|
|
from django.contrib.auth.models import User
|
|
|
|
@receiver(siglog)
|
|
def logger(sender, **kwargs):
|
|
if sender == Device:
|
|
logger = DeviceLog
|
|
elif sender == User:
|
|
logger = UserLog
|
|
elif sender == Wifi:
|
|
logger = WifiLog
|
|
else:
|
|
return
|
|
|
|
logger.objects.create(
|
|
objid=kwargs["id"],
|
|
user=kwargs["user"],
|
|
action=kwargs["action"],
|
|
oldvalue=kwargs["oldvalue"],
|
|
newvalue=kwargs["newvalue"]
|
|
)
|
|
|