Skip to content

Commit 3e7e7c9

Browse files
committed
Make mail aliases for review teams and IAB programs. Fixes ietf-tools#3210
- Legacy-Id: 18901
1 parent cb554fa commit 3e7e7c9

1 file changed

Lines changed: 32 additions & 89 deletions

File tree

ietf/bin/generate-wg-aliases

Lines changed: 32 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44
#
55
# $Id: generate-wg-aliases $
66
#
7-
# Author: Markus Stenberg <markus.stenberg@iki.fi>
7+
# Original Author: Markus Stenberg <markus.stenberg@iki.fi>
8+
# Refactored By: Russ Housley <housley@vigilsec.com>
89
#
910
"""
1011
This script requires that the proper virtual python environment has been
1112
invoked before start.
1213
13-
1414
This code dumps Django model IETFWG's contents as two sets of postfix
1515
mail lists: -ads, and -chairs
16-
1716
"""
1817

19-
# boilerplate (from various other ietf/bin scripts)
20-
import io, os, sys
18+
import io
19+
import os
20+
import sys
21+
import datetime
22+
import time
2123

2224
filename = os.path.abspath(__file__)
2325
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
3638
from ietf.name.models import GroupTypeName
3739
from ietf.utils.aliases import dump_sublist
3840

39-
# from secr/utils/group.py..
4041
ACTIVE_STATES=['active', 'bof', 'proposed']
42+
GROUP_TYPES=['wg','rg','dir','team','review','program']
43+
NO_AD_GROUP_TYPES=['rg','team','program']
4144

4245
if __name__ == '__main__':
43-
import datetime
44-
import time
45-
46-
# Year ago?
47-
#show_since = datetime.datetime.now() - datetime.timedelta(365)
48-
49-
# 2 years ago?
50-
#show_since = datetime.datetime.now() - datetime.timedelta(2 * 365)
51-
52-
# 3 years ago?
53-
#show_since = datetime.datetime.now() - datetime.timedelta(3 * 365)
54-
55-
# 5 years ago?
56-
show_since = datetime.datetime.now() - datetime.timedelta(5 * 365)
57-
5846
date = time.strftime("%Y-%m-%d_%H:%M:%S")
5947
signature = '# Generated by %s at %s\n' % (filename, date)
6048

@@ -64,84 +52,39 @@ if __name__ == '__main__':
6452
afile.write(signature)
6553
vfile.write(signature)
6654
vfile.write("%s anything\n" % settings.GROUP_VIRTUAL_DOMAIN)
55+
56+
# Inactive == 5 years ago
57+
show_since = datetime.datetime.now() - datetime.timedelta(5 * 365)
6758

