Permalink
Browse files

remove MailChimp support

  • Loading branch information...
1 parent f29fe2e commit c80204d8e54b954aa3a3c703413d51068f5bd10c Alex Buchanan committed Aug 11, 2010
View
@@ -5,7 +5,6 @@
class EmailAdmin(admin.ModelAdmin):
list_display = ('name', 'short_subject', 'short_text', 'recipient_count')
- exclude = ('mailchimp_campaign',)
ordering = ('name',)
def short_subject(self, obj):
View
@@ -4,16 +4,12 @@
from django.core.exceptions import ValidationError
from django.core import mail
-from greatape import MailChimp
-
from emailer.models import Recipient
from subscriptions.models import Subscriber
log = commonware.log.getLogger('basket')
-mailchimp = MailChimp(settings.MAILCHIMP_API_KEY)
-
class BaseEmailer(object):
"""
@@ -118,42 +114,3 @@ def send_email(self):
sent.save()
connection.close()
-
-
-class MailChimpEmailer(BaseEmailer):
- """
- Send email using MailChimp lists and transactional campaigns
- """
-
- def send_email(self):
- """Send out the email and record the recipients."""
- recipients = self.get_recipients()
- if not recipients:
- log.info('Nothing to do: List of recipients is empty.')
- return
-
- # MailChimp recommends max batch size of 10K
- recipients = recipients[0:10000]
-
- batch = [dict(EMAIL=x.email, EMAIL_TYPE='html') for x in recipients]
-
- ret = mailchimp.listBatchSubscribe(id=self.email.mailchimp_list,
- batch=batch, double_optin=False)
-
- failed = [x['row']['EMAIL'] for x in ret['errors']]
-
- for recipient in recipients:
- if recipient.email in failed:
- log.error('Failed to subscribe %s' % recipient.email)
- else:
- log.info('Subscribed %s' % recipient.email)
- sent = Recipient(subscriber=recipient, email=self.email)
- try:
- sent.validate_unique()
- except ValidationError:
- # Already exists? Sending was probably forced.
- pass
- else:
- sent.save()
-
- mailchimp.campaignSendNow(cid=self.email.mailchimp_campaign)
@@ -1 +1 @@
-[{"pk": 1, "model": "emailer.email", "fields": {"mailchimp_campaign": "", "name": "iphone-reg", "text": "Greetings!\r\n\r\nFollow these four simple steps to set up Firefox Home and start sharing your Firefox history, bookmarks and even your open tabs between your computer and your iPhone or iPod Touch:\r\n\r\n1. Install the free Firefox Sync add-on on your desktop: <http://www.mozilla.com/en-US/firefox/sync/>\r\n (Firefox Home uses the sync capabilities from the Firefox Sync add-on to access your Firefox browser information and securely send it to your iPhone.)\r\n\r\n2. Restart Firefox and follow prompts to create an account with both a password and a Secret Phrase.\r\n\r\n3. Sign in, then go to your iPhone to complete the setup.\r\n\r\n4. On your iPhone, enter your new account log-in info in the fields provided and tap \"Done\" on the keypad.\r\n (Already using Firefox Sync on your desktop? Go to iTunes and install the Firefox Home app from the App Store on your iPhone.)\r\n\r\nYou're done! After these steps, you can take your favorite parts of the Web with you on your iPhone.\r\n\r\nIf you do not setup Firefox Home within one week of receiving this email, one reminder email will be sent to you.\r\n\r\nSee our Privacy Policy: <http://www.mozilla.com/en-US/privacy-policy.html>\r\nVisit us for more information about Firefox Home: <http://www.mozilla.com/en-US/mobile/home/>", "html": "<html lang=\"en-US\">\r\n<body>\r\n<p>Greetings!</p>\r\n\r\n<p>Follow these four simple steps to set up <strong>Firefox Home</strong> and start sharing your Firefox history, bookmarks and even your open tabs between your computer and your iPhone or iPod Touch:</p>\r\n\r\n<ol>\r\n<li>\r\n<p style=\"font-weight:bold\">Install the <a href=\"http://www.mozilla.com/en-US/firefox/sync/\">free Firefox Sync add-on</a> on your desktop.</p>\r\n<p style=\"font-size:90%;color:#807970\">Firefox Home uses the sync capabilities from the Firefox Sync add-on to access your Firefox browser information and securely send it to your iPhone.</p>\r\n</li>\r\n\r\n<li><p style=\"font-weight:bold\">Restart Firefox and follow prompts to create an account with both a password and a Secret Phrase.</p></li>\r\n\r\n<li><p style=\"font-weight:bold\">Sign in, then go to your iPhone to complete the setup.</p></li>\r\n\r\n<li>\r\n<p style=\"font-weight:bold\">On your iPhone, enter your new account log-in info in the fields provided and tap \"Done\" on the keypad.</p>\r\n<p style=\"font-size:90%;color:#807970\">Already using Firefox Sync on your desktop? Go to iTunes and install the Firefox Home app from the App Store on your iPhone.</p>\r\n</li>\r\n</ol>\r\n\r\n<p>You're done! After these steps, you can take your favorite parts of the Web with you on your iPhone.</p>\r\n\r\n<p>If you do not set up Firefox Home within one week of receiving this email, one reminder email will be sent to you.</p>\r\n\r\n<p>See our <a href=\"http://www.mozilla.com/en-US/privacy-policy.html\">Privacy Policy</a>. Visit us for more information about <a href=\"http://www.mozilla.com/en-US/mobile/home/\">Firefox Home</a>.</p>\r\n</body>\r\n</html>", "emailer_class": "", "mailchimp_list": "", "subject": "Set Up Firefox Home On Your iPhone"}}, {"pk": 2, "model": "emailer.email", "fields": {"mailchimp_campaign": "", "name": "iphone-reminder", "text": "Greetings!\r\n\r\nA few days ago you expressed interest in setting up Firefox Home on your iPhone.\r\n\r\nFollow these four simple steps to set up Firefox Home and start sharing your Firefox history, bookmarks and even your open tabs between your computer and your iPhone or iPod Touch:\r\n\r\n1. Install the free Firefox Sync add-on on your desktop: <http://www.mozilla.com/en-US/firefox/sync/>\r\n (Firefox Home uses the sync capabilities from the Firefox Sync add-on to access your Firefox browser information and securely send it to your iPhone.)\r\n\r\n2. Restart Firefox and follow prompts to create an account with both a password and a Secret Phrase.\r\n\r\n3. Sign in, then go to your iPhone to complete the setup.\r\n\r\n4. On your iPhone, enter your new account log-in info in the fields provided and tap \"Done\" on the keypad.\r\n (Already using Firefox Sync on your desktop? Go to iTunes and install the Firefox Home app from the App Store on your iPhone.)\r\n\r\nYou're done! After these steps, you can take your favorite parts of the Web with you on your iPhone.\r\n\r\nWe will not be sending you any further reminder emails.\r\n\r\nVisit us for more information about Firefox Home: <http://www.mozilla.com/en-US/mobile/home/>", "html": "<html lang=\"en-US\">\r\n<body>\r\n<p>Greetings!</p>\r\n\r\n<p>A few days ago you expressed interest in setting up Firefox Home on your iPhone.</p>\r\n\r\n<p>Follow these four simple steps to set up <strong>Firefox Home</strong> and start sharing your Firefox history, bookmarks and even your open tabs between your computer and your iPhone or iPod Touch:</p>\r\n\r\n<ol>\r\n<li>\r\n<p style=\"font-weight:bold\">Install the <a href=\"http://www.mozilla.com/en-US/firefox/sync/\">free Firefox Sync add-on</a> on your desktop.</p>\r\n<p style=\"font-size:90%;color:#807970\">Firefox Home uses the sync capabilities from the Firefox Sync add-on to access your Firefox browser information and securely send it to your iPhone.</p>\r\n</li>\r\n\r\n<li><p style=\"font-weight:bold\">Restart Firefox and follow prompts to create an account with both a password and a Secret Phrase.</p></li>\r\n\r\n<li><p style=\"font-weight:bold\">Sign in, then go to your iPhone to complete the setup.</p></li>\r\n\r\n<li>\r\n<p style=\"font-weight:bold\">On your iPhone, enter your new account log-in info in the fields provided and tap \"Done\" on the keypad.</p>\r\n<p style=\"font-size:90%;color:#807970\">Already using Firefox Sync on your desktop? Go to iTunes and install the Firefox Home app from the App Store on your iPhone.</p>\r\n</li>\r\n</ol>\r\n\r\n<p>You're done! After these steps, you can take your favorite parts of the Web with you on your iPhone.</p>\r\n\r\n<p>We will not be sending you any further reminder emails.</p>\r\n\r\n<p>Visit us for more information about <a href=\"http://www.mozilla.com/en-US/mobile/home/\">Firefox Home</a>.</p>\r\n</body>\r\n</html>", "emailer_class": "custom_emailers.reminder.ReminderEmailer", "mailchimp_list": "aa3479dc85", "subject": "Reminder to Set Up Firefox Home On Your iPhone"}}]
+[{"pk": 1, "model": "emailer.email", "fields": {"name": "iphone-reg", "text": "Greetings!\r\n\r\nFollow these four simple steps to set up Firefox Home and start sharing your Firefox history, bookmarks and even your open tabs between your computer and your iPhone or iPod Touch:\r\n\r\n1. Install the free Firefox Sync add-on on your desktop: <http://www.mozilla.com/en-US/firefox/sync/>\r\n (Firefox Home uses the sync capabilities from the Firefox Sync add-on to access your Firefox browser information and securely send it to your iPhone.)\r\n\r\n2. Restart Firefox and follow prompts to create an account with both a password and a Secret Phrase.\r\n\r\n3. Sign in, then go to your iPhone to complete the setup.\r\n\r\n4. On your iPhone, enter your new account log-in info in the fields provided and tap \"Done\" on the keypad.\r\n (Already using Firefox Sync on your desktop? Go to iTunes and install the Firefox Home app from the App Store on your iPhone.)\r\n\r\nYou're done! After these steps, you can take your favorite parts of the Web with you on your iPhone.\r\n\r\nIf you do not setup Firefox Home within one week of receiving this email, one reminder email will be sent to you.\r\n\r\nSee our Privacy Policy: <http://www.mozilla.com/en-US/privacy-policy.html>\r\nVisit us for more information about Firefox Home: <http://www.mozilla.com/en-US/mobile/home/>", "html": "<html lang=\"en-US\">\r\n<body>\r\n<p>Greetings!</p>\r\n\r\n<p>Follow these four simple steps to set up <strong>Firefox Home</strong> and start sharing your Firefox history, bookmarks and even your open tabs between your computer and your iPhone or iPod Touch:</p>\r\n\r\n<ol>\r\n<li>\r\n<p style=\"font-weight:bold\">Install the <a href=\"http://www.mozilla.com/en-US/firefox/sync/\">free Firefox Sync add-on</a> on your desktop.</p>\r\n<p style=\"font-size:90%;color:#807970\">Firefox Home uses the sync capabilities from the Firefox Sync add-on to access your Firefox browser information and securely send it to your iPhone.</p>\r\n</li>\r\n\r\n<li><p style=\"font-weight:bold\">Restart Firefox and follow prompts to create an account with both a password and a Secret Phrase.</p></li>\r\n\r\n<li><p style=\"font-weight:bold\">Sign in, then go to your iPhone to complete the setup.</p></li>\r\n\r\n<li>\r\n<p style=\"font-weight:bold\">On your iPhone, enter your new account log-in info in the fields provided and tap \"Done\" on the keypad.</p>\r\n<p style=\"font-size:90%;color:#807970\">Already using Firefox Sync on your desktop? Go to iTunes and install the Firefox Home app from the App Store on your iPhone.</p>\r\n</li>\r\n</ol>\r\n\r\n<p>You're done! After these steps, you can take your favorite parts of the Web with you on your iPhone.</p>\r\n\r\n<p>If you do not set up Firefox Home within one week of receiving this email, one reminder email will be sent to you.</p>\r\n\r\n<p>See our <a href=\"http://www.mozilla.com/en-US/privacy-policy.html\">Privacy Policy</a>. Visit us for more information about <a href=\"http://www.mozilla.com/en-US/mobile/home/\">Firefox Home</a>.</p>\r\n</body>\r\n</html>", "emailer_class": "", "subject": "Set Up Firefox Home On Your iPhone"}}, {"pk": 2, "model": "emailer.email", "fields": {"name": "iphone-reminder", "text": "Greetings!\r\n\r\nA few days ago you expressed interest in setting up Firefox Home on your iPhone.\r\n\r\nFollow these four simple steps to set up Firefox Home and start sharing your Firefox history, bookmarks and even your open tabs between your computer and your iPhone or iPod Touch:\r\n\r\n1. Install the free Firefox Sync add-on on your desktop: <http://www.mozilla.com/en-US/firefox/sync/>\r\n (Firefox Home uses the sync capabilities from the Firefox Sync add-on to access your Firefox browser information and securely send it to your iPhone.)\r\n\r\n2. Restart Firefox and follow prompts to create an account with both a password and a Secret Phrase.\r\n\r\n3. Sign in, then go to your iPhone to complete the setup.\r\n\r\n4. On your iPhone, enter your new account log-in info in the fields provided and tap \"Done\" on the keypad.\r\n (Already using Firefox Sync on your desktop? Go to iTunes and install the Firefox Home app from the App Store on your iPhone.)\r\n\r\nYou're done! After these steps, you can take your favorite parts of the Web with you on your iPhone.\r\n\r\nWe will not be sending you any further reminder emails.\r\n\r\nVisit us for more information about Firefox Home: <http://www.mozilla.com/en-US/mobile/home/>", "html": "<html lang=\"en-US\">\r\n<body>\r\n<p>Greetings!</p>\r\n\r\n<p>A few days ago you expressed interest in setting up Firefox Home on your iPhone.</p>\r\n\r\n<p>Follow these four simple steps to set up <strong>Firefox Home</strong> and start sharing your Firefox history, bookmarks and even your open tabs between your computer and your iPhone or iPod Touch:</p>\r\n\r\n<ol>\r\n<li>\r\n<p style=\"font-weight:bold\">Install the <a href=\"http://www.mozilla.com/en-US/firefox/sync/\">free Firefox Sync add-on</a> on your desktop.</p>\r\n<p style=\"font-size:90%;color:#807970\">Firefox Home uses the sync capabilities from the Firefox Sync add-on to access your Firefox browser information and securely send it to your iPhone.</p>\r\n</li>\r\n\r\n<li><p style=\"font-weight:bold\">Restart Firefox and follow prompts to create an account with both a password and a Secret Phrase.</p></li>\r\n\r\n<li><p style=\"font-weight:bold\">Sign in, then go to your iPhone to complete the setup.</p></li>\r\n\r\n<li>\r\n<p style=\"font-weight:bold\">On your iPhone, enter your new account log-in info in the fields provided and tap \"Done\" on the keypad.</p>\r\n<p style=\"font-size:90%;color:#807970\">Already using Firefox Sync on your desktop? Go to iTunes and install the Firefox Home app from the App Store on your iPhone.</p>\r\n</li>\r\n</ol>\r\n\r\n<p>You're done! After these steps, you can take your favorite parts of the Web with you on your iPhone.</p>\r\n\r\n<p>We will not be sending you any further reminder emails.</p>\r\n\r\n<p>Visit us for more information about <a href=\"http://www.mozilla.com/en-US/mobile/home/\">Firefox Home</a>.</p>\r\n</body>\r\n</html>", "emailer_class": "custom_emailers.reminder.ReminderEmailer", "subject": "Reminder to Set Up Firefox Home On Your iPhone"}}]
View
@@ -3,13 +3,9 @@
from django.core.urlresolvers import get_callable
from django.db import models
-from greatape import MailChimp
-
import emailer
from subscriptions.models import Subscriber
-mailchimp = MailChimp(settings.MAILCHIMP_API_KEY)
-
class Email(models.Model):
"""An email template, to be sent to subscribers."""
@@ -31,74 +27,10 @@ class Email(models.Model):
"The sender's address e.g. campaign@mozilla.com"))
reply_to_email = models.EmailField(blank=True, help_text=(
"The reply-to address"))
- mailchimp_campaign = models.CharField(max_length=20, blank=True)
- mailchimp_list = models.CharField(max_length=20, blank=True, help_text=(
- "MailChimp list ID."
- "Only required if you're using the MailChimp emailer."
- "You can find this in the MailChimp list admin page."))
def get_emailer_callable(self):
return get_callable(self.emailer_class or 'emailer.base.BaseEmailer')
- def clean(self):
- if issubclass(self.get_emailer_callable(),
- emailer.base.MailChimpEmailer):
-
- if not self.mailchimp_list:
- raise ValidationError("A MailChimp list ID is required.")
-
- def save(self):
- if issubclass(self.get_emailer_callable(),
- emailer.base.MailChimpEmailer):
-
- if not self.mailchimp_campaign:
- self.create_mailchimp_campaign()
- else:
- self.update_mailchimp_campaign()
-
- super(Email, self).save()
-
- def update_mailchimp_campaign(self):
- """Update the MailChimp campaign"""
-
- mailchimp.campaignUpdate(cid=self.mailchimp_campaign, name='list_id',
- value=self.mailchimp_list)
- mailchimp.campaignUpdate(cid=self.mailchimp_campaign, name='subject',
- value=self.subject)
- updates = {
- 'list_id': self.mailchimp_list,
- 'subject': self.subject,
- 'from_email': self.from_email,
- 'from_name': self.from_name,
- 'auto_footer': False,
- 'content': {
- 'html': self.html,
- 'text': self.text,
- }
- }
- for name, update in updates.items():
- mailchimp.campaignUpdate(cid=self.mailchimp_campaign, name=name,
- value=update)
-
- def create_mailchimp_campaign(self):
- """Create a MailChimp campaign and store its ID."""
-
- type = 'trans'
- options = {
- 'list_id': self.mailchimp_list,
- 'subject': self.subject,
- 'from_email': self.from_email,
- 'from_name': self.from_name,
- 'auto_footer': False,
- }
- content = {
- 'html': self.html,
- 'text': self.text,
- }
- cid = mailchimp.campaignCreate(type=type, options=options,
- content=content)
- self.mailchimp_campaign = cid
-
class Recipient(models.Model):
"""
@@ -1,5 +0,0 @@
-ALTER TABLE emailer_email ADD COLUMN mailchimp_campaign varchar(20) NOT NULL;
-ALTER TABLE emailer_email ADD COLUMN mailchimp_list varchar(20) NOT NULL;
-UPDATE emailer_email SET emailer_class = 'emailer.base.MailChimpEmailer' WHERE name = 'iphone-reg';
-UPDATE emailer_email SET mailchimp_list = '52f11438bb' WHERE name = 'iphone-reg';
-UPDATE emailer_email SET mailchimp_list = 'aa3479dc85' WHERE name = 'iphone-reminder';
View
@@ -14,6 +14,4 @@ mercurial==1.5.4
oauth2==1.2.0
lockfile==0.8
--e git://github.com/threadsafelabs/greatape.git#egg=greatape
-
python-ldap==2.3.11
View
@@ -113,9 +113,6 @@
DEFAULT_FROM_EMAIL = 'basket@mozilla.com'
DEFAULT_FROM_NAME = 'Mozilla'
-# MailChimp API
-MAILCHIMP_API_KEY = ''
-
# Logging
LOG_LEVEL = logging.DEBUG
HAS_SYSLOG = True # syslog is used if HAS_SYSLOG and NOT DEBUG.
View
@@ -32,9 +32,6 @@
DEBUG_PROPAGATE_EXCEPTIONS = DEBUG
-# MailChimp API
-MAILCHIMP_API_KEY = ''
-
# LDAP
LDAP = {
'host': '',

0 comments on commit c80204d

Please sign in to comment.