Commit d1cb67d66dea0f35c22be4cfc37e3375df100c70
1 parent
aa732fce
Using API to subscribe user to mailinglists
Showing
2 changed files
with
3 additions
and
20 deletions
Show diff stats
src/accounts/views.py
@@ -23,7 +23,6 @@ from conversejs.models import XMPPAccount | @@ -23,7 +23,6 @@ from conversejs.models import XMPPAccount | ||
23 | from haystack.query import SearchQuerySet | 23 | from haystack.query import SearchQuerySet |
24 | 24 | ||
25 | from super_archives.models import EmailAddress, Message | 25 | from super_archives.models import EmailAddress, Message |
26 | -from super_archives.utils.email import send_email_lists | ||
27 | from search.utils import trans | 26 | from search.utils import trans |
28 | from proxy.models import WikiCollabCount, TicketCollabCount | 27 | from proxy.models import WikiCollabCount, TicketCollabCount |
29 | from .forms import (UserCreationForm, ListsForm, UserUpdateForm, | 28 | from .forms import (UserCreationForm, ListsForm, UserUpdateForm, |
@@ -137,10 +136,6 @@ def signup(request): | @@ -137,10 +136,6 @@ def signup(request): | ||
137 | 136 | ||
138 | user = user_form.save() | 137 | user = user_form.save() |
139 | 138 | ||
140 | - mailing_lists = lists_form.cleaned_data.get('lists') | ||
141 | - if mailing_lists: | ||
142 | - send_email_lists(user, mailing_lists) | ||
143 | - | ||
144 | # Check if the user's email have been used previously | 139 | # Check if the user's email have been used previously |
145 | # in the mainling lists to link the user to old messages | 140 | # in the mainling lists to link the user to old messages |
146 | email_addr, created = EmailAddress.objects.get_or_create(address=user.email) | 141 | email_addr, created = EmailAddress.objects.get_or_create(address=user.email) |
@@ -150,6 +145,9 @@ def signup(request): | @@ -150,6 +145,9 @@ def signup(request): | ||
150 | email_addr.user = user | 145 | email_addr.user = user |
151 | email_addr.save() | 146 | email_addr.save() |
152 | 147 | ||
148 | + mailing_lists = lists_form.cleaned_data.get('lists') | ||
149 | + mailman.update_subscription(user.email, mailing_lists) | ||
150 | + | ||
153 | messages.success(request, _('Your profile has been created!')) | 151 | messages.success(request, _('Your profile has been created!')) |
154 | messages.warning(request, _('You must login to validated your profile. ' | 152 | messages.warning(request, _('You must login to validated your profile. ' |
155 | 'Profiles not validated are deleted in 24h.')) | 153 | 'Profiles not validated are deleted in 24h.')) |
src/super_archives/utils/email.py
@@ -17,18 +17,3 @@ def send_verification_email(to, user, validation_key): | @@ -17,18 +17,3 @@ def send_verification_email(to, user, validation_key): | ||
17 | 'key': validation_key, | 17 | 'key': validation_key, |
18 | 'SITE_URL': settings.SITE_URL})) | 18 | 'SITE_URL': settings.SITE_URL})) |
19 | return colab_send_email(subject, message, to) | 19 | return colab_send_email(subject, message, to) |
20 | - | ||
21 | - | ||
22 | -def send_email_lists(user, mailing_lists): | ||
23 | - """XXX: this should be done using API instead of emails""" | ||
24 | - | ||
25 | - subject = _(u'Registration on the mailing list') | ||
26 | - from_ = user.email | ||
27 | - to = [] | ||
28 | - for list_name in mailing_lists: | ||
29 | - # TODO: The following line needs to be generic. Domain should be stored in settings file | ||
30 | - # or database (perharps read directly from mailman). | ||
31 | - subscribe_addr = list_name + '-subscribe@listas.interlegis.gov.br' | ||
32 | - to.append(subscribe_addr) | ||
33 | - | ||
34 | - mail.send_mail(subject, '', from_, to) |