Parcourir la source

Closes #1485: Added LOGIN_BANNER configuration setting to display a banner on the login page

Jeremy Stretch il y a 7 ans
Parent
commit
81df837a33

+ 7 - 1
docs/configuration/optional-settings.md

@@ -17,7 +17,7 @@ ADMINS = [
 
 ## BANNER_BOTTOM
 
-Setting these variables will display content in a banner at the top and/or bottom of the page, respectively. To replicate the content of the top banner in the bottom banner, set:
+Setting these variables will display content in a banner at the top and/or bottom of the page, respectively. HTML is allowed. To replicate the content of the top banner in the bottom banner, set:
 
 ```
 BANNER_TOP = 'Your banner text'
@@ -26,6 +26,12 @@ BANNER_BOTTOM = BANNER_TOP
 
 ---
 
+## BANNER_LOGIN
+
+The value of this variable will be displayed on the login page above the login form. HTML is allowed.
+
+---
+
 ## BASE_PATH
 
 Default: None

+ 5 - 2
netbox/netbox/configuration.example.py

@@ -38,11 +38,14 @@ ADMINS = [
     # ['John Doe', 'jdoe@example.com'],
 ]
 
-# Optionally display a persistent banner at the top and/or bottom of every page. To display the same content in both
-# banners, define BANNER_TOP and set BANNER_BOTTOM = BANNER_TOP.
+# Optionally display a persistent banner at the top and/or bottom of every page. HTML is allowed. To display the same
+# content in both banners, define BANNER_TOP and set BANNER_BOTTOM = BANNER_TOP.
 BANNER_TOP = ''
 BANNER_BOTTOM = ''
 
+# Text to include on the login page above the login form. HTML is allowed.
+BANNER_LOGIN = ''
+
 # Base URL path if accessing NetBox within a directory. For example, if installed at http://example.com/netbox/, set:
 # BASE_PATH = 'netbox/'
 BASE_PATH = ''

+ 3 - 2
netbox/netbox/settings.py

@@ -29,8 +29,9 @@ for setting in ['ALLOWED_HOSTS', 'DATABASE', 'SECRET_KEY']:
 
 # Import optional configuration parameters
 ADMINS = getattr(configuration, 'ADMINS', [])
-BANNER_BOTTOM = getattr(configuration, 'BANNER_BOTTOM', False)
-BANNER_TOP = getattr(configuration, 'BANNER_TOP', False)
+BANNER_BOTTOM = getattr(configuration, 'BANNER_BOTTOM', '')
+BANNER_LOGIN = getattr(configuration, 'BANNER_LOGIN', '')
+BANNER_TOP = getattr(configuration, 'BANNER_TOP', '')
 BASE_PATH = getattr(configuration, 'BASE_PATH', '')
 if BASE_PATH:
     BASE_PATH = BASE_PATH.strip('/') + '/'  # Enforce trailing slash only

+ 6 - 1
netbox/templates/login.html

@@ -2,8 +2,13 @@
 {% load form_helpers %}
 
 {% block content %}
-<div class="row" style="margin-top: 150px;">
+<div class="row" style="margin-top: {% if settings.BANNER_LOGIN %}100{% else %}150{% endif %}px;">
     <div class="col-sm-4 col-sm-offset-4">
+        {% if settings.BANNER_LOGIN %}
+            <div style="margin-bottom: 25px">
+                {{ settings.BANNER_LOGIN|safe }}
+            </div>
+        {% endif %}
         {% if form.non_field_errors %}
             <div class="panel panel-danger">
                 <div class="panel-heading"><strong>Errors</strong></div>