diff --git a/orchestra/contrib/resources/models.py b/orchestra/contrib/resources/models.py index 4ad8a8f4..4d48aab7 100644 --- a/orchestra/contrib/resources/models.py +++ b/orchestra/contrib/resources/models.py @@ -128,20 +128,20 @@ class Resource(models.Model): def sync_periodic_task(self): name = 'monitor.%s' % str(self) - if resource.pk and resource.crontab: + if self.pk and self.crontab: try: task = PeriodicTask.objects.get(name=name) except PeriodicTask.DoesNotExist: - if resource.is_active: + if self.is_active: PeriodicTask.objects.create( name=name, task='resources.Monitor', - args=[resource.pk], - crontab=resource.crontab + args=[self.pk], + crontab=self.crontab ) else: - if task.crontab != resource.crontab: - task.crontab = resource.crontab + if task.crontab != self.crontab: + task.crontab = self.crontab task.save(update_fields=['crontab']) else: PeriodicTask.objects.filter(name=name).delete()