Skip to content

Commit e71a984

Browse files
Adds BANNER_MAINTENANCE config (#12555)
* adds BANNER_MAINTENANCE config #12554 * changes as per review * lint fix * Fix admin form field widget --------- Co-authored-by: jeremystretch <[email protected]>
1 parent 011a936 commit e71a984

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

docs/configuration/miscellaneous.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ This defines custom content to be displayed on the login page above the login fo
2929

3030
---
3131

32+
## BANNER_MAINTENANCE
33+
34+
!!! tip "Dynamic Configuration Parameter"
35+
36+
!!! note
37+
This parameter was added in NetBox v3.5.
38+
39+
This adds a banner to the top of every page when maintenance mode is enabled. HTML is allowed.
40+
41+
---
42+
3243
## BANNER_TOP
3344

3445
!!! tip "Dynamic Configuration Parameter"

netbox/extras/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ConfigRevisionAdmin(admin.ModelAdmin):
2525
'fields': ('ALLOWED_URL_SCHEMES',),
2626
}),
2727
('Banners', {
28-
'fields': ('BANNER_LOGIN', 'BANNER_TOP', 'BANNER_BOTTOM'),
28+
'fields': ('BANNER_LOGIN', 'BANNER_MAINTENANCE', 'BANNER_TOP', 'BANNER_BOTTOM'),
2929
'classes': ('monospace',),
3030
}),
3131
('Pagination', {

netbox/netbox/config/parameters.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ def __init__(self, name, label, default, description='', field=None, field_kwarg
2828
),
2929
},
3030
),
31+
ConfigParam(
32+
name='BANNER_MAINTENANCE',
33+
label=_('Maintenance banner'),
34+
default='NetBox is currently in maintenance mode. Functionality may be limited.',
35+
description=_('Additional content to display when in maintenance mode'),
36+
field_kwargs={
37+
'widget': forms.Textarea(
38+
attrs={'class': 'vLargeTextField'}
39+
),
40+
},
41+
),
3142
ConfigParam(
3243
name='BANNER_TOP',
3344
label=_('Top banner'),

netbox/templates/base/layout.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@
7777
</div>
7878
{% endif %}
7979

80-
{% if config.MAINTENANCE_MODE %}
80+
{% if config.MAINTENANCE_MODE and config.BANNER_MAINTENANCE %}
8181
<div class="alert alert-warning text-center mx-3" role="alert">
8282
<h5><i class="mdi mdi-alert"></i> Maintenance Mode</h5>
83-
NetBox is currently in maintenance mode. Functionality may be limited.
83+
{{ config.BANNER_MAINTENANCE|escape }}
8484
</div>
8585
{% endif %}
8686

0 commit comments

Comments
 (0)