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

Update user migration to not bomb out when a UserResource already exists for a user

This commit is contained in:
Akita Noek 2016-03-01 09:54:35 -05:00
parent 73dc061716
commit 41c06dc2d0

View File

@ -5,10 +5,9 @@ def migrate_users(apps, schema_editor):
migrations = list()
User = apps.get_model('auth', "User")
Role = apps.get_model('main', "Role")
UserResource = apps.get_model('main', "UserResource")
for user in User.objects.all():
ur = UserResource.objects.create(user=user)
ur = user.resource # implicitly creates the UserResource field if it didn't already exist
ur.admin_role.members.add(user)
if user.is_superuser: