Tweaks
- extra column in events grid with location & time - bugfixes in locationwidget - prepared email notifications
This commit is contained in:
@@ -18,4 +18,39 @@ class Message ( models.Model ):
|
||||
return self.author.username + " : " + self.titel
|
||||
|
||||
|
||||
|
||||
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
|
||||
from django.core.mail import EmailMultiAlternatives
|
||||
|
||||
from musicians.models import Musician
|
||||
|
||||
from django.template.loader import get_template
|
||||
|
||||
from django.template import Context
|
||||
|
||||
@receiver(post_save, sender=Message)
|
||||
def my_handler(sender, instance, created, **kwargs):
|
||||
if not created:
|
||||
return
|
||||
|
||||
receivers = [ m.user.email for m in Musician.objects.all() ]
|
||||
# overwrite only to me for now
|
||||
receivers = [ 'martinbauer86@gmail.com' ]
|
||||
|
||||
subject = "Blechreiz Forum: " + instance.titel
|
||||
from_email = 'forum@blechreiz.com'
|
||||
|
||||
c = { 'messages': Message.objects.all().order_by('-creation_time')[:10] }
|
||||
|
||||
text_template = get_template( "simpleforum/mail.txt" )
|
||||
html_template = get_template( "simpleforum/mail.html" )
|
||||
|
||||
text_content = text_template.render( Context(c) )
|
||||
#html_content = html_template.render( Context(c) )
|
||||
|
||||
msg = EmailMultiAlternatives( subject, text_content, from_email, receivers )
|
||||
#msg.attach_alternative( html_content, "text/html" )
|
||||
msg.send()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user