from flask.ext.mail import Message from apollo import services from apollo.core import mail from apollo.settings import SECURITY_EMAIL_SENDER from apollo.messaging.outgoing import gateway_factory from apollo.factory import create_celery_app celery = create_celery_app() @celery.task def send_message(event, message, recipient, sender=""): """ Task for sending outgoing messages using the configured gateway :param message: The string for the contents of the message to be sent :param recipient: The recipient of the text message :param sender: (Optional) The sender to set """ gateway = gateway_factory() if gateway: services.messages.log_message( event=services.events.get(pk=event), recipient=recipient, sender=sender, text=message, direction='OUT') return gateway.send(message, recipient, sender) @celery.task def send_messages(event, message, recipients, sender=""): if hasattr(recipients, '__iter__'):
from apollo import models from apollo.factory import create_celery_app celery = create_celery_app() @celery.task def init_submissions(deployment_pk, event_pk, form_pk, role_pk, location_type_pk): deployment = models.Deployment.objects.get(pk=deployment_pk) event = models.Event.objects.get(pk=event_pk) form = models.Form.objects.get(pk=form_pk) role = models.ParticipantRole.objects.get(pk=role_pk) location_type = models.LocationType.objects.get(pk=location_type_pk) if not (deployment and event and form and role and location_type): return models.Submission.init_submissions(deployment, event, form, role, location_type)