Skip to content

Fixes #19800: ModuleType import supports associating ModuleTypeProfile #19803

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jnovinger
Copy link
Member

Fixes: #19800

  • Fixes issue by adding profile to the list of fields the import form should recognize
  • Fixes up module type bulk import testing by adding necessary permissions for related models and adding inheritance of BulkImportObjectsViewTestCase
  • Adds an additional regression assertion to make sure that this fix does not regress

@jnovinger jnovinger requested review from a team and jeremystretch and removed request for a team July 2, 2025 12:51
InterfaceTemplate, FrontPortTemplate, RearPortTemplate, ModuleBayTemplate,
]
for model in additional_permissions:
obj_perm.object_types.add(ObjectType.objects.get_for_model(model))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to suggestions on this approach.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an add_permissions() method on the test case to facilitate this; will that work?

InterfaceTemplate, FrontPortTemplate, RearPortTemplate, ModuleBayTemplate,
]
for model in additional_permissions:
obj_perm.object_types.add(ObjectType.objects.get_for_model(model))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an add_permissions() method on the test case to facilitate this; will that work?

fan_module_type = ModuleType.objects.get(part_number='generic-fan')
fan_module_type_profile = ModuleTypeProfile.objects.get(name='Fan')

assert fan_module_type.profile == fan_module_type_profile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed. The test should be checking that each declared field was set to the correct value on import.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy, will verify. My memory was that it was just checking object count relative to pre-test.

@@ -471,7 +471,7 @@ class Meta:
model = ModuleType
fields = [
'manufacturer', 'model', 'part_number', 'description', 'airflow', 'weight', 'weight_unit', 'comments',
'tags',
'tags', 'profile',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move profile before comments in the list? It affects the ordering of the fields in the import form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Module type import does not assign profile
2 participants