Skip to content

Commit 53b1719

Browse files
committed
Merged [5645],[5646] and [5647] from olau@iola.dk:
Added support for notifying the RFC Editor upon draft approval Added action to post to RFC Editor on non-IESG publication requests too Fixed a bug that the CC on the announcement copy sent to IANA wasn't cleared causing people on the CC to get duplicate emails - Legacy-Id: 5680
1 parent 2310348 commit 53b1719

7 files changed

Lines changed: 94 additions & 7 deletions

File tree

ietf/idrfc/testsREDESIGN.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,13 +882,13 @@ def test_approve_ballot(self):
882882
r = self.client.get(url)
883883
self.assertEquals(r.status_code, 200)
884884
q = PyQuery(r.content)
885-
self.assertTrue("Send out the announcement" in q('.actions input[type=submit]')[0].get('value'))
885+
self.assertTrue("send out the announcement" in q('.actions input[type=submit]')[0].get('value').lower())
886886
self.assertEquals(len(q('.announcement pre:contains("Subject: Protocol Action")')), 1)
887887

888888
# approve
889889
mailbox_before = len(outbox)
890890

891-
r = self.client.post(url, dict())
891+
r = self.client.post(url, dict(skiprfceditorpost="1"))
892892
self.assertEquals(r.status_code, 302)
893893

894894
draft = Document.objects.get(name=draft.name)
@@ -897,6 +897,7 @@ def test_approve_ballot(self):
897897
self.assertTrue("Protocol Action" in outbox[-2]['Subject'])
898898
# the IANA copy
899899
self.assertTrue("Protocol Action" in outbox[-1]['Subject'])
900+
self.assertTrue(not outbox[-1]['CC'])
900901
self.assertTrue("Protocol Action" in draft.message_set.order_by("-time")[0].subject)
901902

902903
def test_disapprove_ballot(self):
@@ -981,7 +982,7 @@ def test_request_publication(self):
981982
# approve
982983
mailbox_before = len(outbox)
983984

984-
r = self.client.post(url, dict(subject=subject, body=body))
985+
r = self.client.post(url, dict(subject=subject, body=body, skiprfceditorpost="1"))
985986
self.assertEquals(r.status_code, 302)
986987

987988
draft = Document.objects.get(name=draft.name)
@@ -991,6 +992,7 @@ def test_request_publication(self):
991992
self.assertTrue("Document Action" in draft.message_set.order_by("-time")[0].subject)
992993
# the IANA copy
993994
self.assertTrue("Document Action" in outbox[-1]['Subject'])
995+
self.assertTrue(not outbox[-1]['CC'])
994996

995997
class ExpireIDsTestCase(django.test.TestCase):
996998
fixtures = ['names']

ietf/idrfc/views_ballot.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ def approve_ballotREDESIGN(request, name):
10081008
# NOTE: according to Michelle Cotton <michelle.cotton@icann.org>
10091009
# (as per 2011-10-24) IANA is scraping these messages for
10101010
# information so would like to know beforehand if the format
1011-
# changes (perhaps RFC 6359 will change that)
1011+
# changes
10121012
announcement = approval_text + "\n\n" + ballot_writeup
10131013

10141014
if request.method == 'POST':
@@ -1017,6 +1017,17 @@ def approve_ballotREDESIGN(request, name):
10171017
else:
10181018
new_state = State.objects.get(used=True, type="draft-iesg", slug="ann")
10191019

1020+
if new_state.slug == "ann" and not request.REQUEST.get("skiprfceditorpost"):
1021+
# start by notifying the RFC Editor
1022+
import ietf.sync.rfceditor
1023+
response, error = ietf.sync.rfceditor.post_approved_draft(ietf.sync.rfceditor.POST_APPROVED_DRAFT_URL, doc.name)
1024+
if error:
1025+
return render_to_response('doc/rfceditor_post_approved_draft_failed.html',
1026+
dict(name=doc.name,
1027+
response=response,
1028+
error=error),
1029+
context_instance=RequestContext(request))
1030+
10201031
# fixup document
10211032
close_open_ballots(doc, login)
10221033

@@ -1064,7 +1075,7 @@ def approve_ballotREDESIGN(request, name):
10641075
msg.related_docs.add(doc)
10651076

