90 lines
2.9 KiB
Python
Executable file
90 lines
2.9 KiB
Python
Executable file
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
# -*- Python -*-
|
|
#
|
|
# $Id: generate-wg-aliases $
|
|
#
|
|
# Author: Markus Stenberg <markus.stenberg@iki.fi>
|
|
#
|
|
"""
|
|
|
|
This code dumps Django model IETFWG's contents as two sets of postfix
|
|
mail lists: -ads, and -chairs
|
|
|
|
"""
|
|
|
|
# boilerplate (from various other ietf/bin scripts)
|
|
import os, sys
|
|
basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
|
|
sys.path = [ basedir ] + sys.path
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ietf.settings")
|
|
|
|
|
|
from ietf.group.models import Group
|
|
from ietf.group.utils import get_group_ads_emails, get_group_chairs_emails, get_area_ads_emails, get_area_chairs_emails
|
|
from ietf.person.models import Email
|
|
from ietf.utils.aliases import *
|
|
|
|
# from secr/utils/group.py..
|
|
ACTIVE_STATES=['active', 'bof', 'proposed']
|
|
|
|
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)
|
|
|
|
modname = 'ietf.generate_wg_aliases'
|
|
date = time.strftime("%Y-%m-%d_%H:%M:%S")
|
|
print '# Generated by python -m %s at %s' % (modname, date)
|
|
wgs = Group.objects.filter(type='wg').all()
|
|
|
|
print '# WGs'
|
|
# - status = Active
|
|
active_wgs = wgs.filter(state__in=ACTIVE_STATES)
|
|
|
|
# - activity within last year? (use concluded_date)
|
|
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('%s%s' % (name, '-ads'), get_group_ads_emails, wg, True)
|
|
dump_sublist('%s%s' % (name, '-chairs'), get_group_chairs_emails, wg)
|
|
|
|
print '# RGs'
|
|
# - status = Active
|
|
rgs = Group.objects.filter(type='rg').all()
|
|
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_ads_emails, rg, True)
|
|
dump_sublist('%s%s' % (name, '-chairs'), get_group_chairs_emails, rg)
|
|
|
|
# Additionally, for areaz, we should list -ads and -chairs
|
|
# (for every chair in active groups within the area).
|
|
print '# Areas'
|
|
areas = Group.objects.filter(type='area').all()
|
|
active_areas = areas.filter(state__in=ACTIVE_STATES)
|
|
for area in active_areas:
|
|
name = area.acronym
|
|
dump_sublist('%s%s' % (name, '-ads'), get_area_ads_emails, area, True)
|
|
dump_sublist('%s%s' % (name, '-chairs'), get_area_chairs_emails, area)
|
|
|
|
|