Skip to content
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

Add fields to restrict visibility/creation of custom fields #4841

Closed
shane-davidson opened this issue Jul 10, 2020 · 2 comments
Closed

Add fields to restrict visibility/creation of custom fields #4841

shane-davidson opened this issue Jul 10, 2020 · 2 comments

Comments

@shane-davidson
Copy link

shane-davidson commented Jul 10, 2020

Environment

  • Python version: 3.8.2
  • NetBox version: 2.8

Proposed Functionality

Adding an option in custom fields to restrict the custom field visibility based on the model fields equality a specific value.

class CustomField(models.Model):

    restrict= models.CharField(
        default=None,
       choices= "custom choice set showing fields available for filtering"
        help_text='Model field used to restrict visibility of this custom field.'
    )

    restrict_value= models.CharField(
        blank=True,
        help_text='Value to match when restrict field is set'
    )

    restrict_negate= models.BooleanField(
        blank=True,
        help_text='Negates restriction match'
    )

when creating a custom field you have the option to select a field and a value to match.
This field and value will decide if the custom field is visible or not.

Use Case

Create a role for a virtual machine called "app server"
Create a custom field you only want visible on virtual machine with the "app server" role

restrict = "role.name"
restrict_value = "app server"

Create a role for a virtual machine called "database server"
Create a custom field you only want visible on virtual machine with the "database server" role

restrict = "role.name"
restrict_value = "database server"

Create a device with type "Cisco Router"
Create a custom field on device

restrict = "device_type.manufacturer.name"
restrict_value = "Cisco"

OR

restrict = "device_type.manufacturer.model"
restrict_value = "Cisco Router XXX"

Other considerations:

  • Optional negate on the restriction.
  • Setting for if new 'restrict' field doesn't match any model field to show or hide the custom fields

Database Changes

New fields on CustomField

External Dependencies

None

@jeremystretch
Copy link
Member

We are not currently accepting feature requests for development related to custom fields.

@jeremystretch
Copy link
Member

Please see #4878

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants