Notify by email of newly created liaisons that need approval. Fixes #361

- Legacy-Id: 2476
This commit is contained in:
Emilio A. Sánchez López 2010-08-13 08:09:21 +00:00
parent bfaf558e8d
commit 915c93cf3e
3 changed files with 64 additions and 0 deletions

View file

@ -114,7 +114,31 @@ class LiaisonDetail(models.Model):
class Meta:
db_table = 'liaison_detail'
def notify_pending_by_email(self, fake):
from ietf.liaisons.utils import IETFHM
from_entity = IETFHM.get_entity_by_key(self.from_raw_code)
if not from_entity:
return None
to_email = []
for person in from_entity.can_approve():
to_email.append('%s <%s>' % person.email())
subject = 'New Liaison Statement, "%s" needs your approval' % (self.title)
from_email = settings.LIAISON_UNIVERSAL_FROM
body = render_to_string('liaisons/pending_liaison_mail.txt',
{'liaison': self,
})
mail = IETFEmailMessage(subject=subject,
to=to_email,
from_email=from_email,
body = body)
if not fake:
mail.send()
return mail
def send_by_email(self, fake=False):
if self.is_pending():
return self.notify_pending_by_email(fake)
subject = 'New Liaison Statement, "%s"' % (self.title)
from_email = settings.LIAISON_UNIVERSAL_FROM
to_email = self.to_poc.split(',')
@ -137,6 +161,9 @@ class LiaisonDetail(models.Model):
mail.send()
return mail
def is_pending(self):
return bool(self.approval and not self.approval.approved)
class SDOs(models.Model):
sdo_id = models.AutoField(primary_key=True)

View file

@ -44,6 +44,9 @@ class Entity(object):
def needs_approval(self, person=None):
return False
def can_approve(self):
return []
class IETFEntity(Entity):
@ -62,6 +65,9 @@ class IETFEntity(Entity):
return False
return True
def can_approve(self):
return [self.poc]
class IABEntity(Entity):
chair = FakePerson(**IABCHAIR)
@ -83,6 +89,9 @@ class IABEntity(Entity):
return False
return True
def can_approve(self):
return [self.chair]
class AreaEntity(Entity):
@ -103,6 +112,9 @@ class AreaEntity(Entity):
return False
return True
def can_approve(self):
return self.get_poc()
class WGEntity(Entity):
@ -130,6 +142,9 @@ class WGEntity(Entity):
return False
return True
def can_approve(self):
return [i.person for i in self.obj.area.area.areadirector_set.all()]
class SDOEntity(Entity):

View file

@ -0,0 +1,22 @@
The following liaison statement will remain pending (and not public available) in the system until you approve it:
Title: {{ liaison.title }}
Submission Date: {{ liaison.submitted_date }}
URL of the IETF Web page: {% url liaison_approval_detail liaison.pk %}
{% if liaison.deadline_date %}Please reply by {{ liaison.deadline_date }}{% endif %}
From: {{ liaison.from_body }} ({{ liaison.person }} &lt;{{ liaison.replyto|default:liaison.from_email|fix_ampersands }}&gt;)
To: {{ liaison.to_body }} ({{ liaison.to_poc }})
Cc: {{ liaison.cc1 }}
Reponse Contact: {{ liaison.response_contact }}
Technical Contact: {{ liaison.technical_contact }}
Purpose: {% if liaison.purpose_text %}{{ liaison.purpose_text }}{% else %}{{ liaison.purpose.purpose_text }}{% endif %}
Body: {{ liaison.body }}
Attachment(s):
{% for file in liaison.uploads_set.all %}
{{ file.file_title }} https://datatracker.ietf.org/documents/LIAISON/file{{ file.file_id }}{{ file.file_extension }}
{% empty %}
No document has been attached
{% endfor %}
Please visit {% url liaison_approval_detail liaison.pk %} in order to approve the liaison statement.