• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fiduswriter / fiduswriter / 10941406873

19 Sep 2024 12:55PM UTC coverage: 87.088% (-0.007%) from 87.095%
10941406873

Pull #1294

github

web-flow
Merge 0ca2fd0ed into b2c563a85
Pull Request #1294: remove JSONPATCH setting

6374 of 7319 relevant lines covered (87.09%)

4.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.85
fiduswriter/base/settings.py
1
import os
13✔
2

3
PORT = 8000
13✔
4

5
# If you want to show debug messages, set DEBUG to True.
6
DEBUG = True
13✔
7
SOURCE_MAPS = False
13✔
8

9
# This determines whether the server is used for testing and will let the
10
# users know upon signup know that their documents may disappear.
11
TEST_SERVER = True
13✔
12
# This is the contact email that will be shown in various places all over
13
# the site.
14
CONTACT_EMAIL = "mail@email.com"
13✔
15
# If websockets is running on a non-standard server/port, add it here:
16
WS_SERVERS = [
13✔
17
    False,  # Default websocket server
18
]
19
# Interval between document saves
20
DOC_SAVE_INTERVAL = 30
13✔
21

22
ADMINS = (("Your Name", "your_email@example.com"),)
13✔
23

24
MANAGERS = ADMINS
13✔
25

26
# The top path of the project. Depending on whether ./manage.py is executed or
27
# the fiduswriter pip package, it is either the dir that contains manage.py or
28
# the cwd.
29
PROJECT_PATH = os.environ.get("PROJECT_PATH")
13✔
30
# SRC_PATH is the root path of the FW sources.
31
SRC_PATH = os.environ.get("SRC_PATH")
13✔
32

33
DATABASES = {
13✔
34
    "default": {
35
        "ENGINE": "django.db.backends.sqlite3",
36
        "NAME": os.path.join(PROJECT_PATH, "fiduswriter.sqlite3"),
37
        "CONN_MAX_AGE": None,
38
        "TEST": {"NAME": "testdb.sqlite3"},
39
    }
40
}
41

42
# Will let any user not delete more than 5000 bibliography entries
43
# simultaneously
44
DATA_UPLOAD_MAX_NUMBER_FIELDS = 5000
13✔
45

46
# Whether anyone surfing to the site can open an account with a login/password.
47
REGISTRATION_OPEN = True
13✔
48

49
# Whether user's can login using passwords (if not, they will only be able to
50
# sign in using social accounts).
51
PASSWORD_LOGIN = True
13✔
52

53
# Whether anyone surfing to the site can open an account or login with a
54
# socialaccount.
55
SOCIALACCOUNT_OPEN = True
13✔
56
SOCIALACCOUNT_STORE_TOKENS = True
13✔
57
SOCIALACCOUNT_EMAIL_VERIFICATION = "none"
13✔
58

59
# This determines whether there is a star labeled "Free" on the login page
60
IS_FREE = True
13✔
61

62
# Send emails to console.
63
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
13✔
64

65
# Or send emails using an SMTP server
66
# EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
67
# EMAIL_HOST = 'localhost'
68
# EMAIL_HOST_USER = ''
69
# EMAIL_HOST_PASSWORD = ''
70
# EMAIL_PORT = 25
71
# EMAIL_SUBJECT_PREFIX = '[Fidus Writer]'
72

73

74
# Local time zone for this installation. Keep UTC here, the frontend will
75
# translate this to the correct local time.
76
TIME_ZONE = "UTC"
13✔
77

78
# Language code for this installation. All choices can be found here:
79
# http://www.i18nguy.com/unicode/language-identifiers.html
80
LANGUAGE_CODE = "en-us"
13✔
81

82
SITE_ID = 1
13✔
83

84
# If you set this to False, the server will make some optimizations so as not
85
# to load the internationalization machinery. Fidus Writer makes use of
86
# internationalization, so you should probably keep this on.
87

88
USE_I18N = True
13✔
89

90
LOCALE_PATHS = (os.path.join(SRC_PATH, "locale"),)
13✔
91

92
# A list of allowed hostnames of this Fidus Writer installation
93
ALLOWED_HOSTS = [
13✔
94
    "localhost",
95
]
96

97
# If you set this to False, the server will not format dates, numbers and
98
# calendars according to the current locale.
99
USE_L10N = True
13✔
100

101
# If you set this to False, the server will not use timezone-aware datetimes.
102
USE_TZ = True
13✔
103

104
# Absolute filesystem path to the directory that will hold user-uploaded files.
105
# The default is the media folder in the directory above this file.
106
MEDIA_ROOT = os.path.join(PROJECT_PATH, "media/")
13✔
107

108
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
109
# trailing slash.
110
MEDIA_URL = "/media/"
13✔
111

112
# The maximum size of user uploaded images in bytes. If you use NGINX, note
113
# that also it needs to support at least this size.
114
MEDIA_MAX_SIZE = False
13✔
115
DATA_UPLOAD_MAX_MEMORY_SIZE = None
13✔
116

