-
Notifications
You must be signed in to change notification settings - Fork 25
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
Refactor ValidatedSoftwareLCM and the software helper logic. #32
Conversation
…ed. Other minor improvements.
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.
Great work @progala
from .tables import ValidatedSoftwareLCMTable | ||
|
||
|
||
class ItemSoftware: |
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.
Would it make sense to convert get_validated_software_qs
into a queryset class for ValidatedSoftwareLCM
This would allow us to have something like that
device = Device.objects.get(XXX)
validated_software = ValidatedSoftwareLCM.objects.get_for_model(device)
it's easier than it look to implement
We just need to create a new class
class ValidatedSoftwareLCMQuerySet(RestrictedQuerySet):
"""Queryset for `ValidatedSoftwareLCM` objects."""
def get_for_object(self, obj):
"""
Return all `ValidatedSoftwareLCM` assigned to the given object.
"""
if obj is of type Device:
do this
else:
do that
[..]
class ValidatedSoftwareLCM([..]):
objects = ValidatedSoftwareLCMQuerySet.as_manager()
Here is an example https://github.com/nautobot/nautobot/pull/1047/files#diff-01ee6b16cefc4c5378473d290760c32b2507d31249d3df90972f4dca6a93d33aR16
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 made an attempt at implementing that and moved a few things around. Seems to work well.
@dgarros @josh5276 @jvanderaa Could you please review and we could hopefully merge it soon.
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.
LGTM, great work @progala
Note This PR introduces schema changes.
Refactored the
ValidatedSoftwareLCM
model and filters, forms etc. that reference it.Moved helper functions for working with
SoftwareLCM
andValidatedSoftwareLCM
objects tosoftware
module.List of changes:
ValidatedSoftwareLCM
now allows assignment to multiple objects.ValidatedSoftwareLCM
can now be assigned to:ValidatedSoftwareLCM
SoftwareLCM
andValidatedSoftwareLCM
related objects.valid
filter toValidatedSoftwareLCMFilterSet
SoftwareLCM
objects.ValidatedSoftwareLCM
content template for theDeviceType
.ValidatedSoftwareLCM
can now return queryset tailored to a given object withget_for_object
.