-
Notifications
You must be signed in to change notification settings - Fork 33
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
Updating methods for custom field choices #115
Merged
joewesch
merged 7 commits into
nautobot:develop
from
nautics889:nautics-114-custom-field-choices
Jul 27, 2023
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
afedd94
fix: Update methods for custom fields (#114)
nautics889 8085e23
fix: Tests for methods for custom fields (#114)
nautics889 69ef638
fix: Fixtures for tests (custom fields) (#114)
nautics889 b09543a
fix: Failing test for getting custom fields (#114)
nautics889 e8b586c
refactor: Update docstrings and naming (#114)
nautics889 e5efc1a
fix: backward compatibility
nautics889 f401a23
refactor: update `custom_choices()` (#114)
nautics889 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
[ | ||
{ | ||
"id": "5b39ba88-e5ab-4be2-89f5-5a016473b53c", | ||
"display": "First option", | ||
"url": "http://localhost:8000/api/extras/custom-field-choices/5b39ba88-e5ab-4be2-89f5-5a016473b53c/", | ||
"field": { | ||
"display": "Test custom field 2", | ||
"id": "5b39ba88-e5ab-4be2-89f5-5a016473b53c", | ||
"url": "http://localhost:8000/api/extras/custom-fields/5b39ba88-e5ab-4be2-89f5-5a016473b53c/", | ||
"name": "test_custom_field_2" | ||
}, | ||
"value": "First option", | ||
"weight": 100, | ||
"created": "2023-04-15", | ||
"last_updated": "2023-04-15T18:11:57.163237Z" | ||
}, | ||
{ | ||
"id": "5b39ba88-e5ab-4be2-89f5-5a016473b53c", | ||
"display": "Second option", | ||
"url": "http://localhost:8000/api/extras/custom-field-choices/5b39ba88-e5ab-4be2-89f5-5a016473b53c/", | ||
"field": { | ||
"display": "Test custom field 2", | ||
"id": "5b39ba88-e5ab-4be2-89f5-5a016473b53c", | ||
"url": "http://localhost:8000/api/extras/custom-fields/5b39ba88-e5ab-4be2-89f5-5a016473b53c/", | ||
"name": "test_custom_field_2" | ||
}, | ||
"value": "Second option", | ||
"weight": 100, | ||
"created": "2023-04-15", | ||
"last_updated": "2023-04-15T18:11:57.169962Z" | ||
}, | ||
{ | ||
"id": "5b39ba88-e5ab-4be2-89f5-5a016473b53c", | ||
"display": "Third option", | ||
"url": "http://localhost:8000/api/extras/custom-field-choices/5b39ba88-e5ab-4be2-89f5-5a016473b53c/", | ||
"field": { | ||
"display": "Test custom field 2", | ||
"id": "5b39ba88-e5ab-4be2-89f5-5a016473b53c", | ||
"url": "http://localhost:8000/api/extras/custom-fields/5b39ba88-e5ab-4be2-89f5-5a016473b53c/", | ||
"name": "test_custom_field_2" | ||
}, | ||
"value": "Third option", | ||
"weight": 100, | ||
"created": "2023-04-15", | ||
"last_updated": "2023-04-15T18:11:57.174825Z" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
[ | ||
{ | ||
"id": "5b39ba88-e5ab-4be2-89f5-5a016473b53c", | ||
"display": "Test custom field", | ||
"url": "http://localhost:8000/api/extras/custom-fields/5b39ba88-e5ab-4be2-89f5-5a016473b53c/", | ||
"content_types": [ | ||
"dcim.rack" | ||
], | ||
"type": { | ||
"value": "integer", | ||
"label": "Integer" | ||
}, | ||
"label": "Test custom field", | ||
"name": "test_custom_field", | ||
"slug": "test_custom_field", | ||
"description": "", | ||
"required": false, | ||
"filter_logic": { | ||
"value": "loose", | ||
"label": "Loose" | ||
}, | ||
"default": null, | ||
"weight": 100, | ||
"validation_minimum": null, | ||
"validation_maximum": null, | ||
"validation_regex": "", | ||
"created": "2023-04-15", | ||
"last_updated": "2023-04-15T17:45:11.839431Z", | ||
"notes_url": "http://localhost:8000/api/extras/custom-fields/5b39ba88-e5ab-4be2-89f5-5a016473b53c/notes/" | ||
}, | ||
{ | ||
"id": "5b39ba88-e5ab-4be2-89f5-5a016473b53c", | ||
"display": "Test custom field 2", | ||
"url": "http://localhost:8000/api/extras/custom-fields/5b39ba88-e5ab-4be2-89f5-5a016473b53c/", | ||
"content_types": [ | ||
"dcim.rack" | ||
], | ||
"type": { | ||
"value": "select", | ||
"label": "Selection" | ||
}, | ||
"label": "Test custom field 2", | ||
"name": "test_custom_field_2", | ||
"slug": "test_custom_field_2", | ||
"description": "", | ||
"required": false, | ||
"filter_logic": { | ||
"value": "loose", | ||
"label": "Loose" | ||
}, | ||
"default": null, | ||
"weight": 100, | ||
"validation_minimum": null, | ||
"validation_maximum": null, | ||
"validation_regex": "", | ||
"created": "2023-04-15", | ||
"last_updated": "2023-04-15T18:11:57.133408Z", | ||
"notes_url": "http://localhost:8000/api/extras/custom-fields/5b39ba88-e5ab-4be2-89f5-5a016473b53c/notes/" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should we have
.custom_choices()
callself.custom_fields()
so it is backwards compatible?@jvanderaa @pszulczewski do we have any specific patterns of notifying the end user the method is deprecated?
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.
BTW, this is exactly the question that i had gotten, but i thought it depends on versioning. I guess if it's ok to wait new minor feature release (x.y.z) for this update, it can be as is. Otherwise if it's better to keep as it was, i'm ready to upload a new commit, containing the original method implemetation and both of new, but renamed. Just let me know.
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 don't think we have a specific pattern today @joewesch. I think we should add in something for this.
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 don't think we need to have it straight for here.
If there is a breaking change, we will do a major release, following SemVer. There is an up coming major release for supporting Nautobot 2.0 if we want to get that in with this.
On top of it we should start to look at adding the policy in with 2.0 release.
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 think it would be good to add
.custom_choices()
to callself.custom_fields()
as @joewesch suggested and we will keep it in 1.x release train and remove in 2.0.We can also add
logging
and calllogger.warning()
that the method will be deprecated in 2.x.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.
Done
I've restored original method as it was, except adding deprecation warning log. Original tests are left removed for obvious reasons i presume (or should they be restored as well?)