Created
February 18, 2014 02:40
-
-
Save marcelcaraciolo/9063656 to your computer and use it in GitHub Desktop.
Agendamento
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import | |
from celery import shared_task | |
# import the logging library | |
import logging | |
# Get an instance of a logger | |
logger = logging.getLogger(__name__) | |
@shared_task | |
def sendScheduledAlertTask(pk, scheduling_id): | |
from alerts.models import MaintenanceAlert | |
logger.info('entrei no task com pk igual a e tipo ' + str(pk) + str(type(pk))) | |
logger.info('tentei chegar no scheduling_id com ' + str(scheduling_id)) | |
try: | |
alert = MaintenanceAlert.objects.get(pk=pk) | |
except MaintenanceAlert.DoesNotExist: | |
return | |
logger.info('entrei no task com o alerta %s' % alert.name) | |
if alert.status == MaintenanceAlert.SCHEDULED_TO_SEND and alert.scheduling_id == scheduling_id: | |
logger.info('entrei na atividade com o alerta %s' % alert.name) | |
alert.task_id = None | |
alert.scheduling_id = None | |
alert.save() | |
alert.send() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment