diff --git a/project/geosource/mixins.py b/project/geosource/mixins.py index 7ff0e13e..7ed056f2 100644 --- a/project/geosource/mixins.py +++ b/project/geosource/mixins.py @@ -1,17 +1,11 @@ -from datetime import timedelta - from celery import states from django.utils.timezone import now from rest_framework.exceptions import MethodNotAllowed from project.geosource.tasks import run_model_object_method -from .app_settings import MAX_TASK_RUNTIME - class CeleryCallMethodsMixin: - DONE_STATUSES = ("SUCCESS", "FAILURE", "NEED_SYNC", None) - def update_status(self, task): self.task_id = task.task_id self.task_date = now() @@ -20,13 +14,7 @@ def update_status(self, task): @property def can_sync(self): """Property containing a boolean that tell if the state allow to run a sync""" - status = self.get_status() - - return status.get("state") in self.DONE_STATUSES or ( - status.get("state") not in self.DONE_STATUSES - and self.task_date is not None - and self.task_date < now() - timedelta(hours=MAX_TASK_RUNTIME) - ) + return self.status != self.Status.PENDING def run_async_method( self,