68-
# - Working groups -----------------------------------------
69-
wgs = Group.objects.filter(type='wg').all()
70-
71-
# - status = Active
72-
active_wgs = wgs.filter(state__in=ACTIVE_STATES)
73-
74-
# - activity within last year? (use concluded_date)
75-
inactive_recent_wgs = wgs.exclude(state__in=ACTIVE_STATES).filter(time__gte=show_since)
76-
interesting_wgs = active_wgs | inactive_recent_wgs
77-
78-
for wg in interesting_wgs.distinct().iterator():
79-
name = wg.acronym
80-
dump_sublist(afile, vfile, name+'-ads', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_ad_emails(wg))
81-
dump_sublist(afile, vfile, name+'-chairs', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_role_emails(wg, ['chair', 'secr']))
82-
83-
# - Research groups -----------------------------------------
84-
rgs = Group.objects.filter(type='rg').all()
85-
86-
# - status = Active
87-
active_rgs = rgs.filter(state__in=ACTIVE_STATES)
88-
89-
# - activity within last year? (use concluded_date)
90-
inactive_recent_rgs = rgs.exclude(state__in=ACTIVE_STATES).filter(time__gte=show_since)
91-
interesting_rgs = active_rgs | inactive_recent_rgs
92-
93-
for rg in interesting_rgs.distinct().iterator():
94-
name = rg.acronym
95-
#dump_sublist('%s%s' % (name, '-ads'), get_group_ad_emails, rg, True)
96-
dump_sublist(afile, vfile, name+'-chairs', ['ietf.org', 'irtf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_role_emails(rg, ['chair', 'secr']))
97-
98-
# - Directorates -----------------------------------------
99-
directorates = Group.objects.filter(type='dir').all()
100-
101-
# - status = Active
102-
active_directorates = directorates.filter(state__in=ACTIVE_STATES)
103-
104-
# - activity within last year? (use concluded_date)
105-
inactive_recent_directorates = directorates.exclude(state__in=ACTIVE_STATES).filter(time__gte=show_since)
106-
interesting_directorates = active_directorates | inactive_recent_directorates
107-
108-
for directorate in interesting_directorates.distinct().iterator():
109-
name = directorate.acronym
110-
dump_sublist(afile, vfile, name+'-ads', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_ad_emails(directorate))
111-
dump_sublist(afile, vfile, name+'-chairs', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_role_emails(directorate, ['chair', 'secr']))
112-
113-
# - Teams -----------------------------------------
114-
teams = Group.objects.filter(type='team').all()
115-
116-
# - status = Active
117-
active_teams = teams.filter(state__in=ACTIVE_STATES)
118-
119-
# - activity within last year? (use concluded_date)
120-
inactive_recent_teams = teams.exclude(state__in=ACTIVE_STATES).filter(time__gte=show_since)
121-
interesting_teams = active_teams | inactive_recent_teams
122-
123-
for team in interesting_teams.distinct().iterator():
124-
name = team.acronym
125-
dump_sublist(afile, vfile, name+'-chairs', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_role_emails(team, ['chair', 'secr']))
126-
127-
# - Areas --------------------------------------------------
128-
# Additionally, for areas, we should list -ads and -chairs
129-
# (for every chair in active groups within the area).
59+
# Loop through each group type and build -ads and -chairs entries
60+
for g in GROUP_TYPES:
61+
entries = Group.objects.filter(type=g).all()
62+
active_entries = entries.filter(state__in=ACTIVE_STATES)
63+
inactive_recent_entries = entries.exclude(state__in=ACTIVE_STATES).filter(time__gte=show_since)
64+
interesting_entries = active_entries | inactive_recent_entries
65+
66+
for e in interesting_entries.distinct().iterator():
67+
name = e.acronym
68+
# Research groups, teams, and programs do not have -ads lists
69+
if not g in NO_AD_GROUP_TYPES:
70+
dump_sublist(afile, vfile, name+'-ads', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_ad_emails(e))
71+
# All group types have -chairs lists
72+
dump_sublist(afile, vfile, name+'-chairs', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_role_emails(e, ['chair', 'secr']))
73+
74+
# The area lists include every chair in active working groups in the area
13075
areas = Group.objects.filter(type='area').all()
13176
active_areas = areas.filter(state__in=ACTIVE_STATES)
13277
for area in active_areas:
13378
name = area.acronym
13479
area_ad_emails = get_group_role_emails(area, ['pre-ad', 'ad', 'chair'])
135-
dump_sublist(afile, vfile, name+'-ads' , ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, area_ad_emails)
80+
dump_sublist(afile, vfile, name+'-ads', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, area_ad_emails)
13681
dump_sublist(afile, vfile, name+'-chairs', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, (get_child_group_role_emails(area, ['chair', 'secr']) | area_ad_emails))
13782

138-
139-
# - Special groups --------------------------------------------------
140-
# We need to be able to send mail to chairs of groups that require
141-
# group draft submission approval and don't otherwise have aliases
83+
# Other groups with chairs that require Internet-Draft submission approval
14284
gtypes = GroupTypeName.objects.values_list('slug', flat=True)
14385
special_groups = Group.objects.filter(type__features__req_subm_approval=True, acronym__in=gtypes, state='active')
14486
for group in special_groups:
14587
dump_sublist(afile, vfile, group.acronym+'-chairs', ['ietf.org', ], settings.GROUP_VIRTUAL_DOMAIN, get_group_role_emails(group, ['chair', 'delegate']))
14688

147-
89+
afile.close()
90+
vfile.close()

0 commit comments

Comments
 (0)