-
-
Notifications
You must be signed in to change notification settings - Fork 100
Expand file tree
/
Copy pathsettings.py
More file actions
195 lines (169 loc) · 6.47 KB
/
settings.py
File metadata and controls
195 lines (169 loc) · 6.47 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Django settings for patchman project.
import os
import site
import sys
# use pysqlite3 if available
try:
import pysqlite3 # noqa
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
except ImportError:
pass
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DEBUG = True
ALLOWED_HOSTS = ['127.0.0.1']
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.http.ConditionalGetMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
]
# SECURE_BROWSER_XSS_FILTER = True
# SECURE_CONTENT_TYPE_NOSNIFF = True
# CSRF_COOKIE_SECURE = True
# SESSION_COOKIE_SECURE = True
# X_FRAME_OPTIONS = 'DENY'
SITE_ID = 1
ROOT_URLCONF = 'patchman.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'util.context_processors.issues_count',
'util.context_processors.patchman_version',
],
'debug': DEBUG,
},
},
]
# Internationalization
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'America/NewYork'
USE_I18N = True
USE_L10N = True
USE_TZ = True
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
DEFAULT_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'django.contrib.admindocs',
'django.contrib.sites',
]
THIRD_PARTY_APPS = [
'django_extensions',
'taggit',
'bootstrap3',
'django_tables2',
'django_select2',
'rest_framework',
'django_filters',
'celery',
'django_celery_beat',
]
LOCAL_APPS = [
'arch.apps.ArchConfig',
'domains.apps.DomainsConfig',
'errata.apps.ErrataConfig',
'hosts.apps.HostsConfig',
'modules.apps.ModulesConfig',
'operatingsystems.apps.OperatingsystemsConfig',
'packages.apps.PackagesConfig',
'repos.apps.ReposConfig',
'security.apps.SecurityConfig',
'reports.apps.ReportsConfig',
'util.apps.UtilConfig',
'rest_framework_api_key',
]
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': ['rest_framework.permissions.IsAuthenticatedOrReadOnly'], # noqa
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication',
],
'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'], # noqa
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', # noqa
'PAGE_SIZE': 100,
}
# API Key authentication settings
# Set to False to allow unauthenticated protocol 2 report uploads
REQUIRE_API_KEY = True
TAGGIT_CASE_INSENSITIVE = True
DJANGO_TABLES2_TEMPLATE = 'table.html'
CELERY_BROKER_URL = 'redis://127.0.0.1:6379/0'
CELERY_BROKER_TRANSPORT_OPTIONS = {
'queue_order_strategy': 'priority',
}
CELERY_BROKER_CONNECTION_RETRY_ON_STARTUP = True
CELERY_WORKER_PREFETCH_MULTIPLIER = 1
LOGIN_REDIRECT_URL = '/patchman/'
LOGOUT_REDIRECT_URL = '/patchman/login/'
LOGIN_URL = '/patchman/login/'
# URL prefix for static files.
STATIC_URL = '/patchman/static/'
# Additional dirs where the media should be copied from
STATICFILES_DIRS = [os.path.abspath(os.path.join(BASE_DIR, 'patchman/static'))]
# Absolute path to the directory static files should be collected to.
STATIC_ROOT = '/var/lib/patchman/static/'
if sys.prefix == '/usr':
conf_path = '/etc/patchman'
else:
conf_path = os.path.join(sys.prefix, 'etc/patchman')
# if sys.prefix + conf_path doesn't exist, try ./etc/patchman (source)
if not os.path.isdir(conf_path):
conf_path = './etc/patchman'
# if ./etc/patchman doesn't exist, try site.getsitepackages() (pip/new-style virtualenv)
if not os.path.isdir(conf_path):
try:
sitepackages = site.getsitepackages()[0]
except (AttributeError, IndexError):
# old-style virtualenv, try site-packages in sys.path
sp = 'site-packages'
sitepackages = [s for s in sys.path if s.endswith(sp)][0]
conf_path = os.path.join(sitepackages, 'etc/patchman')
local_settings = os.path.join(conf_path, 'local_settings.py')
with open(local_settings, 'r', encoding='utf_8') as ls:
exec(compile(ls.read(), local_settings, 'exec'))
INSTALLED_APPS = DEFAULT_APPS + THIRD_PARTY_APPS + LOCAL_APPS
if RUN_GUNICORN or (len(sys.argv) > 1 and sys.argv[1] == 'runserver'): # noqa
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/login/'
LOGIN_URL = '/login/'
STATICFILES_DIRS = [os.path.abspath(os.path.join(BASE_DIR, 'patchman/static'))] # noqa
STATIC_ROOT = os.path.abspath(os.path.join(BASE_DIR, 'run/static'))
STATIC_URL = '/static/'
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.http.ConditionalGetMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
]
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' # noqa