-
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
Closes #16076: Extend PROTECTION_RULES
example
#18033
base: develop
Are you sure you want to change the base?
Changes from all commits
062295d
5459b37
ec46044
a4e22ab
c769ee9
3b02d03
7d54045
6e54e9f
7088791
0ac87ff
29405d2
771ac8a
e131436
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,17 +94,17 @@ The following colors are supported: | |
|
||
!!! tip "Dynamic Configuration Parameter" | ||
|
||
This is a mapping of models to [custom validators](../customization/custom-validation.md) against which an object is evaluated immediately prior to its deletion. If validation fails, the object is not deleted. An example is provided below: | ||
This is a mapping of models to [custom validators](../customization/custom-validation.md) against which an object is evaluated immediately prior to its deletion. If validation fails, the object is not deleted. The configuration can be carried out in the menu under “System/Configuration History/Custom validators”. | ||
In the example, a device can only be deleted when it is set to the “decommissioning” status. Paths such as “dcim.device” can be found in the top right-hand corner when you open the page of a device. For a rack it would therefore be “dcim.rack”. | ||
|
||
```python | ||
PROTECTION_RULES = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no reason to remove this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the example is not well suited or not well described for someone who deals with the topic. If I understand it correctly, it mixes 3 complexities together. Example: The site can only be deleted if the status is: decommissioning. Notation for Configuration.py file: PROTECTION_RULES = { Notation for web frontend: ‘dcim.site": [ Notation for Configuration.py with further validation of custom plugins: PROTECTION_RULES = { The problem with the original example is that it does not work out of the box. ‘my_plugin.validators.Validator1’,: PROTECTION_RULES = {: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have an idea, in the chapter ‘Dynamic Configuration Parameter’ I would like to point out that the outer bracket e.g. PROTECTION_RULES = { ..} is relevant within the Configuration.py. In the web frontend, however, this should be removed from the examples. As the parameter in the web front end already represents this. Would that be ok? |
||
"dcim.site": [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why change the object type? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes ok you could leave it at Site. But I think the example is much more interesting for devices. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have an idea, I will reverse this example and integrate the variant for Device. Then you can see how to integrate multiple validations. |
||
{ | ||
"dcim.device": [ | ||
{ | ||
"status": { | ||
"eq": "decommissioning" | ||
} | ||
}, | ||
"my_plugin.validators.Validator1", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no reason to remove this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. In my opinion, this should be a separate example, because a beginner is doomed to failure. Because it will never work unless he knows what this line means and what needs to be done for it. I still wouldn't know, because it's too much for the first step. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I have an idea. I will undo this and create a hint text that you should leave out this line for the entry. Can you give me a short description of this line so that beginners can understand it better? Something like: This line is used to integrate a validation of its own plugin. Perhaps also a link to the topic? |
||
} | ||
] | ||
} | ||
``` |
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.
This is implied by the "dynamic configuration parameter" note above, which appears on many similar parameters.
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.
Ok, I hadn't understood the connection between the tip.
!!! tip "Dynamic Configuration Parameter"
Because there is no link to the other md file where the topic was described.
https://demo.netbox.dev/static/docs/configuration/#dynamic-configuration-parameters
It was only through your comment and Google that I found the connection again.
If there was a link to dynamic-configuration-parameters, you could probably understand it better.
I would like to adapt the tip like this:
!!! tip [
Dynamic Configuration Parameter](./index.md#dynamic-configuration-parameters)
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.
Is it ok if I adjust all these tips?
Before:
!!! tip ‘Dynamic Configuration Parameter’
After:
!!! tip [
Dynamic Configuration Parameter](./index.md#dynamic-configuration-parameters)