Skip to content

Commit d0f3b5e

Browse files
committed
Port change_state view + helpers + tests to new schema, retaining the old view via settings; adjusted relationship model to use source/target as attribute names
- Legacy-Id: 2808
1 parent 294740d commit d0f3b5e

19 files changed

Lines changed: 2363 additions & 75 deletions

ietf/idrfc/fixtures/names.xml

Lines changed: 414 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/python
2+
3+
# boiler plate
4+
import os, sys
5+
6+
one_dir_up = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../'))
7+
8+
sys.path.insert(0, one_dir_up)
9+
10+
from django.core.management import setup_environ
11+
import settings
12+
setup_environ(settings)
13+
14+
# script
15+
from django.core.serializers import serialize
16+
from django.db.models import Q
17+
18+
def output(name, qs):
19+
try:
20+
f = open(os.path.join(settings.BASE_DIR, "idrfc/fixtures/%s.xml" % name), 'w')
21+
f.write(serialize("xml", qs, indent=4))
22+
f.close()
23+
except:
24+
from django.db import connection
25+
from pprint import pprint
26+
pprint(connection.queries)
27+
raise
28+
29+
# pick all name models directly out of the module
30+
names = []
31+
32+
import name.models
33+
for n in dir(name.models):
34+
if n[:1].upper() == n[:1] and n.endswith("Name"):
35+
model = getattr(name.models, n)
36+
if not model._meta.abstract:
37+
names.extend(model.objects.all())
38+
39+
output("names", names)
40+

ietf/idrfc/lastcall.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import datetime
44

5+
from django.conf import settings
6+
57
from ietf.idtracker.models import InternetDraft, DocumentComment, BallotInfo, IESGLogin
68
from ietf.idrfc.mails import *
79
from ietf.idrfc.utils import *
10+
from doc.models import Event
811

912
def request_last_call(request, doc):
1013
try:
@@ -15,6 +18,26 @@ def request_last_call(request, doc):
1518
send_last_call_request(request, doc, ballot)
1619
add_document_comment(request, doc, "Last Call was requested")
1720

21+
def request_last_callREDESIGN(request, doc):
22+
if not doc.latest_event(type="changed_ballot_writeup_text"):
23+
generate_ballot_writeup(request, doc)
24+
if not doc.latest_event(type="changed_ballot_approval_text"):
25+
generate_approval_mail(request, doc)
26+
if not doc.latest_event(type="changed_last_call_text"):
27+
generate_last_call_announcement(request, doc)
28+
29+
send_last_call_request(request, doc)
30+
31+
e = Event()
32+
e.type = "requested_last_call"
33+
e.by = request.user.get_profile().email()
34+
e.doc = doc
35+
e.desc = "Last call was requested by %s" % e.by.get_name()
36+
e.save()
37+
38+
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
39+
request_last_call = request_last_callREDESIGN
40+
1841
def get_expired_last_calls():
1942
return InternetDraft.objects.filter(lc_expiration_date__lte=datetime.date.today(),
2043
idinternal__cur_state__document_state_id=IDState.IN_LAST_CALL)

ietf/idrfc/mails.py

Lines changed: 185 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
from ietf.utils.mail import send_mail, send_mail_text
1111
from ietf.idtracker.models import *
12+
from doc.models import Text
13+
from person.models import Email
1214

1315
def email_state_changed(request, doc, text):
1416
to = [x.strip() for x in doc.idinternal.state_change_notice_to.replace(';', ',').split(',')]
@@ -18,6 +20,17 @@ def email_state_changed(request, doc, text):
1820
dict(text=text,
1921
url=settings.IDTRACKER_BASE_URL + doc.idinternal.get_absolute_url()))
2022

23+
def email_state_changedREDESIGN(request, doc, text):
24+
to = [x.strip() for x in doc.notify.replace(';', ',').split(',')]
25+
send_mail(request, to, None,
26+
"ID Tracker State Update Notice: %s" % doc.file_tag(),
27+
"idrfc/state_changed_email.txt",
28+
dict(text=text,
29+
url=settings.IDTRACKER_BASE_URL + doc.get_absolute_url()))
30+
31+
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
32+
email_state_changed = email_state_changedREDESIGN
33+
2134
def html_to_text(html):
2235
return strip_tags(html.replace("&lt;", "<").replace("&gt;", ">").replace("&amp;", "&").replace("<br>", "\n"))
2336

@@ -34,6 +47,23 @@ def email_owner(request, doc, owner, changed_by, text, subject=None):
3447
doc=doc,
3548
url=settings.IDTRACKER_BASE_URL + doc.idinternal.get_absolute_url()))
3649

