Merge pull request #66 from Grokzen/fix_filter_logic_field
Fix for broken field filterable
This commit is contained in:
commit
3e485049e0
|
@ -168,7 +168,7 @@ text_field:
|
||||||
label: Custom Text
|
label: Custom Text
|
||||||
description: Enter text in a text field.
|
description: Enter text in a text field.
|
||||||
required: false
|
required: false
|
||||||
filterable: true
|
filter_logic: loose
|
||||||
weight: 0
|
weight: 0
|
||||||
on_objects:
|
on_objects:
|
||||||
- dcim.models.Device
|
- dcim.models.Device
|
||||||
|
@ -277,6 +277,7 @@ You can check the label of your local image by running `docker inspect ninech/ne
|
||||||
|
|
||||||
The following is a list of breaking changes:
|
The following is a list of breaking changes:
|
||||||
|
|
||||||
|
* 0.3.0: Field `filterable: <boolean` was replaced with field `filter_logic: loose/exact/disabled`. It will default to `CF_FILTER_LOOSE=loose` when not defined.
|
||||||
* 0.2.0: Re-organized paths: `/etc/netbox -> /etc/netbox/config` and `/etc/reports -> /etc/netbox/reports`. Fixes [#54](https://github.com/ninech/netbox-docker/issues/54).
|
* 0.2.0: Re-organized paths: `/etc/netbox -> /etc/netbox/config` and `/etc/reports -> /etc/netbox/reports`. Fixes [#54](https://github.com/ninech/netbox-docker/issues/54).
|
||||||
* 0.1.0: Introduction of the `NETBOX_DOCKER_PROJECT_VERSION`. (Not a breaking change per se.)
|
* 0.1.0: Introduction of the `NETBOX_DOCKER_PROJECT_VERSION`. (Not a breaking change per se.)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
# label: Custom Text
|
# label: Custom Text
|
||||||
# description: Enter text in a text field.
|
# description: Enter text in a text field.
|
||||||
# required: false
|
# required: false
|
||||||
# filterable: true
|
|
||||||
# weight: 0
|
# weight: 0
|
||||||
# on_objects:
|
# on_objects:
|
||||||
# - dcim.models.Device
|
# - dcim.models.Device
|
||||||
|
@ -17,7 +16,7 @@
|
||||||
# label: Custom Number
|
# label: Custom Number
|
||||||
# description: Enter numbers into an integer field.
|
# description: Enter numbers into an integer field.
|
||||||
# required: true
|
# required: true
|
||||||
# filterable: true
|
# filter_logic: loose
|
||||||
# weight: 10
|
# weight: 10
|
||||||
# on_objects:
|
# on_objects:
|
||||||
# - tenancy.models.Tenant
|
# - tenancy.models.Tenant
|
||||||
|
@ -25,7 +24,7 @@
|
||||||
# type: selection
|
# type: selection
|
||||||
# label: Choose between items
|
# label: Choose between items
|
||||||
# required: false
|
# required: false
|
||||||
# filterable: true
|
# filter_logic: exact
|
||||||
# weight: 30
|
# weight: 30
|
||||||
# on_objects:
|
# on_objects:
|
||||||
# - dcim.models.Device
|
# - dcim.models.Device
|
||||||
|
@ -44,7 +43,7 @@
|
||||||
# type: boolean
|
# type: boolean
|
||||||
# label: Yes Or No?
|
# label: Yes Or No?
|
||||||
# required: true
|
# required: true
|
||||||
# filterable: true
|
# filter_logic: loose
|
||||||
# default: "false" # important: but "false" in quotes!
|
# default: "false" # important: but "false" in quotes!
|
||||||
# weight: 90
|
# weight: 90
|
||||||
# on_objects:
|
# on_objects:
|
||||||
|
@ -54,13 +53,13 @@
|
||||||
# label: Hyperlink
|
# label: Hyperlink
|
||||||
# description: Link to something nice.
|
# description: Link to something nice.
|
||||||
# required: true
|
# required: true
|
||||||
# filterable: false
|
# filter_logic: disabled
|
||||||
# on_objects:
|
# on_objects:
|
||||||
# - tenancy.models.Tenant
|
# - tenancy.models.Tenant
|
||||||
# date_field:
|
# date_field:
|
||||||
# type: date
|
# type: date
|
||||||
# label: Important Date
|
# label: Important Date
|
||||||
# required: false
|
# required: false
|
||||||
# filterable: false
|
# filter_logic: disabled
|
||||||
# on_objects:
|
# on_objects:
|
||||||
# - dcim.models.Device
|
# - dcim.models.Device
|
||||||
|
|
|
@ -36,8 +36,11 @@ with open('/opt/netbox/initializers/custom_fields.yml', 'r') as stream:
|
||||||
if cf_details.get('description', 0):
|
if cf_details.get('description', 0):
|
||||||
custom_field.description = cf_details['description']
|
custom_field.description = cf_details['description']
|
||||||
|
|
||||||
if cf_details.get('filterable', 0):
|
# If no filter_logic is specified then it will default to 'Loose'
|
||||||
custom_field.is_filterables = cf_details['filterable']
|
if cf_details.get('filter_logic', 0):
|
||||||
|
for choice_id, choice_text in CF_FILTER_CHOICES:
|
||||||
|
if choice_text.lower() == cf_details['filter_logic']:
|
||||||
|
custom_field.filter_logic = choice_id
|
||||||
|
|
||||||
if cf_details.get('label', 0):
|
if cf_details.get('label', 0):
|
||||||
custom_field.label = cf_details['label']
|
custom_field.label = cf_details['label']
|
||||||
|
|
Loading…
Reference in New Issue