2017-01-28 17:06:05 +01:00
|
|
|
|
|
|
|
def checkForShadowCall(sender, instance, created, raw, **kwargs):
|
2020-01-26 11:36:47 +01:00
|
|
|
""" Check for existing shadow call. If present copy it's data and delete it. """
|
|
|
|
if created:
|
|
|
|
# to prevent circular imports we import ShadowCall here
|
|
|
|
from .models import ShadowCall
|
2017-01-28 17:06:05 +01:00
|
|
|
|
2020-01-26 11:36:47 +01:00
|
|
|
try:
|
|
|
|
shadow = ShadowCall.objects.get(username=instance.username)
|
|
|
|
instance.ref = shadow.ref
|
|
|
|
instance.location = shadow.location
|
|
|
|
instance.opName = shadow.opName
|
|
|
|
instance.regTime = shadow.regTime
|
2017-01-28 17:06:05 +01:00
|
|
|
|
2020-01-26 11:36:47 +01:00
|
|
|
instance.save()
|
|
|
|
shadow.delete()
|
|
|
|
except ShadowCall.DoesNotExist:
|
|
|
|
pass
|