50+
def email_ownerREDESIGN(request, doc, owner, changed_by, text, subject=None):
51+
if not owner or not changed_by or owner == changed_by:
52+
return
53+
54+
to = owner.formatted_email()
55+
send_mail(request, to,
56+
"DraftTracker Mail System <iesg-secretary@ietf.org>",
57+
"%s updated by %s" % (doc.file_tag(), changed_by),
58+
"idrfc/change_notice.txt",
59+
dict(text=html_to_text(text),
60+
doc=doc,
61+
url=settings.IDTRACKER_BASE_URL + doc.get_absolute_url()))
62+
63+
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
64+
email_owner = email_ownerREDESIGN
65+
66+
3767
def full_intended_status(intended_status):
3868
s = str(intended_status)
3969
# FIXME: this should perhaps be defined in the db
@@ -54,6 +84,15 @@ def full_intended_status(intended_status):
5484
else:
5585
return "a %s" % s
5686

87+
def generate_ballot_writeup(request, doc):
88+
e = Text()
89+
e.type = "changed_ballot_writeup_text"
90+
e.by = request.user.get_profile().email()
91+
e.doc = doc
92+
e.desc = u"Ballot writeup was generated by %s" % e.by.get_name()
93+
e.content = unicode(render_to_string("idrfc/ballot_writeup.txt"))
94+
e.save()
95+
5796
def generate_last_call_announcement(request, doc):
5897
status = full_intended_status(doc.intended_status).replace("a ", "").replace("an ", "")
5998

@@ -86,6 +125,49 @@ def generate_last_call_announcement(request, doc):
86125
)
87126
)
88127

128+
def generate_last_call_announcementREDESIGN(request, doc):
129+
doc.full_status = full_intended_status(doc.intended_std_level)
130+
status = doc.full_status.replace("a ", "").replace("an ", "")
131+
132+
expiration_date = date.today() + timedelta(days=14)
133+
cc = []
134+
if doc.group.type_id == "individ":
135+
group = "an individual submitter"
136+
expiration_date += timedelta(days=14)
137+
else:
138+
group = "the %s WG (%s)" % (doc.group.name, doc.group.acronym)
139+
if doc.group.list_email:
140+
cc.append(doc.group.list_email)
141+
142+
doc.filled_title = textwrap.fill(doc.title, width=70, subsequent_indent=" " * 3)
143+
url = settings.IDTRACKER_BASE_URL + doc.get_absolute_url()
144+
145+
mail = render_to_string("idrfc/last_call_announcement.txt",
146+
dict(doc=doc,
147+
doc_url=settings.IDTRACKER_BASE_URL + doc.get_absolute_url(),
148+
expiration_date=expiration_date.strftime("%Y-%m-%d"), #.strftime("%B %-d, %Y"),
149+
cc=", ".join("<%s>" % e for e in cc),
150+
group=group,
151+
docs=[doc],
152+
urls=[url],
153+
status=status,
154+
impl_report="Draft" in status or "Full" in status,
155+
)
156+
)
157+
158+
from doc.models import Text
159+
e = Text()
160+
e.type = "changed_last_call_text"
161+
e.by = request.user.get_profile().email()
162+
e.doc = doc
163+
e.desc = u"Last call announcement was generated by %s" % e.by.get_name()
164+
e.content = unicode(mail)
165+
e.save()
166+
167+
168+
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
169+
generate_last_call_announcement = generate_last_call_announcementREDESIGN
170+
89171
def generate_approval_mail(request, doc):
90172
if doc.idinternal.cur_state_id in IDState.DO_NOT_PUBLISH_STATES or doc.idinternal.via_rfc_editor:
91173
return generate_approval_mail_rfc_editor(request, doc)
@@ -114,7 +196,7 @@ def generate_approval_mail(request, doc):
114196
if len(docs) > 1:
115197
made_by = "These documents have been reviewed in the IETF but are not the products of an IETF Working Group."
116198
else:
117-
made_by = "This document has been reviewed in the IETF but is not the product of an IETF Working Group.";
199+
made_by = "This document has been reviewed in the IETF but is not the product of an IETF Working Group."
118200
else:
119201
if len(docs) > 1:
120202
made_by = "These documents are products of the %s." % doc.group.name_with_wg
@@ -159,6 +241,95 @@ def generate_approval_mail_rfc_editor(request, doc):
159241
)
160242
)
161243

