diff --git a/humbug/settings.py b/humbug/settings.py index 0b3dff6240..53f70da37a 100644 --- a/humbug/settings.py +++ b/humbug/settings.py @@ -426,6 +426,9 @@ OPENID_SSO_SERVER_URL = 'https://www.google.com/accounts/o8/id' OPENID_CREATE_USERS = True OPENID_RENDER_FAILURE = openid_failure_handler +MAILCHIMP_API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-us4' +HUMBUG_FRIENDS_LIST_ID = '84b2f3da6b' + EVENT_LOG_DIR = 'event_log' # Client-side polling timeout for get_events, in milliseconds. diff --git a/zephyr/management/commands/subscribe_new_users.py b/zephyr/management/commands/subscribe_new_users.py new file mode 100644 index 0000000000..8678594f12 --- /dev/null +++ b/zephyr/management/commands/subscribe_new_users.py @@ -0,0 +1,22 @@ +import simplejson +from postmonkey import PostMonkey +from django.core.management.base import BaseCommand +from django.conf import settings + +from zephyr.lib.queue import SimpleQueueClient + +class Command(BaseCommand): + pm = PostMonkey(settings.MAILCHIMP_API_KEY, timeout=10) + + def subscribe(self, ch, method, properties, data): + self.pm.listSubscribe( + id=settings.HUMBUG_FRIENDS_LIST_ID, + email_address=data['EMAIL'], + merge_vars=data['merge_vars'], + double_optin=False, + send_welcome=False) + + def handle(self, *args, **options): + q = SimpleQueueClient() + q.register_json_consumer("signups", self.subscribe) + q.start_consuming() diff --git a/zephyr/views.py b/zephyr/views.py index 7da86c6325..9df155289b 100644 --- a/zephyr/views.py +++ b/zephyr/views.py @@ -42,6 +42,7 @@ from zephyr.lib.response import json_success, json_error, json_response, json_me from zephyr.lib.timestamp import timestamp_to_datetime, datetime_to_timestamp from zephyr.lib.cache import cache_with_key from zephyr.lib.unminify import SourceMap +from zephyr.lib.queue import queue_json_publish from zephyr import tornado_callbacks from confirmation.models import Confirmation @@ -223,6 +224,17 @@ def accounts_register(request): ) notify_new_user(user_profile) + queue_json_publish( + "signups", + { + 'EMAIL': email, + 'merge_vars': { + 'NAME': full_name, + 'OPTIN_IP': request.META['REMOTE_ADDR'], + 'OPTIN_TIME': datetime.datetime.isoformat(datetime.datetime.now()), + }, + }, + lambda event: None) login(request, authenticate(username=email, password=password)) return HttpResponseRedirect(reverse('zephyr.views.home'))