Skip to content
Snippets Groups Projects
Commit b6491d07 authored by Sylvain Lehmann's avatar Sylvain Lehmann
Browse files

feature: add email notification template field

parent e4fad5d8
No related branches found
No related tags found
1 merge request!45feature: filter auto mail notification by notification type
Pipeline #11722 passed
# Generated by Django 2.2.22 on 2021-06-04 12:03
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('djangoldp_notification', '0011_auto_20210218_1145'),
]
operations = [
migrations.AddField(
model_name='notification',
name='emailNotificationTemplate',
field=models.CharField(max_length=255, default='default'),
),
]
......@@ -30,6 +30,7 @@ class Notification(Model):
summary = models.TextField()
date = models.DateTimeField(auto_now_add=True)
unread = models.BooleanField(default=True)
emailNotificationTemplate = models.CharField(max_length=255, default='default')
class Meta(Model.Meta):
owner_field = 'user'
......@@ -224,7 +225,11 @@ def send_request(target, object_iri, instance, created):
@receiver(post_save, sender=Notification)
def send_email_on_notification(sender, instance, created, **kwargs):
if created and instance.summary and getattr(settings,'JABBER_DEFAULT_HOST',False) and instance.user.email:
if created \
and instance.summary \
and getattr(settings,'JABBER_DEFAULT_HOST',False) \
and instance.user.email \
and instance.emailNotificationTemplate == 'default':
# get author name, and store in who
try:
# local author
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment