From 942efacb080251018f1d514884940d72fb3edb4a Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Tue, 23 Jul 2013 22:28:19 +0000 Subject: [PATCH] Added a guard to prevent duplicate RFC-Editor notifications for approved documents, and added logging to the notification routine. - Legacy-Id: 5852 --- ietf/idrfc/views_ballot.py | 6 +++--- ietf/sync/rfceditor.py | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ietf/idrfc/views_ballot.py b/ietf/idrfc/views_ballot.py index 3dfefe5b8..a6258da5f 100644 --- a/ietf/idrfc/views_ballot.py +++ b/ietf/idrfc/views_ballot.py @@ -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() diff --git a/ietf/sync/rfceditor.py b/ietf/sync/rfceditor.py index 8bb29eb5f..ff894dc7d 100644 --- a/ietf/sync/rfceditor.py +++ b/ietf/sync/rfceditor.py @@ -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