Added a guard to prevent duplicate RFC-Editor notifications for approved documents, and added logging to the notification routine.

- Legacy-Id: 5852
This commit is contained in:
Henrik Levkowetz 2013-07-23 22:28:19 +00:00
parent 3cb184ec12
commit 942efacb08
2 changed files with 7 additions and 3 deletions

View file

@ -1016,7 +1016,8 @@ def approve_ballotREDESIGN(request, name):
else:
new_state = State.objects.get(used=True, type="draft-iesg", slug="ann")
if new_state.slug == "ann" and not request.REQUEST.get("skiprfceditorpost"):
prev_state = doc.get_state("draft-iesg")
if new_state.slug == "ann" and new_state.slug != prev_state.slug and not request.REQUEST.get("skiprfceditorpost"):
# start by notifying the RFC Editor
import ietf.sync.rfceditor
response, error = ietf.sync.rfceditor.post_approved_draft(settings.RFC_EDITOR_SYNC_NOTIFICATION_URL, doc.name)
@ -1032,7 +1033,6 @@ def approve_ballotREDESIGN(request, name):
save_document_in_history(doc)
prev = doc.get_state("draft-iesg")
doc.set_state(new_state)
prev_tag = doc.tags.filter(slug__in=IESG_SUBSTATE_TAGS)
@ -1052,7 +1052,7 @@ def approve_ballotREDESIGN(request, name):
change_description = e.desc + " and state has been changed to %s" % doc.get_state("draft-iesg").name
e = idrfcutil_log_state_changed(request, doc, login, prev, prev_tag)
e = idrfcutil_log_state_changed(request, doc, login, prev_state, prev_tag)
doc.time = e.time
doc.save()

View file

@ -4,6 +4,7 @@ from xml.dom import pulldom, Node
from django.utils.http import urlquote
from ietf.utils.mail import send_mail_text
from ietf.utils import log
from ietf.doc.models import *
from ietf.person.models import *
@ -477,12 +478,14 @@ def post_approved_draft(url, name):
if settings.SERVER_MODE != "production":
return ("OK", "")
log("Posting RFC-Editor notifcation of approved draft '%s' to '%s'" % (name, url))
text = error = ""
try:
f = urllib2.urlopen(request, data=urllib.urlencode({ 'draft': name }), timeout=20)
text = f.read()
status_code = f.getcode()
f.close()
log("RFC-Editor notification result for draft '%s': %s:'%s'" % (name, status_code, text))
if status_code != 200:
raise Exception("Status code is not 200 OK (it's %s)." % status_code)
@ -493,6 +496,7 @@ def post_approved_draft(url, name):
except Exception as e:
# catch everything so we don't leak exceptions, convert them
# into string instead
log("Exception on RFC-Editor notification for draft '%s': '%s'" % (name, e))
error = unicode(e)
return text, error