Merged in [18901] from housley@vigilsec.com:
Make mail aliases for review teams and IAB programs. Fixes #3210
- Legacy-Id: 18918
Note: SVN reference [18901] has been migrated to Git commit 3e7e7c99d9
This commit is contained in:
commit
d603b625f0
|
@ -4,20 +4,22 @@
|
||||||
#
|
#
|
||||||
# $Id: generate-wg-aliases $
|
# $Id: generate-wg-aliases $
|
||||||
#
|
#
|
||||||
# Author: Markus Stenberg <markus.stenberg@iki.fi>
|
# Original Author: Markus Stenberg <markus.stenberg@iki.fi>
|
||||||
|
# Refactored By: Russ Housley <housley@vigilsec.com>
|
||||||
#
|
#
|
||||||
"""
|
"""
|
||||||
This script requires that the proper virtual python environment has been
|
This script requires that the proper virtual python environment has been
|
||||||
invoked before start.
|
invoked before start.
|
||||||
|
|
||||||
|
|
||||||
This code dumps Django model IETFWG's contents as two sets of postfix
|
This code dumps Django model IETFWG's contents as two sets of postfix
|
||||||
mail lists: -ads, and -chairs
|
mail lists: -ads, and -chairs
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# boilerplate (from various other ietf/bin scripts)
|
import io
|
||||||
import io, os, sys
|
import os
|
||||||
|
import sys
|
||||||
|
import datetime
|
||||||
|
import time
|
||||||
|
|
||||||
filename = os.path.abspath(__file__)
|
filename = os.path.abspath(__file__)
|
||||||
basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
|
basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
|
||||||
|
@ -36,25 +38,11 @@ from ietf.group.utils import get_group_ad_emails, get_group_role_emails, get_chi
|
||||||
from ietf.name.models import GroupTypeName
|
from ietf.name.models import GroupTypeName
|
||||||
from ietf.utils.aliases import dump_sublist
|
from ietf.utils.aliases import dump_sublist
|
||||||
|
|
||||||
# from secr/utils/group.py..
|
|
||||||
ACTIVE_STATES=['active', 'bof', 'proposed']
|
ACTIVE_STATES=['active', 'bof', 'proposed']
|
||||||
|
GROUP_TYPES=['wg','rg','dir','team','review','program']
|
||||||
|
NO_AD_GROUP_TYPES=['rg','team','program']
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import datetime
|
|
||||||
import time
|
|
||||||
|
|
||||||
# Year ago?
|
|
||||||
#show_since = datetime.datetime.now() - datetime.timedelta(365)
|
|
||||||
|
|
||||||
# 2 years ago?
|
|
||||||
#show_since = datetime.datetime.now() - datetime.timedelta(2 * 365)
|
|
||||||
|
|
||||||
# 3 years ago?
|
|
||||||
#show_since = datetime.datetime.now() - datetime.timedelta(3 * 365)
|
|
||||||
|
|
||||||
# 5 years ago?
|
|
||||||
show_since = datetime.datetime.now() - datetime.timedelta(5 * 365)
|
|
||||||
|
|
||||||
date = time.strftime("%Y-%m-%d_%H:%M:%S")
|
date = time.strftime("%Y-%m-%d_%H:%M:%S")
|
||||||
signature = '# Generated by %s at %s\n' % (filename, date)
|
signature = '# Generated by %s at %s\n' % (filename, date)
|
||||||
|
|
||||||
|
@ -64,84 +52,39 @@ if __name__ == '__main__':
|
||||||
afile.write(signature)
|
afile.write(signature)
|
||||||
vfile.write(signature)
|
vfile.write(signature)
|
||||||
vfile.write("%s anything\n" % settings.GROUP_VIRTUAL_DOMAIN)
|
vfile.write("%s anything\n" % settings.GROUP_VIRTUAL_DOMAIN)
|
||||||
|
|
||||||
|
# Inactive == 5 years ago
|
||||||
|
show_since = datetime.datetime.now() - datetime.timedelta(5 * 365)
|
||||||
|
|
||||||
# - Working groups -----------------------------------------
|
# Loop through each group type and build -ads and -chairs entries
|
||||||
wgs = Group.objects.filter(type='wg').all()
|
for g in GROUP_TYPES:
|
||||||
|
entries = Group.objects.filter(type=g).all()
|
||||||
|
active_entries = entries.filter(state__in=ACTIVE_STATES)
|
||||||
|
inactive_recent_entries = entries.exclude(state__in=ACTIVE_STATES).filter(time__gte=show_since)
|
||||||
|
interesting_entries = active_entries | inactive_recent_entries
|
||||||
|
|
||||||
# - status = Active
|
for e in interesting_entries.distinct().iterator():
|
||||||
active_wgs = wgs.filter(state__in=ACTIVE_STATES)
|
name = e.acronym
|
||||||
|
# Research groups, teams, and programs do not have -ads lists
|
||||||
|
if not g in NO_AD_GROUP_TYPES:
|
||||||
|
dump_sublist(afile, vfile, name+'-ads', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_ad_emails(e))
|
||||||
|
# All group types have -chairs lists
|
||||||
|
dump_sublist(afile, vfile, name+'-chairs', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_role_emails(e, ['chair', 'secr']))
|
||||||
|
|
||||||
# - activity within last year? (use concluded_date)
|
# The area lists include every chair in active working groups in the area
|
||||||
inactive_recent_wgs = wgs.exclude(state__in=ACTIVE_STATES).filter(time__gte=show_since)
|
|
||||||
interesting_wgs = active_wgs | inactive_recent_wgs
|
|
||||||
|
|
||||||
for wg in interesting_wgs.distinct().iterator():
|
|
||||||
name = wg.acronym
|
|
||||||
dump_sublist(afile, vfile, name+'-ads', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_ad_emails(wg))
|
|
||||||
dump_sublist(afile, vfile, name+'-chairs', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_role_emails(wg, ['chair', 'secr']))
|
|
||||||
|
|
||||||
# - Research groups -----------------------------------------
|
|
||||||
rgs = Group.objects.filter(type='rg').all()
|
|
||||||
|
|
||||||
# - status = Active
|
|
||||||
active_rgs = rgs.filter(state__in=ACTIVE_STATES)
|
|
||||||
|
|
||||||
# - activity within last year? (use concluded_date)
|
|
||||||
inactive_recent_rgs = rgs.exclude(state__in=ACTIVE_STATES).filter(time__gte=show_since)
|
|
||||||
interesting_rgs = active_rgs | inactive_recent_rgs
|
|
||||||
|
|
||||||
for rg in interesting_rgs.distinct().iterator():
|
|
||||||
name = rg.acronym
|
|
||||||
#dump_sublist('%s%s' % (name, '-ads'), get_group_ad_emails, rg, True)
|
|
||||||
dump_sublist(afile, vfile, name+'-chairs', ['ietf.org', 'irtf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_role_emails(rg, ['chair', 'secr']))
|
|
||||||
|
|
||||||
# - Directorates -----------------------------------------
|
|
||||||
directorates = Group.objects.filter(type='dir').all()
|
|
||||||
|
|
||||||
# - status = Active
|
|
||||||
active_directorates = directorates.filter(state__in=ACTIVE_STATES)
|
|
||||||
|
|
||||||
# - activity within last year? (use concluded_date)
|
|
||||||
inactive_recent_directorates = directorates.exclude(state__in=ACTIVE_STATES).filter(time__gte=show_since)
|
|
||||||
interesting_directorates = active_directorates | inactive_recent_directorates
|
|
||||||
|
|
||||||
for directorate in interesting_directorates.distinct().iterator():
|
|
||||||
name = directorate.acronym
|
|
||||||
dump_sublist(afile, vfile, name+'-ads', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_ad_emails(directorate))
|
|
||||||
dump_sublist(afile, vfile, name+'-chairs', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_role_emails(directorate, ['chair', 'secr']))
|
|
||||||
|
|
||||||
# - Teams -----------------------------------------
|
|
||||||
teams = Group.objects.filter(type='team').all()
|
|
||||||
|
|
||||||
# - status = Active
|
|
||||||
active_teams = teams.filter(state__in=ACTIVE_STATES)
|
|
||||||
|
|
||||||
# - activity within last year? (use concluded_date)
|
|
||||||
inactive_recent_teams = teams.exclude(state__in=ACTIVE_STATES).filter(time__gte=show_since)
|
|
||||||
interesting_teams = active_teams | inactive_recent_teams
|
|
||||||
|
|
||||||
for team in interesting_teams.distinct().iterator():
|
|
||||||
name = team.acronym
|
|
||||||
dump_sublist(afile, vfile, name+'-chairs', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_role_emails(team, ['chair', 'secr']))
|
|
||||||
|
|
||||||
# - Areas --------------------------------------------------
|
|
||||||
# Additionally, for areas, we should list -ads and -chairs
|
|
||||||
# (for every chair in active groups within the area).
|
|
||||||
areas = Group.objects.filter(type='area').all()
|
areas = Group.objects.filter(type='area').all()
|
||||||
active_areas = areas.filter(state__in=ACTIVE_STATES)
|
active_areas = areas.filter(state__in=ACTIVE_STATES)
|
||||||
for area in active_areas:
|
for area in active_areas:
|
||||||
name = area.acronym
|
name = area.acronym
|
||||||
area_ad_emails = get_group_role_emails(area, ['pre-ad', 'ad', 'chair'])
|
area_ad_emails = get_group_role_emails(area, ['pre-ad', 'ad', 'chair'])
|
||||||
dump_sublist(afile, vfile, name+'-ads' , ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, area_ad_emails)
|
dump_sublist(afile, vfile, name+'-ads', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, area_ad_emails)
|
||||||
dump_sublist(afile, vfile, name+'-chairs', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, (get_child_group_role_emails(area, ['chair', 'secr']) | area_ad_emails))
|
dump_sublist(afile, vfile, name+'-chairs', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, (get_child_group_role_emails(area, ['chair', 'secr']) | area_ad_emails))
|
||||||
|
|
||||||
|
# Other groups with chairs that require Internet-Draft submission approval
|
||||||
# - Special groups --------------------------------------------------
|
|
||||||
# We need to be able to send mail to chairs of groups that require
|
|
||||||
# group draft submission approval and don't otherwise have aliases
|
|
||||||
gtypes = GroupTypeName.objects.values_list('slug', flat=True)
|
gtypes = GroupTypeName.objects.values_list('slug', flat=True)
|
||||||
special_groups = Group.objects.filter(type__features__req_subm_approval=True, acronym__in=gtypes, state='active')
|
special_groups = Group.objects.filter(type__features__req_subm_approval=True, acronym__in=gtypes, state='active')
|
||||||
for group in special_groups:
|
for group in special_groups:
|
||||||
dump_sublist(afile, vfile, group.acronym+'-chairs', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_role_emails(group, ['chair', 'delegate']))
|
dump_sublist(afile, vfile, group.acronym+'-chairs', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_role_emails(group, ['chair', 'delegate']))
|
||||||
|
|
||||||
|
afile.close()
|
||||||
|
vfile.close()
|
Loading…
Reference in a new issue