From 6400bd7f69f1140d3c8a61a2eff30696b1120ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20A=2E=20S=C3=A1nchez=20L=C3=B3pez?= Date: Fri, 23 Jul 2010 08:13:55 +0000 Subject: [PATCH] Command to request SDO Authorized Individual list to be updated. Fixes #352 - Legacy-Id: 2375 --- ietf/liaisons/management/__init__.py | 0 ietf/liaisons/management/commands/__init__.py | 0 .../commands/remind_update_sdo_list.py | 52 +++++++++++++++++++ ietf/templates/liaisons/sdo_reminder.txt | 21 ++++++++ 4 files changed, 73 insertions(+) create mode 100644 ietf/liaisons/management/__init__.py create mode 100644 ietf/liaisons/management/commands/__init__.py create mode 100644 ietf/liaisons/management/commands/remind_update_sdo_list.py create mode 100644 ietf/templates/liaisons/sdo_reminder.txt diff --git a/ietf/liaisons/management/__init__.py b/ietf/liaisons/management/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/ietf/liaisons/management/commands/__init__.py b/ietf/liaisons/management/commands/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/ietf/liaisons/management/commands/remind_update_sdo_list.py b/ietf/liaisons/management/commands/remind_update_sdo_list.py new file mode 100644 index 000000000..8bc669b04 --- /dev/null +++ b/ietf/liaisons/management/commands/remind_update_sdo_list.py @@ -0,0 +1,52 @@ +from optparse import make_option + +from django.conf import settings +from django.core.mail import EmailMessage +from django.core.management.base import BaseCommand +from django.template.loader import render_to_string + +from ietf.liaisons.models import SDOs + + +class Command(BaseCommand): + 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") + option_list = BaseCommand.option_list + ( + make_option('-s', '--sdo-pk', dest='sdo_pk', + help='Send the reminder to the SDO whith this primary key. If not provided reminder will be sent to all SDOs'), + ) + + + def send_mail_to(self, person, sdo): + subject = 'Request for update list of authorized individuals' + email = person.email()[1] + name = ' '.join([i for i in (person.name_prefix, person.first_name, person.middle_initial, person.last_name, person.name_suffix) if i]) + authorized_list = [i.person for i in sdo.sdoauthorizedindividual_set.all()] + body = render_to_string('liaisons/sdo_reminder.txt', + {'manager_name': name, + 'sdo_name': sdo.sdo_name, + 'individuals': authorized_list, + }) + mail = EmailMessage(subject=subject, + to=[email], + from_email=settings.LIAISON_UNIVERSAL_FROM, + body = body) + if not settings.DEBUG: + mail.send() + print '%05s#: %s Mail Sent!' % (sdo.pk, sdo.sdo_name) + else: + print '%05s#: %s Mail Not Sent because in DEBUG mode!' % (sdo.pk, sdo.sdo_name) + return + + def handle(self, *args, **options): + query = SDOs.objects.all().order_by('pk') + sdo_pk = options.get('sdo_pk', None) + if sdo_pk: + query = query.filter(pk=sdo_pk) + + for sdo in query: + manager = sdo.liaisonmanager() + if manager: + self.send_mail_to(manager.person, sdo) + else: + print '%05s#: %s has no liaison manager' % (sdo.pk, sdo.sdo_name) + diff --git a/ietf/templates/liaisons/sdo_reminder.txt b/ietf/templates/liaisons/sdo_reminder.txt new file mode 100644 index 000000000..91110fc90 --- /dev/null +++ b/ietf/templates/liaisons/sdo_reminder.txt @@ -0,0 +1,21 @@ +Dear {{ manager_name }} + +This is an automatic reminder, please do not reply to this email. + +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. + +Current list in our system for {{ sdo_name }} is: + +------ +{% for person in individuals %} +{{ person.email.0 }} <{{ person.email.1 }}> +{% endfor %} +------ + +Please fell free to add or remove individuals from the list and send it to the secretariat at statments@ietf.org. + +For any questions please contact statments@ietf.org. + +Thank you, + +The IETF Secretariat (statements@ietf.org)