From f1ad6a0e8e1afc039fe632b5e05adfa3ac217b7f Mon Sep 17 00:00:00 2001
From: Henrik Levkowetz <henrik@levkowetz.com>
Date: Wed, 17 Aug 2016 21:45:57 +0000
Subject: [PATCH] Merged in [11779] from rjsparks@nostrum.com:

    Robustness improvements for the bluesheet migrations.
 - Legacy-Id: 11814
Note: SVN reference [11779] has been migrated to Git commit 54a774caef8eb00f1d412dba658aaa9a91be3bb8
---
 .../0032_reconstruct_bluesheet_docs_95through96.py   | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/ietf/meeting/migrations/0032_reconstruct_bluesheet_docs_95through96.py b/ietf/meeting/migrations/0032_reconstruct_bluesheet_docs_95through96.py
index 74e8069a5..808280324 100644
--- a/ietf/meeting/migrations/0032_reconstruct_bluesheet_docs_95through96.py
+++ b/ietf/meeting/migrations/0032_reconstruct_bluesheet_docs_95through96.py
@@ -3,6 +3,8 @@ from __future__ import unicode_literals
 
 import os
 
+import debug         # pyflakes:ignore
+
 from django.db import migrations
 from django.conf import settings
 
@@ -19,14 +21,20 @@ def forward(apps, schema_editor):
 
     active = State.objects.get(type_id='bluesheets',slug='active')
 
+    print
+    print "Attention: The following anomalies are expected:"
+    print "There are no bluesheets for nmlrg at IETF95 or for cellar at IETF96."
+    print "At IETF95, netmod and opsec have a different number of bluesheets than sessions."
+    print "Please report any other warnings issued during the production migration to RjS."
+
     for num in [95, 96]:
         mtg = Meeting.objects.get(number=num)
         bs_path = '%s/bluesheets/'% os.path.join(settings.AGENDA_PATH,mtg.number)
         if not os.path.exists(bs_path):
             os.makedirs(bs_path)
         bs_files = os.listdir(bs_path)
-        bs_acronyms = set([x[14:-7] for x in bs_files])
-        group_acronyms = set([x.group.acronym for x in mtg.session_set.all() if official_time(x) and x.group.type_id in ['wg','rg','ag'] and not x.agenda_note.lower().startswith('cancel')])
+        bs_acronyms = set([x[14:].split('-')[0] for x in bs_files])
+        group_acronyms = set([x.group.acronym for x in mtg.session_set.filter(status_id='sched') if official_time(x) and x.group.type_id in ['wg','rg','ag'] and not x.agenda_note.lower().startswith('cancel')])
 
         if  bs_acronyms-group_acronyms:
             print "Warning IETF%s : groups that have bluesheets but did not appear to meet: %s"%(num,list(bs_acronyms-group_acronyms))