117
# Absolute path to the directory static files should be collected to.
118
# Don't put anything in this directory yourself; store your static files
119
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
120
# Example: "/home/media/media.lawrence.com/static/"
121
STATIC_ROOT = os.path.join(PROJECT_PATH, "static-collected/")
13✔
122

123
# URL prefix for static files.
124
# Example: "https://media.lawrence.com/static/"
125
STATIC_URL = "/static/"
13✔
126

127
# Additional locations of static files
128
STATICFILES_DIRS = (
13✔
129
    os.path.join(PROJECT_PATH, "static-transpile"),
130
    os.path.join(PROJECT_PATH, "static-libs"),
131
)
132

133
LOGIN_URL = "/"
13✔
134
SOCIALACCOUNT_LOGIN_ON_GET = True
13✔
135

136
# List of finder classes that know how to find static files in
137
# various locations.
138
STATICFILES_FINDERS = (
13✔
139
    "django.contrib.staticfiles.finders.FileSystemFinder",
140
    "django.contrib.staticfiles.finders.AppDirectoriesFinder",
141
    #    "django.contrib.staticfiles.finders.DefaultStorageFinder",
142
)
143

144
# Make this unique, and don't share it with anybody. Change the default string.
145
SECRET_KEY = "2ouq2zgw5y-@w+t6!#zf#-z1inigg7$lg3p%8e3kkob1bf$#p4"
13✔
146

147

148
# These middleware classes is what Fidus Writer needs in its standard setup.
149
# You only need to change this in very advanced setups.
150
BASE_MIDDLEWARE = [
13✔
151
    "django.middleware.common.CommonMiddleware",
152
    "django.contrib.sessions.middleware.SessionMiddleware",
153
    "django.middleware.csrf.CsrfViewMiddleware",
154
    "django.contrib.auth.middleware.AuthenticationMiddleware",
155
    "django.contrib.messages.middleware.MessageMiddleware",
156
    "django.middleware.locale.LocaleMiddleware",
157
    "allauth.account.middleware.AccountMiddleware",
158
]
159

160
MIDDLEWARE = []
13✔
161

162

163
# The location of the top urls.py file inside the base folder.
164
# You only need to change this in very advanced setups.
165
ROOT_URLCONF = "base.root_urls"
13✔
166

167
TEMPLATES = [
13✔
168
    {
169
        "BACKEND": "django.template.backends.django.DjangoTemplates",
170
        "DIRS": [
171
            os.path.join(PROJECT_PATH, "templates"),
172
            # Put strings here, like "/home/html/django_templates".
173
            # You only need to change this in very advanced setups.
174
        ],
175
        "APP_DIRS": True,
176
        "OPTIONS": {
177
            "context_processors": [
178
                "django.contrib.auth.context_processors.auth",
179
                "django.template.context_processors.debug",
180
                "django.template.context_processors.i18n",
181
                "django.template.context_processors.media",
182
                "django.template.context_processors.static",
183
                "django.template.context_processors.request",
184
                "django.template.context_processors.tz",
185
                "django.contrib.messages.context_processors.messages",
186
            ],
187
        },
188
    },
189
]
190

191

192
# The following are the apps needed by Fidus Writer.
193

194
BASE_INSTALLED_APPS = [
13✔
195
    "npm_mjs",
196
    "base",
197
    "daphne",
198
    "django.contrib.auth",
199
    "django.contrib.contenttypes",
200
    "django.contrib.sessions",
201
    "django.contrib.sites",
202
    "django.contrib.messages",
203
    "django.contrib.staticfiles",
204
    "django.contrib.admin",
205
    "django.contrib.admindocs",
206
    "django.contrib.flatpages",
207
    "channels",
208
    # "channels_presence",
209
    "django_js_error_hook",
210
    "loginas",
211
    "fixturemedia",
212
    "browser_check",
213
    "menu",
214
    "document",
215
    "bibliography",
216
    "usermedia",
217
    "user",
218
    "allauth",
219
    "allauth.account",
220
    "allauth.socialaccount",
221
    "avatar",
222
    "feedback",
223
    "style",
224
]
225

226
# These are additional apps to be overriden by configuration.py
227
INSTALLED_APPS = []
13✔
228

229
# These are apps that are removed from core apps overriden by configuration.py
230
REMOVED_APPS = []
13✔
231

232

233
AUTHENTICATION_BACKENDS = (
13✔
234
    # Needed to login by username in Django admin, regardless of `allauth`
235
    "django.contrib.auth.backends.ModelBackend",
236
    # `allauth` specific authentication methods, such as login by e-mail
237
    "allauth.account.auth_backends.AuthenticationBackend",
238
)
239

240
TEST_RUNNER = "django.test.runner.DiscoverRunner"
13✔
241
TESTING = False  # Overriden by test runner.
13✔
242

243

244
# Define available languages
245
# You only need to change this in very advanced setups.
246
def gettext(s):
13✔
247
    return s
