Esempio n. 1
0
def auto_update_user_value(sender, instance, raw, **kwargs):
    try:
        old_obj = SportCarOwnership.objects.get(pk=instance.pk)
    except ObjectDoesNotExist:
        return
    if old_obj.identified != instance.identified:
        user = instance.user
        user_value_change.delay(user)
Esempio n. 2
0
def auto_update_user_value_after_car_change(sender, instance, raw, **kwargs):
    from User.models import User
    try:
        old_car = Sportscar.objects.get(pk=instance.pk)
    except ObjectDoesNotExist:
        return
    if old_car.price_number != instance.price_number:
        # get related users and recalculate their value
        users = User.objects.filter(ownership__car=instance)
        for user in users:
            user_value_change.delay(user)
Esempio n. 3
0
def auto_update_user_value_after_delete(sender, instance, **kwargs):
    if instance.identified:
        user = instance.user
        user_value_change.delay(user)