Skip to content

Commit b605dfc

Browse files
16704 - Define a default help_text for ColorField (netbox-community#16708)
* Added `help_text` to ColorField. * Addressed PR comment to remove the redundant help_text from all the forms where ColorField was used. * Add space before example value --------- Co-authored-by: Jeremy Stretch <[email protected]>
1 parent 33004df commit b605dfc

File tree

4 files changed

+2
-18
lines changed

4 files changed

+2
-18
lines changed

netbox/circuits/forms/bulk_import.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ class CircuitTypeImportForm(NetBoxModelImportForm):
6666
class Meta:
6767
model = CircuitType
6868
fields = ('name', 'slug', 'color', 'description', 'tags')
69-
help_texts = {
70-
'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' <code>00ff00</code>'),
71-
}
7269

7370

7471
class CircuitImportForm(NetBoxModelImportForm):

netbox/dcim/forms/bulk_import.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,6 @@ class RackRoleImportForm(NetBoxModelImportForm):
174174
class Meta:
175175
model = RackRole
176176
fields = ('name', 'slug', 'color', 'description', 'tags')
177-
help_texts = {
178-
'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' <code>00ff00</code>'),
179-
}
180177

181178

182179
class RackImportForm(NetBoxModelImportForm):
@@ -384,9 +381,6 @@ class DeviceRoleImportForm(NetBoxModelImportForm):
384381
class Meta:
385382
model = DeviceRole
386383
fields = ('name', 'slug', 'color', 'vm_role', 'config_template', 'description', 'tags')
387-
help_texts = {
388-
'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' <code>00ff00</code>'),
389-
}
390384

391385

392386
class PlatformImportForm(NetBoxModelImportForm):
@@ -1104,9 +1098,6 @@ class InventoryItemRoleImportForm(NetBoxModelImportForm):
11041098
class Meta:
11051099
model = InventoryItemRole
11061100
fields = ('name', 'slug', 'color', 'description')
1107-
help_texts = {
1108-
'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' <code>00ff00</code>'),
1109-
}
11101101

11111102

11121103
#
@@ -1183,9 +1174,6 @@ class Meta:
11831174
'side_a_device', 'side_a_type', 'side_a_name', 'side_b_device', 'side_b_type', 'side_b_name', 'type',
11841175
'status', 'tenant', 'label', 'color', 'length', 'length_unit', 'description', 'comments', 'tags',
11851176
]
1186-
help_texts = {
1187-
'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' <code>00ff00</code>'),
1188-
}
11891177

11901178
def _clean_side(self, side):
11911179
"""

netbox/extras/forms/bulk_import.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,6 @@ class TagImportForm(CSVModelForm):
228228
class Meta:
229229
model = Tag
230230
fields = ('name', 'slug', 'color', 'description')
231-
help_texts = {
232-
'color': mark_safe(_('RGB color in hexadecimal. Example:') + ' <code>00ff00</code>'),
233-
}
234231

235232

236233
class JournalEntryImportForm(NetBoxModelImportForm):

netbox/utilities/fields.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from django.contrib.contenttypes.fields import GenericForeignKey
44
from django.db import models
5+
from django.utils.safestring import mark_safe
56
from django.utils.translation import gettext_lazy as _
67

78
from utilities.ordering import naturalize
@@ -26,6 +27,7 @@ def __init__(self, *args, **kwargs):
2627

2728
def formfield(self, **kwargs):
2829
kwargs['widget'] = ColorSelect
30+
kwargs['help_text'] = mark_safe(_('RGB color in hexadecimal. Example: ') + '<code>00ff00</code>')
2931
return super().formfield(**kwargs)
3032

3133

0 commit comments

Comments
 (0)