mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-14 15:52:18 -06:00
Merge branch 'main' into feature
Some checks failed
CI / build (20.x, 3.12) (push) Has been cancelled
CI / build (20.x, 3.13) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, actions) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
Some checks failed
CI / build (20.x, 3.12) (push) Has been cancelled
CI / build (20.x, 3.13) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, actions) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
This commit is contained in:
@@ -10,6 +10,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
from core.models import ObjectType
|
||||
from ipam.formfields import IPNetworkFormField
|
||||
from ipam.validators import prefix_validator
|
||||
from netbox.config import get_config
|
||||
from netbox.preferences import PREFERENCES
|
||||
from users.choices import TokenVersionChoices
|
||||
from users.constants import *
|
||||
@@ -63,8 +64,8 @@ class UserConfigFormMetaclass(forms.models.ModelFormMetaclass):
|
||||
class UserConfigForm(forms.ModelForm, metaclass=UserConfigFormMetaclass):
|
||||
fieldsets = (
|
||||
FieldSet(
|
||||
'locale.language', 'pagination.per_page', 'pagination.placement', 'ui.tables.striping',
|
||||
name=_('User Interface')
|
||||
'locale.language', 'ui.copilot_enabled', 'pagination.per_page', 'pagination.placement',
|
||||
'ui.tables.striping', name=_('User Interface')
|
||||
),
|
||||
FieldSet('data_format', 'csv_delimiter', name=_('Miscellaneous')),
|
||||
)
|
||||
@@ -81,8 +82,7 @@ class UserConfigForm(forms.ModelForm, metaclass=UserConfigFormMetaclass):
|
||||
def __init__(self, *args, instance=None, **kwargs):
|
||||
|
||||
# Get initial data from UserConfig instance
|
||||
initial_data = flatten_dict(instance.data)
|
||||
kwargs['initial'] = initial_data
|
||||
kwargs['initial'] = flatten_dict(instance.data)
|
||||
|
||||
super().__init__(*args, instance=instance, **kwargs)
|
||||
|
||||
@@ -91,6 +91,10 @@ class UserConfigForm(forms.ModelForm, metaclass=UserConfigFormMetaclass):
|
||||
(f'tables.{table_name}', '') for table_name in instance.data.get('tables', [])
|
||||
)
|
||||
|
||||
# Disable Copilot preference if it has been disabled globally
|
||||
if not get_config().COPILOT_ENABLED:
|
||||
self.fields['ui.copilot_enabled'].disabled = True
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
||||
# Set UserConfig data
|
||||
|
||||
Reference in New Issue
Block a user