From 2295373a4ebff308bf5a736da90edf432d643df5 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 19 Mar 2019 21:25:50 -0400 Subject: news: Make mailing list announcements configurable in settings.py --- main/context_processors.py | 1 + news/views.py | 7 ++++--- settings.py | 8 ++++++++ templates/news/news_email_notification.txt | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/main/context_processors.py b/main/context_processors.py index 96a45dcf..5d12e6f8 100644 --- a/main/context_processors.py +++ b/main/context_processors.py @@ -4,6 +4,7 @@ def secure(request): def branding(request): from django.conf import settings return { + 'WEB_URL': settings.WEB_URL, 'BUGTRACKER_URL': settings.BUGTRACKER_URL, 'MAILMAN_BASE_URL': settings.MAILMAN_BASE_URL, 'PROJECTS_URL': settings.PROJECTS_URL, diff --git a/news/views.py b/news/views.py index f85db171..f799fc08 100644 --- a/news/views.py +++ b/news/views.py @@ -1,4 +1,5 @@ from django import forms +from django.conf import settings from django.core.mail import send_mail from django.http import HttpResponse from django.shortcuts import get_object_or_404, redirect @@ -44,10 +45,10 @@ class NewsCreateView(CreateView): 'news': newsitem, }) template = loader.get_template('news/news_email_notification.txt') - send_mail('[arch-announce] %s' % newsitem.title, + send_mail('[%s] %s' % (settings.NEWS_MAILINGLIST, newsitem.title), template.render(ctx), - '"Arch Linux: Recent news updates: %s" ' % newsitem.author.get_full_name(), - ['arch-announce@archlinux.org'], + '"%s: Recent news updates: %s" <%s@%s>' % (settings.BRANDING_DISTRONAME, newsitem.author.get_full_name(), settings.NEWS_MAILINGLIST, settings.MAILMAN_DOMAIN), + ['%s@%s' % (settings.NEWS_MAILINGLIST, settings.MAILMAN_DOMAIN)], fail_silently=True) return super(NewsCreateView, self).form_valid(form) diff --git a/settings.py b/settings.py index e64e8620..a1216f2d 100644 --- a/settings.py +++ b/settings.py @@ -156,6 +156,9 @@ LOGGING = { PGP_SERVER = 'pgp.mit.edu' PGP_SERVER_SECURE = True +# URL where archweb is deployed +WEB_URL = 'https://www.archlinux.org' + # URL to fetch a current list of available ISOs ISO_LIST_URL = 'https://releng.archlinux.org/isos/' @@ -165,6 +168,11 @@ SVN_BASE_URL = 'svn://svn.archlinux.org/' # URL for linking to mailing lists MAILMAN_BASE_URL = 'https://mailman.archlinux.org/' +# Domain for mailman mailing lists +MAILMAN_DOMAIN = 'archlinux.org' + +# Email news items to NEWS_MAILINGLIST@MAILMAN_DOMAIN +NEWS_MAILINGLIST = 'arch-announce' # URL for linking to the bugtracker BUGTRACKER_URL = 'https://bugs.archlinux.org/' diff --git a/templates/news/news_email_notification.txt b/templates/news/news_email_notification.txt index 2588c921..6bc8f821 100644 --- a/templates/news/news_email_notification.txt +++ b/templates/news/news_email_notification.txt @@ -1,3 +1,3 @@ {{ news.content }} -URL: https://www.archlinux.org{{ news.get_absolute_url }} +URL: {{ WEB_URL }}{{ news.get_absolute_url }} -- cgit v1.2.2