-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fixes #17954 - Handle CircuitTerminations in Cable Bulk Import #17995
base: develop
Are you sure you want to change the base?
Fixes #17954 - Handle CircuitTerminations in Cable Bulk Import #17995
Conversation
48b1c7b
to
2721455
Compare
termination_object = model.objects.get(device=device, name=name) | ||
|
||
# Should never happen as we return None above if we don't have a device or circuit | ||
assert device or circuit |
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.
One of the things we came up to in another PR, is asserts are not a guaranteed thing since it requires python to be compiled with debug=true.
I am actually going to defer to Jeremy on whether we want to stick with asserts or not.
queryset=Circuit.objects.all(), | ||
to_field_name='cid', | ||
required=False, | ||
conditional=True, |
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.
See comment re: conditional below
@@ -1189,8 +1200,18 @@ class CableImportForm(NetBoxModelImportForm): | |||
label=_('Side B device'), | |||
queryset=Device.objects.all(), | |||
to_field_name='name', | |||
required=False, | |||
conditional=True, |
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.
See comment re: conditional below
queryset=Circuit.objects.all(), | ||
to_field_name='cid', | ||
required=False, | ||
conditional=True, |
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.
See comment re: conditional below
@@ -1171,8 +1172,18 @@ class CableImportForm(NetBoxModelImportForm): | |||
label=_('Side A device'), | |||
queryset=Device.objects.all(), | |||
to_field_name='name', | |||
required=False, | |||
conditional=True, |
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.
See comment re: conditional below
{% elif field.conditional %} | ||
<span class="badge bg-yellow text-yellow-fg" >{% trans "Conditional" %}</span> |
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.
See comment re: conditional below
def __init__(self, conditional=False, *args, **kwargs): | ||
# Used to display tags for fields that are conditionally required | ||
self.conditional = conditional | ||
super().__init__(*args, **kwargs) | ||
|
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.
I am not myself prepared to make a decision on whether this is something we should consider introducing.
That said, I think that if this is something we want to persue further, there should be a FR for it and a related PR as I am sure there is more then just this.
For example, it marks it as a conditionally required value but do we want to enrich that further by telling the end-user which fields are part of this conditional group?
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.
Thank you for your input. I did consider enriching the frontend to indicate which fields are part of the conditional group when adding the conditional
attribute. However, I felt that this might be out of scope for this particular issue. The main goal here was to provide a way to mark those fields as conditionally required in the frontend. without altering much of the existing functionality.
I'm open to exploring further enhancements to improve user guidance on conditional fields, possibly in a separate feature request if needed.
As mentioned in the comments on #17954, this limitation also impacts power feeds. IMO we should solve for both circuit terminations and power feeds here. Instead of introducing additional fields, I'll suggest rename |
I did not tackle the other one as I wanted a consensus on the methodology first. I don't mind fixing both the same way.
Do you suggest that we design a replacement for |
Fixes: #17954
Add Support for Bulk Importing Cables Connected to Circuits
This pull request enhances the bulk import functionality for cables by allowing users to specify circuits as termination points on either side of a cable. Previously, only devices could be specified for cable terminations during bulk import which didn't allow for Cables to be connected to Circuit Terminations properly.
Key Changes:
Added Fields for Circuit Terminations:
side_a_circuit
andside_b_circuit
fields in theCableImportForm
withindcim/forms/bulk_import.py
.cid
) as a termination point.Updated CableImportForm Validation Logic:
_clean_side
method inCableImportForm
to handle cases where a circuit is specified instead of a device.Enhanced Bulk Import Template:
bulk_import.html
to display a "Conditional" tag for fields that are conditionally required, improving user experience during the import process.Extended CSV Field Functionality:
CSVModelChoiceField
inutilities/forms/fields/csv.py
to accept aconditional
parameter.Benefits:
Usage Notes: