Skip to content

Commit 3a45c8e

Browse files
committed
Merge the I-D notification work from my sprint branch.
- Legacy-Id: 2112
1 parent ec4b877 commit 3a45c8e

5 files changed

Lines changed: 84 additions & 3 deletions

File tree

changelog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
ietfdb (2.46)
2+
3+
From Robert:
4+
5+
* Add the I-D expiration notification script.
6+
7+
-- Bill Fenner <fenner@fenron.net> 20 Mar 2010 12:59:50 -0800
8+
19
ietfdb (2.45)
210

311
From Pasi:

ietf/bin/notify-expirations

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env python
2+
3+
import datetime
4+
5+
from ietf import settings
6+
from django.core import management
7+
management.setup_environ(settings)
8+
9+
from ietf.idtracker.models import InternetDraft,IDAuthor,WGChair
10+
from ietf.utils.mail import send_mail_subj
11+
12+
notify_days = 14 # notify about documents that expire within the
13+
# next 2 weeks
14+
15+
start_date = datetime.date.today() - datetime.timedelta(InternetDraft.DAYS_TO_EXPIRE - 1)
16+
end_date = start_date + datetime.timedelta(notify_days - 1)
17+
18+
19+
matches = InternetDraft.objects.filter(revision_date__gte=start_date,revision_date__lte=end_date,status__status='Active')
20+
21+
#For development - focus on one draft
22+
#matches = InternetDraft.objects.filter(filename__icontains='geopriv-http-location-delivery')
23+
24+
# Todo:
25+
#second_cutoff = IDDates.objects.get(date_id=2)
26+
#ietf_monday = IDDates.objects.get(date_id=3)
27+
#freeze_delta = ietf_monday - second_cutoff
28+
29+
for draft in matches:
30+
if not draft.can_expire():
31+
# debugging
32+
#print "%s can't expire, skipping" % draft
33+
continue
34+
expiration = draft.expiration()
35+
# # The I-D expiration job doesn't run while submissions are frozen.
36+
# if ietf_monday > expiration > second_cutoff:
37+
# expiration += freeze_delta
38+
authors = draft.authors.all()
39+
to_addrs = [author.email() for author in authors if author.email()]
40+
cc_addrs = None
41+
if draft.group.acronym != 'none':
42+
cc_addrs = [chair.person.email() for chair in WGChair.objects.filter(group_acronym=draft.group)]
43+
44+
#For development debugging
45+
"""
46+
print "filename: "+draft.filename
47+
print "to: ", to_addrs
48+
print "cc: ", cc_addrs
49+
print "expires: ", expiration
50+
print "status: ", draft.status.status, "/", draft.idstate()
51+
print
52+
continue
53+
"""
54+
55+
send_mail_subj(None, to_addrs, None, 'notify_expirations/subject.txt', 'notify_expirations/body.txt',
56+
{
57+
'draft':draft,
58+
'expiration':expiration,
59+
},
60+
cc_addrs)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The following draft will expire soon:
2+
3+
Filename: {{draft.filename}}
4+
Title: {{draft.title}}
5+
State: {{draft.idstate}}
6+
Expires: {{expiration}} (in {{expiration|timeuntil}})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Expiration impending: {{draft.filename}}

ietf/utils/mail.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from django.conf import settings
99
from django.core.exceptions import ImproperlyConfigured
1010
from django.template.loader import render_to_string
11-
from django.template import RequestContext
11+
from django.template import Context,RequestContext
1212
from ietf.utils import log
1313
import sys
1414
import time
@@ -95,12 +95,18 @@ def copy_email(msg, to, toUser=False):
9595
new['To'] = to
9696
send_smtp(new)
9797

98+
def mail_context(request):
99+
if request:
100+
return RequestContext(request)
101+
else:
102+
return Context()
103+
98104
def send_mail_subj(request, to, frm, stemplate, template, context, *args, **kwargs):
99105
'''
100106
Send an email message, exactly as send_mail(), but the
101107
subject field is a template.
102108
'''
103-
subject = render_to_string(stemplate, context, context_instance=RequestContext(request)).replace("\n"," ").strip()
109+
subject = render_to_string(stemplate, context, context_instance=mail_context(request)).replace("\n"," ").strip()
104110
return send_mail(request, to, frm, subject, template, context, *args, **kwargs)
105111

106112
def send_mail(request, to, frm, subject, template, context, *args, **kwargs):
@@ -110,7 +116,7 @@ def send_mail(request, to, frm, subject, template, context, *args, **kwargs):
110116
The body is a text/plain rendering of the template with the context.
111117
extra is a dict of extra headers to add.
112118
'''
113-
txt = render_to_string(template, context, context_instance=RequestContext(request))
119+
txt = render_to_string(template, context, context_instance=mail_context(request))
114120
return send_mail_text(request, to, frm, subject, txt, *args, **kwargs)
115121

116122
def send_mail_text(request, to, frm, subject, txt, cc=None, extra=None, toUser=None, bcc=None):

0 commit comments

Comments
 (0)