Fix the notifications to each ID list mailing list. Change the footer of the emails. Fixes #723
- Legacy-Id: 3592
This commit is contained in:
parent
675c9fcb7f
commit
a379f713fa
|
@ -35,7 +35,7 @@ class DateField(DisplayField):
|
|||
def get_value(self, document):
|
||||
dates = document.documentchangedates_set.all()
|
||||
if dates and dates[0].new_version_date:
|
||||
return dates[0].new_version_date
|
||||
return dates[0].new_version_date.strftime('%Y-%m-%d')
|
||||
return document.time.strftime('%Y-%m-%d')
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import models
|
||||
from django.db.models import signals
|
||||
from django.db.models import signals, Q
|
||||
|
||||
from ietf.utils.mail import send_mail
|
||||
from redesign.doc.models import Document
|
||||
from redesign.group.models import Group, Role
|
||||
|
||||
|
@ -161,6 +163,21 @@ class ListNotification(models.Model):
|
|||
desc = models.TextField()
|
||||
significant = models.BooleanField(default=False)
|
||||
|
||||
def notify_by_email(self):
|
||||
clists = CommunityList.objects.filter(
|
||||
Q(added_ids=self.document) | Q(rule__cached_ids=self.document)).distinct()
|
||||
from_email = settings.DEFAULT_FROM_EMAIL
|
||||
for l in clists:
|
||||
subject = '%s notification: Changes on %s' % (l.long_name(), self.document.name)
|
||||
context = {'notification': self,
|
||||
'clist': l}
|
||||
to_email = ''
|
||||
filter_subscription = {'community_list': l}
|
||||
if not self.significant:
|
||||
filter_subscription['significant'] = False
|
||||
bcc = ','.join(list(set([i.email for i in EmailSubscription.objects.filter(**filter_subscription)])))
|
||||
send_mail(None, to_email, from_email, subject, 'community/public/notification_email.txt', context, bcc=bcc)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
super(ListNotification, self).save(*args, **kwargs)
|
||||
(changes, created) = DocumentChangeDates.objects.get_or_create(document=self.document)
|
||||
|
@ -170,6 +187,7 @@ class ListNotification(models.Model):
|
|||
else:
|
||||
changes.normal_change_date = self.notification_date
|
||||
changes.save()
|
||||
self.notify_by_email()
|
||||
|
||||
|
||||
def save_previous_states(sender, instance, **kwargs):
|
||||
|
|
|
@ -62,21 +62,34 @@ class ReferenceToRFCRule(RuleManager):
|
|||
codename = 'reference_to_rfc'
|
||||
description = 'All I-Ds that have a reference to a particular RFC'
|
||||
|
||||
def get_documents(self):
|
||||
return Document.objects.filter(Q(type__name='Draft') | Q(state__name='rfc')).filter(relateddocument__target__document__state__name='rfc', relateddocument__target__document__name__icontains=self.value).distinct()
|
||||
|
||||
|
||||
class ReferenceToIDRule(RuleManager):
|
||||
codename = 'reference_to_id'
|
||||
description = 'All I-Ds that have a reference to a particular I-D'
|
||||
|
||||
def get_documents(self):
|
||||
return Document.objects.filter(Q(type__name='Draft') | Q(state__name='rfc')).filter(relateddocument__target__document__type__name='Draft', relateddocument__target__document__name__icontains=self.value).distinct()
|
||||
|
||||
|
||||
class ReferenceFromRFCRule(RuleManager):
|
||||
codename = 'reference_from_rfc'
|
||||
description = 'All I-Ds that are referenced by a particular RFC'
|
||||
|
||||
def get_documents(self):
|
||||
return Document.objects.filter(Q(type__name='Draft') | Q(state__name='rfc')).filter(relateddocument__source__state__name='rfc', relateddocument__source__name__icontains=self.value).distinct()
|
||||
|
||||
|
||||
|
||||
class ReferenceFromIDRule(RuleManager):
|
||||
codename = 'reference_from_id'
|
||||
description = 'All I-Ds that are referenced by a particular I-D'
|
||||
|
||||
def get_documents(self):
|
||||
return Document.objects.filter(Q(type__name='Draft') | Q(state__name='rfc')).filter(relateddocument__source__type__name='Draft', relateddocument__source__name__icontains=self.value).distinct()
|
||||
|
||||
|
||||
class WithTextRule(RuleManager):
|
||||
codename = 'with_text'
|
||||
|
|
15
ietf/templates/community/public/notification_email.txt
Normal file
15
ietf/templates/community/public/notification_email.txt
Normal file
|
@ -0,0 +1,15 @@
|
|||
{% autoescape off %}
|
||||
Hello,
|
||||
|
||||
This is a notification from {{ clist.long_name }}.
|
||||
|
||||
Document: {{ notification.document }}
|
||||
|
||||
Change:
|
||||
{{ notification.desc }}
|
||||
|
||||
Best regards,
|
||||
|
||||
The datatracker login manager service
|
||||
(for the IETF Secretariat)
|
||||
{% endautoescape %}
|
|
@ -1,9 +1,12 @@
|
|||
{% autoescape off %}
|
||||
Hello,
|
||||
|
||||
In order to complete your subscription for {% if significant %}significant {% endif %}changes on {{ clist.long_name }}, please follow this link or copy it and paste it in your web browser:
|
||||
|
||||
http://{{ domain }}{% if significant %}{% url confirm_significant_subscription clist.id to_email today auth %}{% else %}{% url confirm_subscription clist.id to_email today auth %}{% endif %}
|
||||
|
||||
Best,
|
||||
Best regards,
|
||||
|
||||
Your {{ domain }} team.
|
||||
The datatracker login manager service
|
||||
(for the IETF Secretariat)
|
||||
{% endautoescape %}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
{% autoescape off %}
|
||||
Hello,
|
||||
|
||||
In order to complete the cancelation of your subscription to {% if significant %}significant {% endif %}changes on {{ clist.long_name }}, please follow this link or copy it and paste it in your web browser:
|
||||
|
||||
http://{{ domain }}{% if significant %}{% url confirm_significant_unsubscription clist.id to_email today auth %}{% else %}{% url confirm_unsubscription clist.id to_email today auth %}{% endif %}
|
||||
|
||||
Best,
|
||||
Best regards,
|
||||
|
||||
Your {{ domain }} team.
|
||||
The datatracker login manager service
|
||||
(for the IETF Secretariat)
|
||||
{% endautoescape %}
|
||||
|
|
Loading…
Reference in a new issue