Skip to content

Commit 6400bd7

Browse files
committed
Command to request SDO Authorized Individual list to be updated. Fixes ietf-tools#352
- Legacy-Id: 2375
1 parent ab8cbbb commit 6400bd7

4 files changed

Lines changed: 73 additions & 0 deletions

File tree

ietf/liaisons/management/__init__.py

Whitespace-only changes.

ietf/liaisons/management/commands/__init__.py

Whitespace-only changes.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
from optparse import make_option
2+
3+
from django.conf import settings
4+
from django.core.mail import EmailMessage
5+
from django.core.management.base import BaseCommand
6+
from django.template.loader import render_to_string
7+
8+
from ietf.liaisons.models import SDOs
9+
10+
11+
class Command(BaseCommand):
12+
help = (u"Send a remind to each SDO Liaison Manager to update the list of persons authorized to send liaison statements on behalf of his SDO")
13+
option_list = BaseCommand.option_list + (
14+
make_option('-s', '--sdo-pk', dest='sdo_pk',
15+
help='Send the reminder to the SDO whith this primary key. If not provided reminder will be sent to all SDOs'),
16+
)
17+
18+
19+
def send_mail_to(self, person, sdo):
20+
subject = 'Request for update list of authorized individuals'
21+
email = person.email()[1]
22+
name = ' '.join([i for i in (person.name_prefix, person.first_name, person.middle_initial, person.last_name, person.name_suffix) if i])
23+
authorized_list = [i.person for i in sdo.sdoauthorizedindividual_set.all()]
24+
body = render_to_string('liaisons/sdo_reminder.txt',
25+
{'manager_name': name,
26+
'sdo_name': sdo.sdo_name,
27+
'individuals': authorized_list,
28+
})
29+
mail = EmailMessage(subject=subject,
30+
to=[email],
31+
from_email=settings.LIAISON_UNIVERSAL_FROM,
32+
body = body)
33+
if not settings.DEBUG:
34+
mail.send()
35+
print '%05s#: %s Mail Sent!' % (sdo.pk, sdo.sdo_name)
36+
else:
37+
print '%05s#: %s Mail Not Sent because in DEBUG mode!' % (sdo.pk, sdo.sdo_name)
38+
return
39+
40+
def handle(self, *args, **options):
41+
query = SDOs.objects.all().order_by('pk')
42+
sdo_pk = options.get('sdo_pk', None)
43+
if sdo_pk:
44+
query = query.filter(pk=sdo_pk)
45+
46+
for sdo in query:
47+
manager = sdo.liaisonmanager()
48+
if manager:
49+
self.send_mail_to(manager.person, sdo)
50+
else:
51+
print '%05s#: %s has no liaison manager' % (sdo.pk, sdo.sdo_name)
52+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Dear {{ manager_name }}
2+
3+
This is an automatic reminder, please do not reply to this email.
4+
5+
As liaison manager of {{ sdo_name }} you have to provide and updated list of persons who are authorized to send liaison statements on behalf of your SDO.
6+
7+
Current list in our system for {{ sdo_name }} is:
8+
9+
------
10+
{% for person in individuals %}
11+
{{ person.email.0 }} <{{ person.email.1 }}>
12+
{% endfor %}
13+
------
14+
15+
Please fell free to add or remove individuals from the list and send it to the secretariat at statments@ietf.org.
16+
17+
For any questions please contact statments@ietf.org.
18+
19+
Thank you,
20+
21+
The IETF Secretariat (statements@ietf.org)

0 commit comments

Comments
 (0)