-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathsettings.py
More file actions
154 lines (133 loc) · 4.16 KB
/
settings.py
File metadata and controls
154 lines (133 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# ---------------------------------------------------------------------
# Django settings
# ---------------------------------------------------------------------
# Copyright (C) 2007-2025 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
import logging
import re
import os
# NOC modules
from noc.config import config
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "1"
DEBUG = False
TEMPLATE_DEBUG = DEBUG
ADMINS = []
MANAGERS = ADMINS
SERVER_EMAIL = None
# It is up to upstream server to check Host header
ALLOWED_HOSTS = ["*"]
# RDBMS settings
DATABASES = {
"default": {
"ENGINE": "noc.core.model.db",
"NAME": config.pg.db,
"USER": config.pg.user,
"PASSWORD": config.pg.password,
# Defer resolution
"HOST": lambda: config.pg.addresses[0].host,
"PORT": lambda: config.pg.addresses[0].port,
"AUTOCOMMIT": True,
"DISABLE_SERVER_SIDE_CURSORS": True,
"OPTIONS": {"connect_timeout": config.pg.connect_timeout},
}
}
ATOMIC_REQUESTS = False
TIME_ZONE = str(config.timezone)
LANGUAGE_CODE = config.language_code
# Set up date and time formats
DATE_FORMAT = config.date_time_formats.date_format
TIME_FORMAT = config.date_time_formats.time_format
MONTH_DAY_FORMAT = config.date_time_formats.month_day_format
YEAR_MONTH_FORMAT = config.date_time_formats.year_month_format
DATETIME_FORMAT = config.date_time_formats.datetime_format
# Set up date input formats
DATE_INPUT_FORMATS = ["%Y-%m-%d"]
if config.date_time_formats.date_format != DATE_INPUT_FORMATS[0]:
DATE_INPUT_FORMATS.insert(
0,
re.sub(
"[^./: ]", lambda match: "%%%s" % match.group(0), config.date_time_formats.date_format
),
)
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ""
# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
MEDIA_URL = ""
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
STATIC_URL = "/ui/pkg/django-media/"
# Make this unique, and don"t share it with anybody.
SECRET_KEY = config.secret_key
# The maximum size in bytes that a request body may be
# before a SuspiciousOperation (RequestDataTooBig) is raised.
DATA_UPLOAD_MAX_MEMORY_SIZE = config.web.max_upload_size
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = [
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
]
TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
)
MIDDLEWARE = [
"django.middleware.common.CommonMiddleware",
"noc.core.middleware.remoteuser.remote_user_middleware",
"noc.core.middleware.tls.tls_middleware",
"noc.core.middleware.extformat.ext_format_middleware",
]
ROOT_URLCONF = "noc.services.web.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": False,
"DIRS": [".", "templates"],
}
]
INSTALLED_APPS = [
"noc.aaa",
"noc.main",
"noc.dev",
"noc.project",
"noc.wf",
"noc.gis",
"noc.crm",
"noc.inv",
"noc.sa",
"noc.fm",
"noc.pm",
"noc.cm",
"noc.ip",
"noc.vc",
"noc.dns",
"noc.peer",
"noc.kb",
"noc.maintenance",
"noc.support",
"noc.bi",
"noc.sla",
"noc.phone",
]
FORCE_SCRIPT_NAME = ""
# Available languages
_ = lambda s: s
LANGUAGES = [("en", _("English")), ("ru", _("Russian")), ("pt_BR", _("Portuguese (BRAZIL)"))]
LOCALE_PATHS = ["locale"]
# Do not enforce lowercase tags
FORCE_LOWERCASE_TAGS = False
# Suppress deprecation warning. We don't use django's testing framework
TEST_RUNNER = None
# Explicitly setup Django 5 behavior
USE_TZ = False
# Disable SQL statement logging
logging.getLogger("django.db.backends").setLevel(logging.ERROR)