news: Make the check for MAILMAN_PASSWORD backwards compatible

This makes the check work with previous versions of archweb while also taking into
account downstreams that might not want or need this change.
This commit is contained in:
Giancarlo Razzolini 2019-10-25 14:58:33 -03:00
parent 4120191306
commit d3a927e4e0
No known key found for this signature in database
GPG Key ID: F22FB1D78A77AEAB

View File

@ -40,13 +40,13 @@ def form_valid(self, form):
newsitem.author = self.request.user
newsitem.slug = find_unique_slug(News, newsitem.title)
newsitem.save()
if newsitem.send_announce and settings.MAILMAN_PASSWORD:
if newsitem.send_announce:
ctx = {
'news': newsitem,
}
headers = {
'Approved': settings.MAILMAN_PASSWORD,
}
headers = dict()
if settings.MAILMAN_PASSWORD:
headers['Approved'] = settings.MAILMAN_PASSWORD
template = loader.get_template('news/news_email_notification.txt')
EmailMessage(subject='[arch-announce] %s' % newsitem.title,
body=template.render(ctx),