From 594684a1859550fa3408c1ab8b1458db4dfba8a9 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Mon, 27 Oct 2014 18:20:35 +0000 Subject: [PATCH] Fixed a problem with the fill_in_shepherd_email migration, even if it has been run (and things cleaned up), just in case it might be needed or viewed as a pattern later. - Legacy-Id: 8503 --- .../migrations/0022_fill_in_shepherd_email.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ietf/doc/migrations/0022_fill_in_shepherd_email.py b/ietf/doc/migrations/0022_fill_in_shepherd_email.py index 7fab47855..48c5733dd 100644 --- a/ietf/doc/migrations/0022_fill_in_shepherd_email.py +++ b/ietf/doc/migrations/0022_fill_in_shepherd_email.py @@ -1,5 +1,6 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- from south.v2 import DataMigration +import debug class Migration(DataMigration): @@ -9,14 +10,16 @@ class Migration(DataMigration): shepherds.update(orm.DocHistory.objects.values_list("shepherd", flat=True).distinct()) for person_id in shepherds: - emails = orm['person.Email'].objects.filter(person=person_id).order_by("-active", "-time")[:1] - if not emails: - print "ERROR: no emails for", person_id + if not person_id is None: + emails = orm['person.Email'].objects.filter(person=person_id).order_by("-active", "-time")[:1] + if not emails: + print "ERROR: no emails for", person_id + continue + + email = emails[0] - email = emails[0] - - orm.Document.objects.filter(shepherd=person_id, shepherd_email=None).update(shepherd_email=email) - orm.DocHistory.objects.filter(shepherd=person_id, shepherd_email=None).update(shepherd_email=email) + orm.Document.objects.filter(shepherd=person_id, shepherd_email=None).update(shepherd_email=email) + orm.DocHistory.objects.filter(shepherd=person_id, shepherd_email=None).update(shepherd_email=email) def backwards(self, orm): pass