From d1cb67d66dea0f35c22be4cfc37e3375df100c70 Mon Sep 17 00:00:00 2001 From: Sergio Oliveira Date: Mon, 29 Sep 2014 15:30:40 -0300 Subject: [PATCH] Using API to subscribe user to mailinglists --- src/accounts/views.py | 8 +++----- src/super_archives/utils/email.py | 15 --------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/accounts/views.py b/src/accounts/views.py index 7745da7..5bb1edf 100644 --- a/src/accounts/views.py +++ b/src/accounts/views.py @@ -23,7 +23,6 @@ from conversejs.models import XMPPAccount from haystack.query import SearchQuerySet from super_archives.models import EmailAddress, Message -from super_archives.utils.email import send_email_lists from search.utils import trans from proxy.models import WikiCollabCount, TicketCollabCount from .forms import (UserCreationForm, ListsForm, UserUpdateForm, @@ -137,10 +136,6 @@ def signup(request): user = user_form.save() - mailing_lists = lists_form.cleaned_data.get('lists') - if mailing_lists: - send_email_lists(user, mailing_lists) - # Check if the user's email have been used previously # in the mainling lists to link the user to old messages email_addr, created = EmailAddress.objects.get_or_create(address=user.email) @@ -150,6 +145,9 @@ def signup(request): email_addr.user = user email_addr.save() + mailing_lists = lists_form.cleaned_data.get('lists') + mailman.update_subscription(user.email, mailing_lists) + messages.success(request, _('Your profile has been created!')) messages.warning(request, _('You must login to validated your profile. ' 'Profiles not validated are deleted in 24h.')) diff --git a/src/super_archives/utils/email.py b/src/super_archives/utils/email.py index 774f2f1..9095406 100644 --- a/src/super_archives/utils/email.py +++ b/src/super_archives/utils/email.py @@ -17,18 +17,3 @@ def send_verification_email(to, user, validation_key): 'key': validation_key, 'SITE_URL': settings.SITE_URL})) return colab_send_email(subject, message, to) - - -def send_email_lists(user, mailing_lists): - """XXX: this should be done using API instead of emails""" - - subject = _(u'Registration on the mailing list') - from_ = user.email - to = [] - for list_name in mailing_lists: - # TODO: The following line needs to be generic. Domain should be stored in settings file - # or database (perharps read directly from mailman). - subscribe_addr = list_name + '-subscribe@listas.interlegis.gov.br' - to.append(subscribe_addr) - - mail.send_mail(subject, '', from_, to) -- libgit2 0.21.2