Skip to content

Conversation

@mathieued
Copy link

@mathieued mathieued commented Mar 18, 2025

Closes #85 to extend the Support Contract Assignment feature to Modules.

Please note that, as License Assignments are available only for Devices, I've made the assumption that if a Module is selected/assigned in a Support Contract Assignment, neither a Device nor a License Assignment can be selected/assigned to the same one.

Let me know if you agree with that assumption, I can update if you don't.

@mathieued
Copy link
Author

Hello !

@DanSheps or any of the allowed reviewers, is there any chance to have the awaiting PRs reviewed soon ?

Just asking to anticipate. Thanks, and have a good day!

if self.device and self.license and SupportContractAssignment.objects.filter(
if self.module:
if self.license or self.device:
raise ValidationError('Assigning a Module excludes the assigment of a Device or License')
Copy link
Owner

Choose a reason for hiding this comment

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

I don't know if I agree with this. I think selecting a device or license (or both) would be valid depending on the circumstances.

A module is always going to be in a device, and when removing from a device in NetBox it is deleted.

I think a more reasonable check would be to ensure that this is unique across all 3 fields.

In addition, you would want to add unique checks for:

device, module where license is None
module, license where device is None (or just require a device when saving a module)

Comment on lines +112 to +117
if self.cleaned_data.get('module'):
if self.cleaned_data.get('license') or self.cleaned_data.get('device'):
raise forms.ValidationError({
'module': 'Selecting a Module excludes the selection of a Device or License'
})

Copy link
Owner

Choose a reason for hiding this comment

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

See comment in the model and adjust accordingly

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.

Extend Support Contract Assignment to Modules

2 participants