mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Add MAINTENANCE_MODE, MAPS_URL
This commit is contained in:
@ -28,9 +28,9 @@ class ConfigRevisionAdmin(admin.ModelAdmin):
|
||||
# ('Pagination', {
|
||||
# 'fields': ('MAX_PAGE_SIZE', 'PAGINATE_COUNT'),
|
||||
# }),
|
||||
# ('Miscellaneous', {
|
||||
# 'fields': ('GRAPHQL_ENABLED', 'METRICS_ENABLED', 'MAINTENANCE_MODE', 'MAPS_URL'),
|
||||
# }),
|
||||
('Miscellaneous', {
|
||||
'fields': ('MAINTENANCE_MODE', 'MAPS_URL'),
|
||||
}),
|
||||
('Config Revision', {
|
||||
'fields': ('comment',),
|
||||
})
|
||||
|
@ -56,14 +56,14 @@ PARAMS = (
|
||||
# Racks
|
||||
ConfigParam(
|
||||
name='RACK_ELEVATION_DEFAULT_UNIT_HEIGHT',
|
||||
label='Rack Unit Height',
|
||||
label='Rack unit height',
|
||||
default=22,
|
||||
description="Default unit height for rendered rack elevations",
|
||||
field=forms.IntegerField
|
||||
),
|
||||
ConfigParam(
|
||||
name='RACK_ELEVATION_DEFAULT_UNIT_WIDTH',
|
||||
label='Rack Unit Width',
|
||||
label='Rack unit width',
|
||||
default=220,
|
||||
description="Default unit width for rendered rack elevations",
|
||||
field=forms.IntegerField
|
||||
@ -82,4 +82,19 @@ PARAMS = (
|
||||
field_kwargs={'base_field': forms.CharField()}
|
||||
),
|
||||
|
||||
# Miscellaneous
|
||||
ConfigParam(
|
||||
name='MAINTENANCE_MODE',
|
||||
label='Maintenance mode',
|
||||
default=False,
|
||||
description="Enable maintenance mode",
|
||||
field=OptionalBooleanField
|
||||
),
|
||||
ConfigParam(
|
||||
name='MAPS_URL',
|
||||
label='Maps URL',
|
||||
default='https://maps.google.com/?q=',
|
||||
description="Base URL for mapping geographic locations"
|
||||
),
|
||||
|
||||
)
|
||||
|
@ -158,12 +158,6 @@ LOGIN_REQUIRED = False
|
||||
# re-authenticate. (Default: 1209600 [14 days])
|
||||
LOGIN_TIMEOUT = None
|
||||
|
||||
# Setting this to True will display a "maintenance mode" banner at the top of every page.
|
||||
MAINTENANCE_MODE = False
|
||||
|
||||
# The URL to use when mapping physical addresses or GPS coordinates
|
||||
MAPS_URL = 'https://maps.google.com/?q='
|
||||
|
||||
# An API consumer can request an arbitrary number of objects =by appending the "limit" parameter to the URL (e.g.
|
||||
# "?limit=1000"). This setting defines the maximum limit. Setting it to 0 or None will allow an API consumer to request
|
||||
# all objects by specifying "?limit=0".
|
||||
|
@ -128,8 +128,6 @@ GRAPHQL_ENABLED = getattr(configuration, 'GRAPHQL_ENABLED', True)
|
||||
LOGIN_PERSISTENCE = getattr(configuration, 'LOGIN_PERSISTENCE', False)
|
||||
LOGIN_REQUIRED = getattr(configuration, 'LOGIN_REQUIRED', False)
|
||||
LOGIN_TIMEOUT = getattr(configuration, 'LOGIN_TIMEOUT', None)
|
||||
MAINTENANCE_MODE = getattr(configuration, 'MAINTENANCE_MODE', False)
|
||||
MAPS_URL = getattr(configuration, 'MAPS_URL', 'https://maps.google.com/?q=')
|
||||
MAX_PAGE_SIZE = getattr(configuration, 'MAX_PAGE_SIZE', 1000)
|
||||
METRICS_ENABLED = getattr(configuration, 'METRICS_ENABLED', False)
|
||||
NAPALM_ARGS = getattr(configuration, 'NAPALM_ARGS', {})
|
||||
|
@ -64,7 +64,7 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if settings.MAINTENANCE_MODE %}
|
||||
{% if config.MAINTENANCE_MODE %}
|
||||
<div class="alert alert-warning text-center mx-3" role="alert">
|
||||
<h4><i class="mdi mdi-alert"></i> Maintenance Mode</h4>
|
||||
<span>NetBox is currently in maintenance mode. Functionality may be limited.</span>
|
||||
|
@ -100,7 +100,7 @@
|
||||
<td>
|
||||
{% if object.physical_address %}
|
||||
<div class="float-end noprint">
|
||||
<a href="{{ settings.MAPS_URL }}{{ object.physical_address|urlencode }}" target="_blank" class="btn btn-primary btn-sm">
|
||||
<a href="{{ config.MAPS_URL }}{{ object.physical_address|urlencode }}" target="_blank" class="btn btn-primary btn-sm">
|
||||
<i class="mdi mdi-map-marker"></i> Map It
|
||||
</a>
|
||||
</div>
|
||||
@ -119,7 +119,7 @@
|
||||
<td>
|
||||
{% if object.latitude and object.longitude %}
|
||||
<div class="float-end noprint">
|
||||
<a href="{{ settings.MAPS_URL }}{{ object.latitude }},{{ object.longitude }}" target="_blank" class="btn btn-primary btn-sm">
|
||||
<a href="{{ config.MAPS_URL }}{{ object.latitude }},{{ object.longitude }}" target="_blank" class="btn btn-primary btn-sm">
|
||||
<i class="mdi mdi-map-marker"></i> Map It
|
||||
</a>
|
||||
</div>
|
||||
|
@ -1,6 +1,5 @@
|
||||
import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import login as auth_login, logout as auth_logout, update_session_auth_hash
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
@ -14,6 +13,7 @@ from django.utils.http import is_safe_url
|
||||
from django.views.decorators.debug import sensitive_post_parameters
|
||||
from django.views.generic import View
|
||||
|
||||
from netbox.config import Config
|
||||
from utilities.forms import ConfirmationForm
|
||||
from .forms import LoginForm, PasswordChangeForm, TokenForm
|
||||
from .models import Token
|
||||
@ -53,7 +53,7 @@ class LoginView(View):
|
||||
|
||||
# If maintenance mode is enabled, assume the database is read-only, and disable updating the user's
|
||||
# last_login time upon authentication.
|
||||
if settings.MAINTENANCE_MODE:
|
||||
if Config().MAINTENANCE_MODE:
|
||||
logger.warning("Maintenance mode enabled: disabling update of most recent login time")
|
||||
user_logged_in.disconnect(update_last_login, dispatch_uid='update_last_login')
|
||||
|
||||
|
Reference in New Issue
Block a user