diff --git a/billard/models.py b/billard/models.py index 4f9123c..7fa7236 100644 --- a/billard/models.py +++ b/billard/models.py @@ -4,8 +4,6 @@ import uuid from django.contrib.auth.models import User from django.contrib.auth.models import User from django.db import models -from django.db.models.signals import post_save -from django.dispatch import receiver log = logging.getLogger(__name__) @@ -112,15 +110,3 @@ class ClientData(models.Model): class Meta: verbose_name = "Client Data logs" verbose_name_plural = "Client Data logs" - - -@receiver(post_save, sender=LocationData) -def test(sender, **kwargs): - from .tasks import process_location_data - process_location_data() - - -@receiver(post_save, sender=ClientData) -def test(sender, **kwargs): - from .tasks import process_client_data - process_client_data() diff --git a/billard/tasks.py b/billard/tasks.py index 035e12c..9530401 100644 --- a/billard/tasks.py +++ b/billard/tasks.py @@ -2,12 +2,20 @@ from __future__ import absolute_import, unicode_literals import logging +from django.db.models.signals import post_save +from django.dispatch import receiver + import billard.utils as utils from billard.models import LocationData, Client, Accounting, ClientData log = logging.getLogger(__name__) +@receiver(post_save, sender=ClientData) +def pcd(sender, **kwargs): + process_client_data() + + def process_client_data(): data = ClientData.objects.all().order_by('last_seen') for cd in data: @@ -17,6 +25,11 @@ def process_client_data(): cd.delete() +@receiver(post_save, sender=LocationData) +def pld(sender, **kwargs): + process_location_data() + + def process_location_data(): log.info('Starte die Verarbeitung der Location-Data-Objecte') data = LocationData.objects.filter(processed=False).order_by('tst')