From 0157ac6c9b7ad4b43c05a38e28fdedd13950692e Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Tue, 27 Aug 2024 12:08:39 -0700 Subject: [PATCH] =?UTF-8?q?17186=20change=20custom=20link=20button=20color?= =?UTF-8?q?=20from=20outline-dark=20to=20outline-se=E2=80=A6=20(#17248)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 17186 change custom link button color from outline-dark to outline-secondary * 17186 change choice to default * 17186 change choice to default * 17186 change choice to default * Misc cleanup --------- Co-authored-by: Jeremy Stretch --- .../0116_custom_link_button_color.py | 25 +++++++++++++++++++ netbox/extras/templatetags/custom_links.py | 4 ++- netbox/netbox/choices.py | 5 +--- 3 files changed, 29 insertions(+), 5 deletions(-) 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 000000000..665d73017 --- /dev/null +++ b/netbox/extras/migrations/0116_custom_link_button_color.py @@ -0,0 +1,25 @@ +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='default') + + +class Migration(migrations.Migration): + + dependencies = [ + ('extras', '0115_convert_dashboard_widgets'), + ] + + operations = [ + migrations.AlterField( + model_name='customlink', + name='button_class', + field=models.CharField(default='default', max_length=30), + ), + migrations.RunPython( + code=update_link_buttons, + reverse_code=migrations.RunPython.noop + ), + ] diff --git a/netbox/extras/templatetags/custom_links.py b/netbox/extras/templatetags/custom_links.py index dd28a8160..4aeaaa6b1 100644 --- a/netbox/extras/templatetags/custom_links.py +++ b/netbox/extras/templatetags/custom_links.py @@ -4,6 +4,7 @@ from django.utils.safestring import mark_safe from core.models import ObjectType from extras.models import CustomLink +from netbox.choices import ButtonColorChoices register = template.Library() @@ -59,10 +60,11 @@ 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): 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 fe941056f..4fd730255 100644 --- a/netbox/netbox/choices.py +++ b/netbox/netbox/choices.py @@ -81,10 +81,7 @@ class ColorChoices(ChoiceSet): # class ButtonColorChoices(ChoiceSet): - """ - Map standard button color choices to Bootstrap 3 button classes - """ - DEFAULT = 'outline-dark' + DEFAULT = 'default' BLUE = 'blue' INDIGO = 'indigo' PURPLE = 'purple'