1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

Fix NameError/AttributeError in migration.

This commit is contained in:
Chris Church 2013-12-10 18:01:07 -05:00
parent 61059fa1a4
commit dfcedc42fe

View File

@ -3,6 +3,7 @@ from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
from django.core.exceptions import ObjectDoesNotExist
class Migration(DataMigration):
@ -14,7 +15,8 @@ class Migration(DataMigration):
if obj_type == 'orm.User':
obj_type = 'orm["auth.User"]'
obj1 = eval(obj_type + ".objects.get(id=" + str(activity_stream_object.object1_id) + ")")
getattr(activity_stream_object, activity_stream_object.object1).add(obj1)
if hasattr(activity_stream_object, activity_stream_object.object1):
getattr(activity_stream_object, activity_stream_object.object1).add(obj1)
except ObjectDoesNotExist, e:
print("Object 1 for AS id=%s does not exist. (Object Type: %s, id: %s" % (str(activity_stream_object.id),
activity_stream_object.object1_type,