244+
DO_NOT_PUBLISH_IESG_STATES = ("nopubadw", "nopubanw")
245+
246+
def generate_approval_mailREDESIGN(request, doc):
247+
if doc.iesg_state_id in DO_NOT_PUBLISH_IESG_STATES or doc.tags.filter(slug='via-rfc'):
248+
mail = generate_approval_mail_rfc_editor(request, doc)
249+
else:
250+
mail = generate_approval_mail_approved(request, doc)
251+
252+
from doc.models import Text
253+
e = Text()
254+
e.type = "changed_ballot_approval_text"
255+
e.by = request.user.get_profile().email()
256+
e.doc = doc
257+
e.desc = u"Ballot approval text was generated by %s" % e.by.get_name()
258+
e.content = unicode(mail)
259+
e.save()
260+
261+
def generate_approval_mail_approved(request, doc):
262+
doc.full_status = full_intended_status(doc.intended_std_level.name)
263+
status = doc.full_status.replace("a ", "").replace("an ", "")
264+
265+
if "an " in status:
266+
action_type = "Document"
267+
else:
268+
action_type = "Protocol"
269+
270+
cc = ["Internet Architecture Board <iab@iab.org>", "RFC Editor <rfc-editor@rfc-editor.org>"]
271+
272+
# the second check catches some area working groups (like
273+
# Transport Area Working Group)
274+
if doc.group.type_id != "area" and not doc.group.name.endswith("Working Group"):
275+
doc.group.name_with_wg = doc.group.name + " Working Group"
276+
if doc.group.list_email:
277+
cc.append("%s mailing list <%s>" % (doc.group.acronym, doc.group.list_email))
278+
cc.append("%s chair <%s-chairs@tools.ietf.org>" % (doc.group.acronym, doc.group.acronym))
279+
else:
280+
doc.group.name_with_wg = doc.group.name
281+
282+
doc.filled_title = textwrap.fill(doc.title, width=70, subsequent_indent=" " * 3)
283+
284+
if doc.group.type_id == "individ":
285+
made_by = "This document has been reviewed in the IETF but is not the product of an IETF Working Group."
286+
else:
287+
made_by = "This document is the product of the %s." % doc.group.name_with_wg
288+
289+
director = doc.ad
290+
other_director = Email.objects.filter(role__group__role__email=director, role__group__role__name="ad").exclude(pk=director.pk)
291+
292+
if doc.group.type_id != "individ" and other_director:
293+
contacts = "The IESG contact persons are %s and %s." % (director.get_name(), other_director[0].get_name())
294+
else:
295+
contacts = "The IESG contact person is %s." % director.get_name()
296+
297+
doc_type = "RFC" if doc.state_id == "rfc" else "Internet Draft"
298+
299+
return render_to_string("idrfc/approval_mail.txt",
300+
dict(doc=doc,
301+
docs=[doc],
302+
doc_url=settings.IDTRACKER_BASE_URL + doc.get_absolute_url(),
303+
cc=",\n ".join(cc),
304+
doc_type=doc_type,
305+
made_by=made_by,
306+
contacts=contacts,
307+
status=status,
308+
action_type=action_type,
309+
)
310+
)
311+
312+
def generate_approval_mail_rfc_editorREDESIGN(request, doc):
313+
full_status = full_intended_status(doc.intended_std_level.name)
314+
status = full_status.replace("a ", "").replace("an ", "")
315+
disapproved = doc.iesg_state in DO_NOT_PUBLISH_IESG_STATES
316+
doc_type = "RFC" if doc.state_id == "rfc" else "Internet Draft"
317+
318+
return render_to_string("idrfc/approval_mail_rfc_editor.txt",
319+
dict(doc=doc,
320+
doc_url=settings.IDTRACKER_BASE_URL + doc.idinternal.get_absolute_url(),
321+
doc_type=doc_type,
322+
status=status,
323+
full_status=full_status,
324+
disapproved=disapproved,
325+
)
326+
)
327+
328+
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
329+
generate_approval_mail = generate_approval_mailREDESIGN
330+
generate_approval_mail_rfc_editor = generate_approval_mail_rfc_editorREDESIGN
331+
332+
162333
def send_last_call_request(request, doc, ballot):
163334
to = "iesg-secretary@ietf.org"
164335
frm = '"DraftTracker Mail System" <iesg-secretary@ietf.org>'
@@ -170,6 +341,19 @@ def send_last_call_request(request, doc, ballot):
170341
dict(docs=docs,
171342
doc_url=settings.IDTRACKER_BASE_URL + doc.idinternal.get_absolute_url()))
172343

344+
def send_last_call_requestREDESIGN(request, doc):
345+
to = "iesg-secretary@ietf.org"
346+
frm = '"DraftTracker Mail System" <iesg-secretary@ietf.org>'
347+
348+
send_mail(request, to, frm,
349+
"Last Call: %s" % doc.file_tag(),
350+
"idrfc/last_call_request.txt",
351+
dict(docs=[doc],
352+
doc_url=settings.IDTRACKER_BASE_URL + doc.get_absolute_url()))
353+
354+
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
355+
send_last_call_request = send_last_call_requestREDESIGN
356+
173357
def email_resurrect_requested(request, doc, by):
174358
to = "I-D Administrator <internet-drafts@ietf.org>"
175359
frm = u"%s <%s>" % by.person.email()

ietf/idrfc/tests.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,3 +1277,5 @@ def testRfcEditorQueue(self):
12771277
self.assertEquals(len(refs), 3)
12781278
print "OK"
12791279

1280+
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
1281+
from testsREDESIGN import *

0 commit comments

Comments
 (0)