10661077
return HttpResponseRedirect(doc.get_absolute_url())
1067-
1078+
10681079
return render_to_response('idrfc/approve_ballot.html',
10691080
dict(doc=doc,
10701081
action=action,

ietf/idrfc/views_edit.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,17 @@ def request_publication(request, name):
10881088
if request.method == 'POST' and not request.POST.get("reset"):
10891089
form = PublicationForm(request.POST)
10901090
if form.is_valid():
1091+
if not request.REQUEST.get("skiprfceditorpost"):
1092+
# start by notifying the RFC Editor
1093+
import ietf.sync.rfceditor
1094+
response, error = ietf.sync.rfceditor.post_approved_draft(ietf.sync.rfceditor.POST_APPROVED_DRAFT_URL, doc.name)
1095+
if error:
1096+
return render_to_response('doc/rfceditor_post_approved_draft_failed.html',
1097+
dict(name=doc.name,
1098+
response=response,
1099+
error=error),
1100+
context_instance=RequestContext(request))
1101+
10911102
m.subject = form.cleaned_data["subject"]
10921103
m.body = form.cleaned_data["body"]
10931104
m.save()

ietf/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@
277277
IANA_SYNC_CHANGES_URL = "https://datatracker.iana.org:4443/data-tracker/changes"
278278
IANA_SYNC_PROTOCOLS_URL = "http://www.iana.org/protocols/"
279279

280+
RFC_EDITOR_SYNC_PASSWORD="secret"
281+
280282
# Liaison Statement Tool settings
281283
LIAISON_UNIVERSAL_FROM = 'Liaison Statement Management Tool <lsmt@' + IETF_DOMAIN + '>'
282284
LIAISON_ATTACH_PATH = '/a/www/ietf-datatracker/documents/LIAISON/'

ietf/sync/rfceditor.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import re, urllib2, json, email, socket
1+
import re, urllib, urllib2, json, email, socket, base64
22
from xml.dom import pulldom, Node
33

44
from django.utils.http import urlquote
@@ -12,6 +12,7 @@
1212

1313
QUEUE_URL = "http://www.rfc-editor.org/queue2.xml"
1414
INDEX_URL = "http://www.rfc-editor.org/rfc/rfc-index.xml"
15+
POST_APPROVED_DRAFT_URL = "https://www.rfc-editor.org/sdev/jsonexp/jsonparser.php"
1516

1617
MIN_QUEUE_RESULTS = 10
1718
MIN_INDEX_RESULTS = 5000
@@ -445,3 +446,37 @@ def parse_relation_list(l):
445446
doc.save()
446447

447448
return results
449+
450+
451+
def post_approved_draft(url, name):
452+
"""Post an approved draft to the RFC Editor so they can retrieve
453+
the data from the Datatracker and start processing it. Returns
454+
response and error (empty string if no error)."""
455+
456+
request = urllib2.Request(url)
457+
request.add_header("Content-type", "application/x-www-form-urlencoded")
458+
request.add_header("Accept", "text/plain")
459+
# HTTP basic auth
460+
username = "dtracksync"
461+
password = settings.RFC_EDITOR_SYNC_PASSWORD
462+
request.add_header("Authorization", "Basic %s" % base64.encodestring("%s:%s" % (username, password)).replace("\n", ""))
463+
464+
text = error = ""
465+
try:
466+
f = urllib2.urlopen(request, data=urllib.urlencode({ 'approved_draft_name': name }), timeout=20)
467+
text = f.read()
468+
status_code = f.getcode()
469+
f.close()
470+
471+
if status_code != 200:
472+
raise Exception("Status code is not 200 OK (it's %s)." % status_code)
473+
474+
if text != "OK":
475+
raise Exception("Response is not \"OK\".")
476+
477+
except Exception as e:
478+
# catch everything so we don't leak exceptions, convert them
479+
# into string instead
480+
error = unicode(e)
481+
482+
return text, error
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{# Copyright The IETF Trust 2007, All Rights Reserved #}
2+
{% extends "base.html" %}
3+
4+
{% block title %}Posting Approved Draft to RFC Editor Failed{% endblock %}
5+
6+
{% block content %}
7+
<h1>Posting Approved Draft to RFC Editor Failed</h1>
8+
9+
<p>Sorry, when trying to notify the RFC Editor through HTTP, we hit an
10+
error.</p>
11+
12+
<p>We have not changed the draft state or sent the announcement
13+
yet so if this is an intermittent error, you can go back and try
14+
again.</p>
15+
16+
<p>The error was:</p>
17+
18+
<p><code>{{ error }}</code></p>
19+
20+
{% if response %}
21+
<p>The response from the RFC Editor was:</p>
22+
23+
<p><code>{{ response|linebreaksbr }}</code></p>
24+
{% endif %}
25+
26+
{% endblock %}

ietf/templates/idrfc/approve_ballot.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h1>Approve Ballot for {{ doc }}</h1>
3232
<div class="actions">
3333
<a href="{% url doc_ballot_approvaltext name=doc.name %}">Back</a>
3434
{% ifequal action "to_announcement_list" %}
35-
<input type="submit" value="Send out the announcement and close ballot"/>
35+
<input type="submit" value="Notify the RFC Editor, send out the announcement and close ballot"/>
3636
{% endifequal %}
3737
{% ifequal action "to_rfc_editor" %}
3838
<input type="submit" value="Send message to the RFC Editor and close ballot"/>

0 commit comments

Comments
 (0)