From 2dacdcec278f4ad4bdda74097c0451e510a0892f Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Thu, 22 Aug 2024 12:46:11 -0700 Subject: [PATCH 1/5] 17186 change custom link button color from outline-dark to outline-secondary --- .../0116_custom_link_button_color.py | 27 +++++++++++++++++++ netbox/netbox/choices.py | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 netbox/extras/migrations/0116_custom_link_button_color.py diff --git a/netbox/extras/migrations/0116_custom_link_button_color.py b/netbox/extras/migrations/0116_custom_link_button_color.py new file mode 100644 index 00000000000..f9043737286 --- /dev/null +++ b/netbox/extras/migrations/0116_custom_link_button_color.py @@ -0,0 +1,27 @@ +# Generated by Django 5.0.8 on 2024-08-22 19:39 + +from django.db import migrations, models + + +def update_link_buttons(apps, schema_editor): + CustomLink = apps.get_model('extras', 'CustomLink') + CustomLink.objects.filter(button_class='outline-dark').update(button_class='outline-secondary') + + +class Migration(migrations.Migration): + + dependencies = [ + ('extras', '0115_convert_dashboard_widgets'), + ] + + operations = [ + migrations.AlterField( + model_name='customlink', + name='button_class', + field=models.CharField(default='outline-secondary', max_length=30), + ), + migrations.RunPython( + code=update_link_buttons, + reverse_code=migrations.RunPython.noop + ), + ] diff --git a/netbox/netbox/choices.py b/netbox/netbox/choices.py index fe941056fc0..e558463c7b2 100644 --- a/netbox/netbox/choices.py +++ b/netbox/netbox/choices.py @@ -84,7 +84,7 @@ class ButtonColorChoices(ChoiceSet): """ Map standard button color choices to Bootstrap 3 button classes """ - DEFAULT = 'outline-dark' + DEFAULT = 'outline-secondary' BLUE = 'blue' INDIGO = 'indigo' PURPLE = 'purple' From 90b423812c5d3a974fe8609a2f0d9d0536975f74 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Tue, 27 Aug 2024 09:00:16 -0700 Subject: [PATCH 2/5] 17186 change choice to default --- netbox/extras/migrations/0116_custom_link_button_color.py | 2 +- netbox/extras/templatetags/custom_links.py | 7 ++++++- netbox/netbox/choices.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/netbox/extras/migrations/0116_custom_link_button_color.py b/netbox/extras/migrations/0116_custom_link_button_color.py index f9043737286..5910cdcef24 100644 --- a/netbox/extras/migrations/0116_custom_link_button_color.py +++ b/netbox/extras/migrations/0116_custom_link_button_color.py @@ -18,7 +18,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='customlink', name='button_class', - field=models.CharField(default='outline-secondary', max_length=30), + field=models.CharField(default='default', max_length=30), ), migrations.RunPython( code=update_link_buttons, diff --git a/netbox/extras/templatetags/custom_links.py b/netbox/extras/templatetags/custom_links.py index dd28a816010..a961c4ea7ec 100644 --- a/netbox/extras/templatetags/custom_links.py +++ b/netbox/extras/templatetags/custom_links.py @@ -61,8 +61,13 @@ def custom_links(context, obj): else: try: if rendered := cl.render(link_context): + if cl.button_class == "default": + button_class = 'outline-secondary' + else: + button_class = cl.button_class + template_code += LINK_BUTTON.format( - rendered['link'], rendered['link_target'], cl.button_class, rendered['text'] + rendered['link'], rendered['link_target'], button_class, rendered['text'] ) except Exception as e: template_code += f'' \ diff --git a/netbox/netbox/choices.py b/netbox/netbox/choices.py index e558463c7b2..60a1969b1c4 100644 --- a/netbox/netbox/choices.py +++ b/netbox/netbox/choices.py @@ -84,7 +84,7 @@ class ButtonColorChoices(ChoiceSet): """ Map standard button color choices to Bootstrap 3 button classes """ - DEFAULT = 'outline-secondary' + DEFAULT = 'default' BLUE = 'blue' INDIGO = 'indigo' PURPLE = 'purple' From 0f7b12f93911f4b825b9b9106e6f996d34fc9838 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Tue, 27 Aug 2024 09:01:19 -0700 Subject: [PATCH 3/5] 17186 change choice to default --- netbox/extras/migrations/0116_custom_link_button_color.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/extras/migrations/0116_custom_link_button_color.py b/netbox/extras/migrations/0116_custom_link_button_color.py index 5910cdcef24..7295d7fc025 100644 --- a/netbox/extras/migrations/0116_custom_link_button_color.py +++ b/netbox/extras/migrations/0116_custom_link_button_color.py @@ -5,7 +5,7 @@ def update_link_buttons(apps, schema_editor): CustomLink = apps.get_model('extras', 'CustomLink') - CustomLink.objects.filter(button_class='outline-dark').update(button_class='outline-secondary') + CustomLink.objects.filter(button_class='outline-dark').update(button_class='default') class Migration(migrations.Migration): From a98b6a6fdff33b88ff12af45e5b088de8955039b Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Tue, 27 Aug 2024 09:04:13 -0700 Subject: [PATCH 4/5] 17186 change choice to default --- netbox/extras/templatetags/custom_links.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/netbox/extras/templatetags/custom_links.py b/netbox/extras/templatetags/custom_links.py index a961c4ea7ec..feb12fd9a63 100644 --- a/netbox/extras/templatetags/custom_links.py +++ b/netbox/extras/templatetags/custom_links.py @@ -4,6 +4,7 @@ from core.models import ObjectType from extras.models import CustomLink +from netbox.choices import ButtonColorChoices register = template.Library() @@ -61,7 +62,7 @@ def custom_links(context, obj): else: try: if rendered := cl.render(link_context): - if cl.button_class == "default": + if cl.button_class == ButtonColorChoices.DEFAULT: button_class = 'outline-secondary' else: button_class = cl.button_class From dec7ac79bfca50817b19a28ea0fe1a6cfdd3a1cd Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 27 Aug 2024 14:16:35 -0400 Subject: [PATCH 5/5] Misc cleanup --- netbox/extras/migrations/0116_custom_link_button_color.py | 2 -- netbox/extras/templatetags/custom_links.py | 6 +----- netbox/netbox/choices.py | 3 --- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/netbox/extras/migrations/0116_custom_link_button_color.py b/netbox/extras/migrations/0116_custom_link_button_color.py index 7295d7fc025..665d73017b6 100644 --- a/netbox/extras/migrations/0116_custom_link_button_color.py +++ b/netbox/extras/migrations/0116_custom_link_button_color.py @@ -1,5 +1,3 @@ -# Generated by Django 5.0.8 on 2024-08-22 19:39 - from django.db import migrations, models diff --git a/netbox/extras/templatetags/custom_links.py b/netbox/extras/templatetags/custom_links.py index feb12fd9a63..4aeaaa6b15a 100644 --- a/netbox/extras/templatetags/custom_links.py +++ b/netbox/extras/templatetags/custom_links.py @@ -60,13 +60,9 @@ def custom_links(context, obj): # Add non-grouped links else: + button_class = 'outline-secondary' if cl.button_class == ButtonColorChoices.DEFAULT else cl.button_class try: if rendered := cl.render(link_context): - if cl.button_class == ButtonColorChoices.DEFAULT: - button_class = 'outline-secondary' - else: - button_class = cl.button_class - template_code += LINK_BUTTON.format( rendered['link'], rendered['link_target'], button_class, rendered['text'] ) diff --git a/netbox/netbox/choices.py b/netbox/netbox/choices.py index 60a1969b1c4..4fd7302556e 100644 --- a/netbox/netbox/choices.py +++ b/netbox/netbox/choices.py @@ -81,9 +81,6 @@ class ColorChoices(ChoiceSet): # class ButtonColorChoices(ChoiceSet): - """ - Map standard button color choices to Bootstrap 3 button classes - """ DEFAULT = 'default' BLUE = 'blue' INDIGO = 'indigo'