news/views: Send e-mail to arch-announce on news creation
When send_announce is True, we send an e-mail to the arch-announce mail list, containing the content of the news and the URL (slug to it).
This commit is contained in:
parent
c68ae29cc4
commit
fba04673d9
@ -1,6 +1,8 @@
|
||||
from django import forms
|
||||
from django.core.mail import send_mail
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.template import Context, loader
|
||||
from django.views.decorators.http import require_POST
|
||||
from django.views.generic import (DetailView, ListView,
|
||||
CreateView, UpdateView, DeleteView)
|
||||
@ -37,6 +39,16 @@ def form_valid(self, form):
|
||||
newsitem.author = self.request.user
|
||||
newsitem.slug = find_unique_slug(News, newsitem.title)
|
||||
newsitem.save()
|
||||
if newsitem.send_announce:
|
||||
ctx = Context({
|
||||
'news': newsitem,
|
||||
})
|
||||
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)
|
||||
return super(NewsCreateView, self).form_valid(form)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user