13✔
248

249

250
LANGUAGES = (
13✔
251
    ("en", gettext("English")),
252
    ("bg", gettext("Bulgarian")),
253
    ("de", gettext("German")),
254
    ("fr", gettext("French")),
255
    ("it", gettext("Italian")),
256
    ("es", gettext("Spanish")),
257
    ("pt-br", gettext("Portuguese (Brazil)")),
258
)
259

260
LOGIN_REDIRECT_URL = "/"
13✔
261

262

263
# Allow users with login_as permission to log in as different user
264
def can_login_as(request, target_user):
13✔
265
    return request.user.has_perm("user.can_login_as")
×
266

267

268
CAN_LOGIN_AS = can_login_as
13✔
269

270
ACCOUNT_EMAIL_REQUIRED = True
13✔
271
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
13✔
272
ACCOUNT_DEFAULT_HTTP_PROTOCOL = "http"
13✔
273

274
# allow login either with email or username
275
ACCOUNT_AUTHENTICATION_METHOD = "username_email"
13✔
276
ACCOUNT_ADAPTER = "user.adapter.AccountAdapter"
13✔
277

278
AUTH_PROFILE_MODULE = "account.Profile"
13✔
279
AUTH_USER_MODEL = "user.User"
13✔
280

281
LOGGING = {
13✔
282
    "version": 1,
283
    "disable_existing_loggers": False,
284
    "filters": {
285
        "require_debug_false": {"()": "django.utils.log.RequireDebugFalse"}
286
    },
287
    "formatters": {
288
        "verbose": {
289
            "format": (
290
                "%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d "
291
                "%(message)s"
292
            )
293
        },
294
        "simple": {"format": "\033[22;32m%(levelname)s\033[0;0m %(message)s"},
295
    },
296
    "handlers": {
297
        "mail_admins": {
298
            "level": "ERROR",
299
            "filters": ["require_debug_false"],
300
            "class": "django.utils.log.AdminEmailHandler",
301
        },
302
        "console": {
303
            "level": "DEBUG",
304
            "class": "logging.StreamHandler",
305
            "formatter": "simple",
306
        },
307
        "null": {
308
            "class": "logging.NullHandler",
309
        },
310
    },
311
    "loggers": {
312
        "django.request": {
313
            "handlers": ["mail_admins"],
314
            "level": "ERROR",
315
            "propagate": True,
316
        },
317
        "django.security.DisallowedHost": {
318
            "handlers": ["null"],
319
            "propagate": False,
320
        },
321
        "javascript_error": {
322
            "handlers": ["mail_admins", "console"],
323
            "level": "ERROR",
324
            "propagate": True,
325
        },
326
    },
327
}
328

329
# Global variables for avatar
330
# You only need to change this in very advanced setups.
331
AVATAR_GRAVATAR_BACKUP = False
13✔
332
AVATAR_THUMB_FORMAT = "PNG"
13✔
333
AVATAR_DEFAULT_URL = "img/default_avatar.png"
13✔
334
AVATAR_DEFAULT_SIZE = 80
13✔
335
AVATAR_MAX_AVATARS_PER_USER = 1
13✔
336
AVATAR_CACHE_ENABLED = True
13✔
337

338

339
WEBSOCKET_PING_INTERVAL = 55
13✔
340

341
ADMIN_SITE_TITLE = gettext("Fidus Writer Admin")
13✔
342
ADMIN_SITE_HEADER = gettext("Fidus Writer Administration Site")
13✔
343
ADMIN_INDEX_TITLE = gettext("Welcome to the Fidus Writer Administration Site")
13✔
344

345
# The below allow login via JavaScript
346
SESSION_COOKIE_HTTPONLY = False
13✔
347
CSRF_COOKIE_HTTPONLY = False
13✔
348

349
# To make npm-mjs enable the webpack offline plugin
350
WEBPACK_CONFIG_TEMPLATE = os.path.join(
13✔
351
    os.path.dirname(os.path.realpath(__file__)), "webpack.config.template.js"
352
)
353

354
# JS error logging
355
JAVASCRIPT_ERROR_USERAGENT_BLACKLIST = ["googlebot", "bingbot", "cutycapt"]
13✔
356
JAVASCRIPT_ERROR_BLACKLIST = [
13✔
357
    "script error",
358
    "the operation is insecure",
359
    "parse error",
360
    "unhandledrejection, {}",
361
    "An unknown error occurred",
362
]
363

364
# The page to show while transpilation takes place.
365
SETUP_PAGE_PATH = os.path.join(SRC_PATH, "base/setup_page/")
13✔
366

367
# Whether to create a service worker on production sites
368
USE_SERVICE_WORKER = True
13✔
369

370

371
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
13✔
372
SILENCED_SYSTEM_CHECKS = ["models.W042"]
13✔
373

374
FOOTER_LINKS = []
13✔
375
BRANDING_LOGO = False
13✔
376

377
ASGI_APPLICATION = "base.routing.application"
13✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc