Verified Commit 41201913 authored by Giancarlo Razzolini's avatar Giancarlo Razzolini
Browse files

news: Change the news app to use the EmailMessage class to be able to include the mailman password

Due to spamming to arch-announce mail list, we now use a poster password to make sure only authorized
emails are allowed through to the list.
parent c292bdd0
from django import forms
from django.core.mail import send_mail
from django.conf import settings
from django.core.mail import EmailMessage
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, redirect
from django.template import loader
......@@ -39,16 +40,19 @@ def form_valid(self, form):
newsitem.author = self.request.user
newsitem.slug = find_unique_slug(News, newsitem.title)
newsitem.save()
if newsitem.send_announce:
if newsitem.send_announce and settings.MAILMAN_PASSWORD:
ctx = {
'news': newsitem,
}
headers = {
'Approved': settings.MAILMAN_PASSWORD,
}
template = loader.get_template('news/news_email_notification.txt')
send_mail('[arch-announce] %s' % newsitem.title,
template.render(ctx),
'"Arch Linux: Recent news updates: %s" <arch-announce@archlinux.org>' % newsitem.author.get_full_name(),
['arch-announce@archlinux.org'],
fail_silently=True)
EmailMessage(subject='[arch-announce] %s' % newsitem.title,
body=template.render(ctx),
from_email='"Arch Linux: Recent news updates: %s" <arch-announce@archlinux.org>' % newsitem.author.get_full_name(),
to=['arch-announce@archlinux.org'],
headers=headers).send()
return super(NewsCreateView, self).form_valid(form)
......
......@@ -178,6 +178,9 @@
# Make this unique, and don't share it with anybody.
SECRET_KEY = '00000000000000000000000000000000000000000000000'
# Mailman poster password for announcements
MAILMAN_PASSWORD = ''
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment