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
This commit is contained in:
parent
e3077c6e50
commit
594684a185
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue