# Path: emailcongress/emailer.py
# class NoReply(PMMail):
#     HTML_BODY_TEMPLATE_DIR = 'emails/html_body/'
#     TEXT_BODY_TEMPLATE_DIR = 'emails/text_body/'
#     def __init__(self, django_user, **kwargs):
#     def send(self, test=False):
#     def _set_custom_headers_from_msg(self, msg):
#     def signup_confirm(self):
#     def address_change_request(self):
#     def remind_reps(self):
#     def email_confirm(self, msg):
#     def signup_success(self):
#     def reconfirm_info(self, msg):
#     def over_rate_limit(self, msg):
#     def message_queued(self, msg):
#     def message_undeliverable(self, leg_buckets, msg):
#     def message_receipt(self, legs, msg):
#     def send_status(self, msg_legs, msg):
#     def address_changed(self):
#     def custom_email(self, subject, html_template, text_template, context, custom_headers=None):


import os
import traceback
from celery import Celery
from emailcongress import emailer
from django.conf import settings
            from emailcongress.models import Message, MessageLegislator
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'emailcongress.settings.shared')

celery = Celery('emailcongress')
for key, val in settings.CONFIG_DICT['celery'].items():
    setattr(celery.conf, key.upper(), val)


@celery.task(bind=True, max_retries=celery.conf.MAX_RETRIES, default_retry_delay=celery.conf.RETRY_DELAY)
def send_to_phantom_of_the_capitol(self, msg_id=None, msgleg_id=None, force=False):
    """

    @param self:
    @type self:
    @param msg_id:
    @type msg_id:
    @param msgleg_id:
    @type msgleg_id:
    @param force:
    @type force:
    @return:
    @rtype:
    """
    if settings.CONFIG_DICT['email']['submit_to_webform'] or force:
        try:
            if msgleg_id is not None:
                MessageLegislator.objects.get(id=msgleg_id).send()
            elif msg_id is not None:
                msg = Message.objects.get(pk=msg_id)
                msg.send()
                if msg.get_send_status() == 'sent' or self.request.retries >= self.max_retries:

# Path: emailcongress/emailer.py
# class NoReply(PMMail):
#     HTML_BODY_TEMPLATE_DIR = 'emails/html_body/'
#     TEXT_BODY_TEMPLATE_DIR = 'emails/text_body/'
#     def __init__(self, django_user, **kwargs):
#     def send(self, test=False):
#     def _set_custom_headers_from_msg(self, msg):
#     def signup_confirm(self):
#     def address_change_request(self):
#     def remind_reps(self):
#     def email_confirm(self, msg):
#     def signup_success(self):
#     def reconfirm_info(self, msg):
#     def over_rate_limit(self, msg):
#     def message_queued(self, msg):
#     def message_undeliverable(self, leg_buckets, msg):
#     def message_receipt(self, legs, msg):
#     def send_status(self, msg_legs, msg):
#     def address_changed(self):
#     def custom_email(self, subject, html_template, text_template, context, custom_headers=None):


# Path: emailcongress/celery.py
import os
import traceback
from celery import Celery
from emailcongress import emailer
from django.conf import settings
            from emailcongress.models import Message, MessageLegislator

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'emailcongress.settings.shared')

celery = Celery('emailcongress')
for key, val in settings.CONFIG_DICT['celery'].items():
    setattr(celery.conf, key.upper(), val)


@celery.task(bind=True, max_retries=celery.conf.MAX_RETRIES, default_retry_delay=celery.conf.RETRY_DELAY)
def send_to_phantom_of_the_capitol(self, msg_id=None, msgleg_id=None, force=False):
    """

    @param self:
    @type self:
    @param msg_id:
    @type msg_id:
    @param msgleg_id:
    @type msgleg_id:
    @param force:
    @type force:
    @return:
    @rtype:
    """
    if settings.CONFIG_DICT['email']['submit_to_webform'] or force:
        try:
            if msgleg_id is not None:
                MessageLegislator.objects.get(id=msgleg_id).send()
            elif msg_id is not None:
                msg = Message.objects.get(pk=msg_id)
                msg.send()
                if msg.get_send_status() == 'sent' or self.request.retries >= self.max_retries:

                    emailer.NoReply(msg.user_message_info.user.django_user).send_status(msg.to_legislators, msg).send()