-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ObjectPermission Data Migration from Region/Site to Location #3418
Conversation
@@ -299,6 +299,7 @@ def reassign_model_instances_to_locations(apps, model): | |||
Location = apps.get_model("dcim", "location") | |||
LocationType = apps.get_model("dcim", "locationtype") | |||
location_ct = ContentType.objects.get_for_model(Location) | |||
location_type_ct = ContentType.objects.get_for_model(LocationType) | |||
model_class = apps.get_model("dcim", f"{model}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick inc
model_class = apps.get_model("dcim", f"{model}") | |
model_class = apps.get_model("dcim", model) |
region_permissions = self.object_permission.objects.filter( | ||
name__in=["Test Region Permission 1", "Test Region Permission 2"] | ||
) | ||
self.assertEqual( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could make this more concise by using assertCountEqual and dropping sorted
. Not blocking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I do want to check the actual content of the many-to-many field just to make sure it is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertCountEqual
does check that the content of the iterables matches it just ignores the sort order. I don't know why they named it assertCountEqual
Closes: #
What's Changed
Location
/LocationType
ContentType
toobject_types
field of existingRegion
andSite
ObjectPermissions
TODO