Notify by email of newly created liaisons that need approval. Fixes #361
- Legacy-Id: 2476
This commit is contained in:
parent
bfaf558e8d
commit
915c93cf3e
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
22
ietf/templates/liaisons/pending_liaison_mail.txt
Normal file
22
ietf/templates/liaisons/pending_liaison_mail.txt
Normal 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 }} <{{ liaison.replyto|default:liaison.from_email|fix_ampersands }}>)
|
||||
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.
|
Loading…
Reference in a new issue