Просмотр исходного кода

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 <jstretch@netboxlabs.com>
Abhimanyu Saharan 2 лет назад
Родитель
Сommit
e71a98499f

+ 11 - 0
docs/configuration/miscellaneous.md

@@ -29,6 +29,17 @@ This defines custom content to be displayed on the login page above the login fo
 
 ---
 
+## BANNER_MAINTENANCE
+
+!!! tip "Dynamic Configuration Parameter"
+
+!!! note
+    This parameter was added in NetBox v3.5.
+
+This adds a banner to the top of every page when maintenance mode is enabled. HTML is allowed.
+
+---
+
 ## BANNER_TOP
 
 !!! tip "Dynamic Configuration Parameter"

+ 1 - 1
netbox/extras/admin.py

@@ -25,7 +25,7 @@ class ConfigRevisionAdmin(admin.ModelAdmin):
             'fields': ('ALLOWED_URL_SCHEMES',),
         }),
         ('Banners', {
-            'fields': ('BANNER_LOGIN', 'BANNER_TOP', 'BANNER_BOTTOM'),
+            'fields': ('BANNER_LOGIN', 'BANNER_MAINTENANCE', 'BANNER_TOP', 'BANNER_BOTTOM'),
             'classes': ('monospace',),
         }),
         ('Pagination', {

+ 11 - 0
netbox/netbox/config/parameters.py

@@ -28,6 +28,17 @@ PARAMS = (
             ),
         },
     ),
+    ConfigParam(
+        name='BANNER_MAINTENANCE',
+        label=_('Maintenance banner'),
+        default='NetBox is currently in maintenance mode. Functionality may be limited.',
+        description=_('Additional content to display when in maintenance mode'),
+        field_kwargs={
+            'widget': forms.Textarea(
+                attrs={'class': 'vLargeTextField'}
+            ),
+        },
+    ),
     ConfigParam(
         name='BANNER_TOP',
         label=_('Top banner'),

+ 2 - 2
netbox/templates/base/layout.html

@@ -77,10 +77,10 @@ Blocks:
           </div>
         {% endif %}
 
-        {% if config.MAINTENANCE_MODE %}
+        {% if config.MAINTENANCE_MODE and config.BANNER_MAINTENANCE %}
           <div class="alert alert-warning text-center mx-3" role="alert">
             <h5><i class="mdi mdi-alert"></i> Maintenance Mode</h5>
-            NetBox is currently in maintenance mode. Functionality may be limited.
+            {{ config.BANNER_MAINTENANCE|escape }}
           </div>
         {% endif %}