-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.example.py
635 lines (550 loc) · 18.8 KB
/
settings.example.py
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
"""isharmud Django settings."""
from os import getenv
from pathlib import Path
from pymysql import install_as_MySQLdb
from django.core.management.utils import get_random_secret_key
# Set up MySQL.
install_as_MySQLdb()
# Build project path(s).
BASE_DIR = Path(__file__).resolve().parent.parent
# Django secret key.
SECRET_KEY = getenv("DJANGO_SECRET_KEY", get_random_secret_key())
# Debug.
DEBUG = bool(getenv("DJANGO_DEBUG", False))
# Allowed hosts.
ALLOWED_HOSTS = (BASE_DIR.name,)
# Website title.
WEBSITE_TITLE = "Ishar MUD"
WEBSITE_TITLES = {
"isharmud.com": "",
"staging.isharmud.com": " TEST",
"127.0.0.1": " LOCAL",
"::1": " LOCAL",
"[::1]": " LOCAL",
"localhost": " LOCAL",
None: " NONE"
}
WEBSITE_TITLE += WEBSITE_TITLES.get(ALLOWED_HOSTS[0], WEBSITE_TITLES[None])
# Caching.
DJANGO_CACHE_KEY = BASE_DIR.stem
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.filebased.FileBasedCache",
"LOCATION": Path(BASE_DIR, "cache"),
"TIMEOUT": 60,
"OPTIONS": {"MAX_ENTRIES": 1000},
},
DJANGO_CACHE_KEY: {
"BACKEND": "django.core.cache.backends.filebased.FileBasedCache",
"LOCATION": Path(BASE_DIR, "cache", DJANGO_CACHE_KEY),
"TIMEOUT": 300,
"OPTIONS": {"MAX_ENTRIES": 1000},
}
}
CACHE_MIDDLEWARE_ALIAS = DJANGO_CACHE_KEY
CACHE_MIDDLEWARE_SECONDS = 300
CACHE_MIDDLEWARE_KEY_PREFIX = f"{DJANGO_CACHE_KEY}_"
# Database(s).
DATABASES = {
# Staging.
"staging.isharmud.com": {
"ENGINE": "apps.core.backends",
"NAME": "ishar_test",
"USER": "ishar_test",
"PASSWORD": "secret",
"HOST": "127.0.0.1",
"PORT": 3306
},
# Production
"isharmud.com": {
"ENGINE": "apps.core.backends",
"NAME": "ishar",
"USER": "ishar",
"PASSWORD": "secret",
"HOST": "127.0.0.1",
"PORT": 3306
}
}
DATABASES["default"] = DATABASES[ALLOWED_HOSTS[0]]
# Default primary key field type.
DEFAULT_AUTO_FIELD = "apps.core.models.unsigned.UnsignedAutoField"
# CSRF and session cookies.
CSRF_COOKIE_DOMAIN = SESSION_COOKIE_DOMAIN = ALLOWED_HOSTS[0]
CSRF_COOKIE_HTTPONLY = SESSION_COOKIE_HTTPONLY = False
CSRF_COOKIE_SAMESITE = SESSION_COOKIE_SAMESITE = "Strict"
CSRF_COOKIE_SECURE = SESSION_COOKIE_SECURE = True
CSRF_TRUSTED_ORIGINS = (f"https://{ALLOWED_HOSTS[0]}",)
# E-mail.
ADMIN_EMAIL = f"admin@{ALLOWED_HOSTS[0]}"
ADMINS = MANAGERS = (
(f"{WEBSITE_TITLE} Administrator", ADMIN_EMAIL),
)
DEFAULT_FROM_EMAIL = SERVER_EMAIL = ADMIN_EMAIL
EMAIL_SUBJECT_PREFIX = f"{WEBSITE_TITLE} ({ALLOWED_HOSTS[0]}) [Django]: "
EMAIL_HOST = "127.0.0.1"
EMAIL_PORT = 25
EMAIL_HOST_USER = EMAIL_HOST_PASSWORD = None
# Application definition.
INSTALLED_APPS = [
"jazzmin",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.humanize",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.sites",
"django.contrib.staticfiles",
"apps.CoreConfig",
"apps.AccountsConfig",
"apps.AchievementsConfig",
"apps.ChallengesConfig",
"apps.ClassesConfig",
"apps.ClientsConfig",
"apps.DiscordConfig",
"apps.EventsConfig",
"apps.FAQsConfig",
"apps.FeedbackConfig",
"apps.HelpConfig",
"apps.HistoryConfig",
"apps.LeadersConfig",
"apps.MobilesConfig",
"apps.NewsConfig",
"apps.ObjectsConfig",
"apps.PatchesConfig",
"apps.PlayersConfig",
"apps.ProcessesConfig",
"apps.QuestsConfig",
"apps.RacesConfig",
"apps.SeasonsConfig",
"apps.SkillsConfig"
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.cache.UpdateCacheMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.cache.FetchFromCacheMiddleware",
"django.middleware.locale.LocaleMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
ROOT_URLCONF = "urls"
SITE_ID = 0
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": (Path(BASE_DIR, "ishar/templates/base"),),
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"apps.core.contexts.admin_email",
"apps.core.contexts.website_title",
"apps.events.contexts.global_event_count",
"apps.help.contexts.help_search_form",
"apps.players.contexts.player_search_form",
"apps.seasons.contexts.current_season",
],
# "libraries": {
# "ishar": "apps.core.templatetags"
# }
},
},
]
WSGI_APPLICATION = "wsgi.application"
# Authentication.
AUTH_PASSWORD_VALIDATORS = [
{"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"},
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"},
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"}
]
AUTH_USER_MODEL = "accounts.Account"
AUTHENTICATION_BACKENDS = ("apps.accounts.backends.IsharUserAuthBackend",)
LOGIN_URL = "/login/"
LOGIN_REDIRECT_URL = "/portal/"
LOGOUT_URL = "/logout/"
# Logging.
LOGGING_ROOT = Path(BASE_DIR, "logs/")
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"filters": {
"require_debug_false": {
"()": "django.utils.log.RequireDebugFalse",
},
"require_debug_true": {
"()": "django.utils.log.RequireDebugTrue",
},
},
"formatters": {
"verbose": {
"datefmt": "%Y-%m-%d %H:%M:%S %Z",
"format": "{asctime} [{levelname}] {message}",
"style": "{",
},
"django.server": {
"()": "django.utils.log.ServerFormatter",
"format": "[{server_time}] {message}",
"style": "{",
}
},
"handlers": {
"console": {
"level": "INFO",
"class": "logging.StreamHandler",
"formatter": "verbose",
},
"discord": {
"level": "INFO",
"filters": ["require_debug_false"],
"class": "logging.FileHandler",
"filename": Path(LOGGING_ROOT, "discord.log"),
"formatter": "verbose",
},
"django.server": {
"level": "INFO",
"class": "logging.StreamHandler",
"formatter": "django.server",
},
"mail_admins": {
"level": "ERROR",
"filters": ["require_debug_false"],
"class": "django.utils.log.AdminEmailHandler",
},
"error_log": {
"level": "ERROR",
"class": "logging.FileHandler",
"filename": Path(LOGGING_ROOT, "errors.log"),
"formatter": "verbose",
},
},
"loggers": {
"discord": {
"handlers": ["console", "discord"],
"level": "INFO",
},
"django": {
"handlers": ["console", "mail_admins", "error_log"],
"level": "INFO",
},
"django.server": {
"handlers": ["django.server"],
"level": "INFO",
"propagate": False,
},
},
}
# Internationalization.
LANGUAGE_CODE = "en-us"
TIME_ZONE = "UTC"
USE_I18N = True
USE_THOUSAND_SEPARATOR = True
USE_TZ = True
# Static.
STATIC_URL = "static/"
STATIC_ROOT = Path(BASE_DIR, STATIC_URL)
# Media.
MEDIA_URL = "media/"
MEDIA_ROOT = Path(BASE_DIR, MEDIA_URL)
PATCHES_URL = "patches/"
# Discord.
DISCORD = {
"APPLICATION_ID": "EXAMPLE",
"GUILD": "EXAMPLE",
"PUBLIC_KEY": "EXAMPLE",
"TOKEN": "SECRET",
"URL": "https://discord.com/invite/VBmMXUpeve"
}
# MUD files.
MUD_HOME = Path(Path.home(), "ishar-mud")
HELPTAB = Path(MUD_HOME, "lib/Misc/helptab")
# Alignments.
ALIGNMENTS = {
"Very Evil": (-1500, -1000),
"Evil": (-1000, -500),
"Slightly Evil": (-500, -250),
"Neutral": (-250, 250),
"Slightly Good": (250, 500),
"Good": (500, 1000),
"Very Good": (1000, 1500)
}
# Order of statistics for each player class.
CLASS_STATISTICS = {
"Warrior": (
"Strength", "Agility", "Endurance", "Willpower", "Focus",
"Perception"
),
"Rogue": (
"Agility", "Perception", "Strength", "Focus", "Endurance",
"Willpower"
),
"Cleric": (
"Willpower", "Strength", "Perception", "Endurance", "Focus",
"Agility"
),
"Magician": (
"Perception", "Focus", "Agility", "Willpower", "Endurance",
"Strength"
),
"Necromancer": (
"Focus", "Willpower", "Perception", "Agility", "Strength",
"Endurance"
),
"Shaman": (
"Willpower", "Agility", "Endurance", "Focus", "Perception",
"Strength",
),
# Alphabetic as last resort
None: (
"Agility", "Endurance", "Focus", "Perception", "Strength",
"Willpower"
)
}
# Player immortal levels/types.
IMMORTAL_LEVELS = (
(26, "God"),
(25, "Forger"),
(24, "Eternal"),
(23, "Artisan"),
(22, "Immortal"),
(21, "Consort"),
)
MIN_IMMORTAL_LEVEL = min(IMMORTAL_LEVELS)[0]
MAX_IMMORTAL_LEVEL = max(IMMORTAL_LEVELS)[0]
CONNECT_URL = f"https://mudslinger.net/play/?host={ALLOWED_HOSTS[0]}&port=23"
X_FRAME_OPTIONS = "SAMEORIGIN"
JAZZMIN_SETTINGS = {
# title of the window (Will default to current_admin_site.site_title if absent or None)
"site_title": None,
# Title on the login screen (19 chars max) (defaults to current_admin_site.site_header if absent or None)
"site_header": None,
# Title on the brand (19 chars max) (defaults to current_admin_site.site_header if absent or None)
"site_brand": None,
# Logo to use for your site, must be present in static files, used for brand on top left
"site_logo": "images/logo.png",
# Logo to use for your site, must be present in static files, used for login form logo (defaults to site_logo)
"login_logo": "images/favicon.png",
# Logo to use for login form in dark themes (defaults to login_logo)
"login_logo_dark": None,
# CSS classes that are applied to the logo above
"site_logo_classes": "",
# Relative path to a favicon for your site, will default to site_logo if absent (ideally 32x32 px)
"site_icon": "images/favicon.png",
# Welcome text on the login screen
"welcome_sign": "",
# Copyright on the footer
"copyright": "IsharMUD",
# List of model admins to search from the search bar, search bar omitted if excluded
# If you want to use a single search field you dont need to use a list, you can use a simple string
"search_model": [
"accounts.Account",
"mobiles.Mobile",
"objects.Object",
"quests.Quest",
"skills.Skill"
],
# Field name on user model that contains avatar ImageField/URLField/Charfield or a callable that receives the user
"user_avatar": "get_gravatar",
############
# Top Menu #
############
# Links to put along the top menu
"topmenu_links": [
# Url that gets reversed (Permissions can be added)
# {"name": "Home", "url": "admin:index", "permissions": ["auth.view_user"]},
{"name": "Home", "url": "admin:index"},
# external url that opens in a new window (Permissions can be added)
# {"name": "Support", "url": "https://github.com/farridav/django-jazzmin/issues", "new_window": True},
# model admin to link to (Permissions checked against model)
# {"model": "accounts.Account"},
# App with dropdown menu to all its models pages (Permissions checked against models)
# {"app": "classes"},
],
#############
# User Menu #
#############
# Additional links to include in the user menu on the top right ("app" url type is not allowed)
"usermenu_links": [
{"name": WEBSITE_TITLE, "url": "index", "new_window": True},
{"name": "Source Code", "url": "https://github.com/IsharMud/ishar-web/", "new_window": True},
{"name": f"Support {WEBSITE_TITLE}", "url": "support", "new_window": True},
# {"model": "accounts.Account"}
],
#############
# Side Menu #
#############
# Whether to display the side menu
"show_sidebar": True,
# Whether to aut expand the menu
"navigation_expanded": True,
# Hide these apps when generating side menu e.g (auth)
"hide_apps": [],
# Hide these models when generating side menu (e.g auth.user)
"hide_models": [],
# List of apps (and/or models) to base side menu ordering off of (does not need to contain all apps/models)
"order_with_respect_to": ["accounts",],
# Custom links to append to app groups, keyed on app name
"custom_links": {
# "books": [{
# "name": "Make Messages",
# "url": "make_messages",
# "icon": "fas fa-comments",
# "permissions": ["books.view_book"]
# }]
},
# Custom icons for side menu apps/models
# See https://fontawesome.com/icons?d=gallery&m=free&v=5.0.0,5.0.1,5.0.10,5.0.11,5.0.12,5.0.13,5.0.2,5.0.3,5.0.4,5.0.5,5.0.6,5.0.7,5.0.8,5.0.9,5.1.0,5.1.1,5.2.0,5.3.0,5.3.1,5.4.0,5.4.1,5.4.2,5.13.0,5.12.0,5.11.2,5.11.1,5.10.0,5.9.0,5.8.2,5.8.1,5.7.2,5.7.1,5.7.0,5.6.3,5.5.0,5.4.2
# for the full list of 5.13.0 free icon classes
"icons": {
# accounts
"accounts.Account": "fas fa-user",
"accounts.AccountUpgrade": "fas fa-arrow-up",
# achievements
"achievements.Achievement": "fas fa-mountain",
"achievements.AchievementClassRestrict": "fas fa-not-equal",
"achievements.AchievementCriteria": "fas fa-table",
"achievements.AchievementReward": "fas fa-award",
"achievements.AchievementTrigger": "fas fa-stopwatch",
# challenges
"challenges.Challenge": "fas fa-award",
# classes
"classes": "fas fa-people-group",
"classes.Class": "fas fa-user",
"classes.ClassLevel": "fas fa-arrow-up",
"classes.ClassRace": "fas fa-user",
"classes.ClassSkill": "fas fa-brain",
# (MUD) clients
"clients.MUDClient": "fas fa-terminal",
"clients.MUDClientCategory": "fas fa-folder",
# core
"core": "fas fa-flag",
"core.PlayerFlag": "fas fa-flag",
"core.AffectFlag": "fas fa-flag",
"core.Title": "fas fa-tag",
# events
"events.GlobalEvent": "fas fa-calendar",
# faqs
"faqs.FAQ": "fas fa-question",
# feedback
"feedback": "fas fa-flag",
"feedback.FeedbackSubmission": "fas fa-flag",
"feedback.FeedbackVote": "fas fa-person-booth",
# history
"history": "fas fa-monument",
"history.HistoricSeasonStat": "fas fa-monument",
# mobiles
"mobiles": "fas fa-skull",
"mobiles.Mobile": "fas fa-skull",
# news
"news": "fas fa-newspaper",
"news.News": "fas fa-newspaper",
# objects
"objects": "fas fa-object-group",
"objects.Artifact": "fas fa-cross",
"objects.Object": "fas fa-object-group",
"objects.ObjectAffectFlag": "fas fa-flag",
"objects.ObjectExtra": "fas fa-diagram-project",
"objects.ObjectFlag": "fas fa-flag",
"objects.ObjectMod": "fas fa-vector-square",
"objects.ObjectObjectMod": "fas fa-draw-polygon",
"objects.ObjectWearableFlag": "fas fa-flag",
"objects.Relic": "fas fa-ankh",
# patches
"patches": "fas fa-file-pdf",
"patches.Patch": "fas fa-file-pdf",
# processes
"processes": "fas fa-microchip",
"processes.MUDProcess": "fas fa-microchip",
# players
"players": "fas fa-users-cog",
"players.Player": "fas fa-user",
"players.Immortal": "fas fa-user-shield",
"players.RemortUpgrade": "fas fa-arrow-up",
"players.PlayerObject": "fas fa-object-group",
# quests
"quests.Quest": "fas fa-mountain",
"quests.QuestReward": "fas fa-award",
# races
"races": "fas fa-people",
"races.Race": "fas fa-user",
"races.RaceAffinity": "fas fa-brain",
# season
"seasons.Season": "fas fa-tree",
# sites
"django.contrib.sites": "fas fa-sitemap",
# skills
"skills.SpellFlag": "fas fa-flag",
"skills.Force": "fas fa-infinity",
"skills.Skill": "fas fa-brain",
},
# Icons that are used when one is not manually specified
"default_icon_parents": "fas fa-chevron-circle-right",
"default_icon_children": "fas fa-circle",
#################
# Related Modal #
#################
# Use modals instead of popups
"related_modal_active": False,
#############
# UI Tweaks #
#############
# Relative paths to custom CSS/JS scripts (must be present in static files)
"custom_css": None,
"custom_js": None,
# Whether to link font from fonts.googleapis.com (use custom_css to supply font otherwise)
"use_google_fonts_cdn": True,
# Whether to show the UI customizer on the sidebar
"show_ui_builder": True,
###############
# Change view #
###############
# Render out the change view as a single form, or in tabs, current options are
# - single
# - horizontal_tabs (default)
# - vertical_tabs
# - collapsible
# - carousel
"changeform_format": "horizontal_tabs",
# override change forms on a per modeladmin basis
# "changeform_format_overrides": {"auth.user": "collapsible", "auth.group": "vertical_tabs"},
# Add a language dropdown into the admin
"language_chooser": False,
}
JAZZMIN_UI_TWEAKS = {
"navbar_small_text": False,
"footer_small_text": False,
"body_small_text": True,
"brand_small_text": False,
"brand_colour": False,
"accent": "accent-primary",
"navbar": "navbar-white navbar-light",
"no_navbar_border": False,
"navbar_fixed": False,
"layout_boxed": False,
"footer_fixed": False,
"sidebar_fixed": False,
"sidebar": "sidebar-dark-primary",
"sidebar_nav_small_text": False,
"sidebar_disable_expand": False,
"sidebar_nav_child_indent": False,
"sidebar_nav_compact_style": False,
"sidebar_nav_legacy_style": False,
"sidebar_nav_flat_style": False,
"theme": "cerulean",
"dark_mode_theme": None,
"button_classes": {
"primary": "btn-primary",
"secondary": "btn-secondary",
"info": "btn-info",
"warning": "btn-warning",
"danger": "btn-danger",
"success": "btn-success"
}
}