Fixes #22889: Render Config Revision banner fields in monospace (#22907)

Replace the obsolete Django admin `vLargeTextField` class with Tabler's
`font-monospace` utility for the four banner configuration parameters.

Define the widget styling in the parameter definitions, where the metaclass
constructs the form fields, and remove the ineffective `Meta.widgets`
overrides. Add regression coverage for all six code-oriented configuration
fields, including the two JSON fields that already use a monospace font.

Update the add-config-param skill to recommend `font-monospace` so future
textarea-backed parameters do not reintroduce the obsolete admin class.
This commit is contained in:
Jason Novinger 2026-08-18 08:30:45 -05:00 committed by GitHub
parent 93f16a536d
commit d38ace89ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 30 additions and 11 deletions

View File

@ -43,7 +43,7 @@ ConfigParam(
field=forms.BooleanField, # or IntegerField, CharField, JSONField, SimpleArrayField
# field_kwargs only when extra widget/validation config is needed:
field_kwargs={
'widget': forms.Textarea(attrs={'class': 'vLargeTextField'}),
'widget': forms.Textarea(attrs={'class': 'font-monospace'}),
},
),
```

View File

@ -168,12 +168,6 @@ class ConfigRevisionForm(forms.ModelForm, metaclass=ConfigFormMetaclass):
model = ConfigRevision
fields = '__all__'
widgets = {
'BANNER_LOGIN': forms.Textarea(attrs={'class': 'font-monospace'}),
'BANNER_MAINTENANCE': forms.Textarea(attrs={'class': 'font-monospace'}),
'BANNER_TOP': forms.Textarea(attrs={'class': 'font-monospace'}),
'BANNER_BOTTOM': forms.Textarea(attrs={'class': 'font-monospace'}),
'CUSTOM_VALIDATORS': forms.Textarea(attrs={'class': 'font-monospace'}),
'PROTECTION_RULES': forms.Textarea(attrs={'class': 'font-monospace'}),
'comment': forms.Textarea(),
}

View File

@ -0,0 +1,25 @@
from django.test import TestCase
from core.forms import ConfigRevisionForm
class ConfigRevisionFormTestCase(TestCase):
def test_code_fields_render_monospace(self):
"""
Config parameters that hold markup or code (banners, JSON) must render their
textareas in a monospace font. See #8974 and #22889.
"""
form = ConfigRevisionForm()
monospace_fields = (
'BANNER_LOGIN',
'BANNER_MAINTENANCE',
'BANNER_TOP',
'BANNER_BOTTOM',
'CUSTOM_VALIDATORS',
'PROTECTION_RULES',
)
for name in monospace_fields:
with self.subTest(field=name):
css_classes = form[name].field.widget.attrs.get('class', '').split()
self.assertIn('font-monospace', css_classes)

View File

@ -24,7 +24,7 @@ PARAMS = (
description=_("Additional content to display on the login page"),
field_kwargs={
'widget': forms.Textarea(
attrs={'class': 'vLargeTextField'}
attrs={'class': 'font-monospace'}
),
},
),
@ -35,7 +35,7 @@ PARAMS = (
description=_('Additional content to display when in maintenance mode'),
field_kwargs={
'widget': forms.Textarea(
attrs={'class': 'vLargeTextField'}
attrs={'class': 'font-monospace'}
),
},
),
@ -46,7 +46,7 @@ PARAMS = (
description=_("Additional content to display at the top of every page"),
field_kwargs={
'widget': forms.Textarea(
attrs={'class': 'vLargeTextField'}
attrs={'class': 'font-monospace'}
),
},
),
@ -57,7 +57,7 @@ PARAMS = (
description=_("Additional content to display at the bottom of every page"),
field_kwargs={
'widget': forms.Textarea(
attrs={'class': 'vLargeTextField'}
attrs={'class': 'font-monospace'}
),
},
),