settings.py 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. # pylint: disable=line-too-long
  2. """
  3. Django settings for dev project.
  4. Generated by 'django-admin startproject' using Django 1.11.15.
  5. For more information on this file, see
  6. https://docs.djangoproject.com/en/1.11/topics/settings/
  7. For the full list of settings and their values, see
  8. https://docs.djangoproject.com/en/1.11/ref/settings/
  9. """
  10. import os
  11. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  12. BASE_DIR = os.path.dirname(os.path.abspath(__file__))
  13. # Define placeholder gettext function
  14. # This function will mark strings in settings visible to makemessages
  15. # without need for Django's i18n features be initialized first.
  16. _ = lambda s: s
  17. # Quick-start development settings - unsuitable for production
  18. # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
  19. # SECURITY WARNING: keep the secret key used in production secret!
  20. SECRET_KEY = "1znyfpwp*_#!r0#l248lht*6)_0b+504n*2-8cxf(2u)fhi0f^"
  21. # SECURITY WARNING: don't run with debug turned on in production!
  22. DEBUG = True
  23. # A list of strings representing the host/domain names that this Django site can serve.
  24. # If you are unsure, just enter here your domain name, eg. ['mysite.com', 'www.mysite.com']
  25. ALLOWED_HOSTS = []
  26. # Database
  27. # https://docs.djangoproject.com/en/1.11/ref/settings/#databases
  28. DATABASES = {
  29. "default": {
  30. # Misago requires PostgreSQL to run
  31. "ENGINE": "django.db.backends.postgresql",
  32. "NAME": os.environ.get("POSTGRES_DB"),
  33. "USER": os.environ.get("POSTGRES_USER"),
  34. "PASSWORD": os.environ.get("POSTGRES_PASSWORD"),
  35. "HOST": os.environ.get("POSTGRES_HOST"),
  36. "PORT": 5432,
  37. }
  38. }
  39. # Caching
  40. # https://docs.djangoproject.com/en/1.11/topics/cache/#setting-up-the-cache
  41. CACHES = {
  42. "default": {
  43. # Misago doesn't run well with LocMemCache in production environments
  44. "BACKEND": "django.core.cache.backends.locmem.LocMemCache"
  45. }
  46. }
  47. # Password validation
  48. # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
  49. AUTH_PASSWORD_VALIDATORS = [
  50. {
  51. "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
  52. "OPTIONS": {"user_attributes": ["username", "email"]},
  53. },
  54. {
  55. "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
  56. "OPTIONS": {"min_length": 7},
  57. },
  58. {"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
  59. {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
  60. ]
  61. # Internationalization
  62. # https://docs.djangoproject.com/en/1.11/topics/i18n/
  63. LANGUAGE_CODE = "en-us"
  64. TIME_ZONE = "UTC"
  65. USE_I18N = True
  66. USE_L10N = True
  67. USE_TZ = True
  68. # Static files (CSS, JavaScript, Images)
  69. # https://docs.djangoproject.com/en/1.11/howto/static-files/
  70. STATIC_URL = "/static/"
  71. # User uploads (Avatars, Attachments, files uploaded in other Django apps, ect.)
  72. # https://docs.djangoproject.com/en/1.11/howto/static-files/
  73. MEDIA_URL = "/media/"
  74. # The absolute path to the directory where collectstatic will collect static files for deployment.
  75. # https://docs.djangoproject.com/en/1.11/ref/settings/#static-root
  76. STATIC_ROOT = os.path.join(BASE_DIR, "static")
  77. # Absolute filesystem path to the directory that will hold user-uploaded files.
  78. # https://docs.djangoproject.com/en/1.11/ref/settings/#media-root
  79. MEDIA_ROOT = os.path.join(BASE_DIR, "media")
  80. # This setting defines the additional locations the staticfiles app will traverse if the FileSystemFinder finder
  81. # is enabled, e.g. if you use the collectstatic or findstatic management command or use the static file serving view.
  82. # https://docs.djangoproject.com/en/1.10/ref/settings/#staticfiles-dirs
  83. STATICFILES_DIRS = []
  84. # Email configuration
  85. # https://docs.djangoproject.com/en/1.11/ref/settings/#email-backend
  86. EMAIL_HOST = "localhost"
  87. EMAIL_PORT = 25
  88. # If either of these settings is empty, Django won't attempt authentication.
  89. EMAIL_HOST_USER = ""
  90. EMAIL_HOST_PASSWORD = ""
  91. # Default email address to use for various automated correspondence from the site manager(s).
  92. DEFAULT_FROM_EMAIL = "Forums <%s>" % EMAIL_HOST_USER
  93. # Application definition
  94. AUTH_USER_MODEL = "misago_users.User"
  95. AUTHENTICATION_BACKENDS = ["misago.users.authbackends.MisagoBackend"]
  96. CSRF_FAILURE_VIEW = "misago.core.errorpages.csrf_failure"
  97. INSTALLED_APPS = [
  98. # Misago overrides for Django core feature
  99. "misago",
  100. "misago.users",
  101. # Django apps
  102. "django.contrib.admin",
  103. "django.contrib.auth",
  104. "django.contrib.contenttypes",
  105. "django.contrib.postgres",
  106. "django.contrib.humanize",
  107. "django.contrib.sessions",
  108. "django.contrib.messages",
  109. "django.contrib.staticfiles",
  110. # 3rd party apps used by Misago
  111. "celery",
  112. "debug_toolbar",
  113. "mptt",
  114. "rest_framework",
  115. "social_django",
  116. # Misago apps
  117. "misago.admin",
  118. "misago.acl",
  119. "misago.cache",
  120. "misago.core",
  121. "misago.conf",
  122. "misago.themes",
  123. "misago.markup",
  124. "misago.legal",
  125. "misago.categories",
  126. "misago.threads",
  127. "misago.readtracker",
  128. "misago.search",
  129. "misago.graphql",
  130. "misago.faker",
  131. ]
  132. INTERNAL_IPS = ["127.0.0.1"]
  133. LOGIN_REDIRECT_URL = "misago:index"
  134. LOGIN_URL = "misago:login"
  135. LOGOUT_URL = "misago:logout"
  136. MIDDLEWARE = [
  137. "debug_toolbar.middleware.DebugToolbarMiddleware",
  138. "misago.users.middleware.RealIPMiddleware",
  139. "misago.core.middleware.FrontendContextMiddleware",
  140. "django.middleware.security.SecurityMiddleware",
  141. "django.contrib.sessions.middleware.SessionMiddleware",
  142. "django.middleware.common.CommonMiddleware",
  143. "django.middleware.csrf.CsrfViewMiddleware",
  144. "django.contrib.auth.middleware.AuthenticationMiddleware",
  145. "django.contrib.messages.middleware.MessageMiddleware",
  146. "django.middleware.clickjacking.XFrameOptionsMiddleware",
  147. "misago.cache.middleware.cache_versions_middleware",
  148. "misago.conf.middleware.dynamic_settings_middleware",
  149. "misago.users.middleware.UserMiddleware",
  150. "misago.acl.middleware.user_acl_middleware",
  151. "misago.core.middleware.ExceptionHandlerMiddleware",
  152. "misago.users.middleware.OnlineTrackerMiddleware",
  153. "misago.admin.middleware.AdminAuthMiddleware",
  154. "misago.threads.middleware.UnreadThreadsCountMiddleware",
  155. ]
  156. ROOT_URLCONF = "devproject.urls"
  157. SOCIAL_AUTH_PIPELINE = (
  158. # Steps required by social pipeline to work - don't delete those!
  159. "social_core.pipeline.social_auth.social_details",
  160. "social_core.pipeline.social_auth.social_uid",
  161. "social_core.pipeline.social_auth.social_user",
  162. # Uncomment next line to let your users to associate their old forum account with social one.
  163. # 'misago.users.social.pipeline.associate_by_email',
  164. # Those steps make sure banned users may not join your site or use banned name or email.
  165. "misago.users.social.pipeline.validate_ip_not_banned",
  166. "misago.users.social.pipeline.validate_user_not_banned",
  167. # Reads user data received from social site and tries to create valid and available username
  168. # Required if you want automatic account creation to work. Otherwhise optional.
  169. "misago.users.social.pipeline.get_username",
  170. # Uncomment next line to enable automatic account creation if data from social site is valid
  171. # and get_username found valid name for new user account:
  172. # 'misago.users.social.pipeline.create_user',
  173. # This step asks user to complete simple, pre filled registration form containing username,
  174. # email, legal note if you remove it without adding custom one, users will have no fallback
  175. # for joining your site using their social account.
  176. "misago.users.social.pipeline.create_user_with_form",
  177. # Steps finalizing social authentication flow - don't delete those!
  178. "social_core.pipeline.social_auth.associate_user",
  179. "social_core.pipeline.social_auth.load_extra_data",
  180. "misago.users.social.pipeline.require_activation",
  181. )
  182. SOCIAL_AUTH_POSTGRES_JSONFIELD = True
  183. TEMPLATES = [
  184. {
  185. "BACKEND": "django.template.backends.django.DjangoTemplates",
  186. "DIRS": [],
  187. "APP_DIRS": True,
  188. "OPTIONS": {
  189. "context_processors": [
  190. "django.template.context_processors.debug",
  191. "django.template.context_processors.i18n",
  192. "django.template.context_processors.media",
  193. "django.template.context_processors.request",
  194. "django.template.context_processors.static",
  195. "django.template.context_processors.tz",
  196. "django.contrib.auth.context_processors.auth",
  197. "django.contrib.messages.context_processors.messages",
  198. "misago.acl.context_processors.user_acl",
  199. "misago.conf.context_processors.conf",
  200. "misago.core.context_processors.misago_version",
  201. "misago.core.context_processors.site_address",
  202. "misago.core.context_processors.momentjs_locale",
  203. "misago.search.context_processors.search_providers",
  204. "misago.themes.context_processors.theme",
  205. "misago.legal.context_processors.legal_links",
  206. "misago.users.context_processors.user_links",
  207. # Data preloaders
  208. "misago.conf.context_processors.preload_settings_json",
  209. "misago.core.context_processors.current_link",
  210. "misago.markup.context_processors.preload_api_url",
  211. "misago.threads.context_processors.preload_threads_urls",
  212. "misago.users.context_processors.preload_user_json",
  213. # Note: keep frontend_context processor last for previous processors
  214. # to be able to expose data UI app via request.frontend_context
  215. "misago.core.context_processors.frontend_context",
  216. ]
  217. },
  218. }
  219. ]
  220. WSGI_APPLICATION = "devproject.wsgi.application"
  221. # Django Debug Toolbar
  222. # http://django-debug-toolbar.readthedocs.io/en/stable/configuration.html
  223. DEBUG_TOOLBAR_PANELS = [
  224. "debug_toolbar.panels.versions.VersionsPanel",
  225. "debug_toolbar.panels.timer.TimerPanel",
  226. "debug_toolbar.panels.settings.SettingsPanel",
  227. "debug_toolbar.panels.headers.HeadersPanel",
  228. "debug_toolbar.panels.request.RequestPanel",
  229. "debug_toolbar.panels.sql.SQLPanel",
  230. "misago.acl.panels.MisagoACLPanel",
  231. "debug_toolbar.panels.staticfiles.StaticFilesPanel",
  232. "debug_toolbar.panels.templates.TemplatesPanel",
  233. "debug_toolbar.panels.cache.CachePanel",
  234. "debug_toolbar.panels.signals.SignalsPanel",
  235. "debug_toolbar.panels.logging.LoggingPanel",
  236. ]
  237. # Django Rest Framework
  238. # http://www.django-rest-framework.org/api-guide/settings/
  239. REST_FRAMEWORK = {
  240. "DEFAULT_PERMISSION_CLASSES": [
  241. "misago.core.rest_permissions.IsAuthenticatedOrReadOnly"
  242. ],
  243. "DEFAULT_RENDERER_CLASSES": ["rest_framework.renderers.JSONRenderer"],
  244. "EXCEPTION_HANDLER": "misago.core.exceptionhandler.handle_api_exception",
  245. "UNAUTHENTICATED_USER": "misago.users.models.AnonymousUser",
  246. "URL_FORMAT_OVERRIDE": None,
  247. }
  248. # Celery - Distributed Task Queue
  249. # http://docs.celeryproject.org/en/latest/userguide/configuration.html
  250. # Configure Celery to use Redis as message broker.
  251. CELERY_BROKER_URL = "redis://redis:6379/0"
  252. # Celery workers may leak the memory, eventually depriving the instance of resources.
  253. # This setting forces celery to stop worker, clean after it and create new one
  254. # after worker has processed 10 tasks.
  255. CELERY_WORKER_MAX_TASKS_PER_CHILD = 10
  256. # Misago specific settings
  257. # https://misago.readthedocs.io/en/latest/developers/settings.html
  258. # Complete HTTP address to your Misago site homepage. Misago relies on this address to create
  259. # links in e-mails that are sent to site users.
  260. # On Misago admin panel home page you will find a message telling you if you have entered the
  261. # correct value, or what value is correct in case you've didn't.
  262. MISAGO_ADDRESS = "http://my-misago-site.com/"
  263. # On dev instance, generate only three sizes of avatars instead of default 6 sizes.
  264. MISAGO_AVATARS_SIZES = [400, 200, 100]
  265. # PostgreSQL text search configuration to use in searches
  266. # Defaults to "simple", for list of installed configurations run "\dF" in "psql".
  267. # Standard configs as of PostgreSQL 9.5 are: dutch, english, finnish, french,
  268. # german, hungarian, italian, norwegian, portuguese, romanian, russian, simple,
  269. # spanish, swedish and turkish
  270. # Example on adding custom language can be found here: https://github.com/lemonskyjwt/plpstgrssearch
  271. MISAGO_SEARCH_CONFIG = "simple"
  272. # Allow users to download their personal data
  273. # Enables users to learn what data about them is being held by the site without having
  274. # to contact site's administrators.
  275. MISAGO_ENABLE_DOWNLOAD_OWN_DATA = True
  276. # Path to the directory that Misago should use to prepare user data downloads.
  277. # Should not be accessible from internet.
  278. MISAGO_USER_DATA_DOWNLOADS_WORKING_DIR = os.path.join(BASE_DIR, "userdata")
  279. # Allow users to delete their accounts
  280. # Lets users delete their own account on the site without having to contact site administrators.
  281. # This mechanism doesn't delete user posts, polls or attachments, but attempts to anonymize any
  282. # data about user left behind after user is deleted.
  283. MISAGO_ENABLE_DELETE_OWN_ACCOUNT = True
  284. # Automatically delete new user accounts that weren't activated in specified time
  285. # If you rely on admin review of new registrations, make this period long, disable
  286. # the "deleteinactiveusers" management command, or change this value to zero. Otherwise
  287. # keep it short to give users a chance to retry on their own after few days pass.
  288. MISAGO_DELETE_NEW_INACTIVE_USERS_OLDER_THAN_DAYS = 2
  289. # Path to directory containing avatar galleries
  290. # Those galleries can be loaded by running loadavatargallery command
  291. MISAGO_AVATAR_GALLERY = os.path.join(BASE_DIR, "avatargallery")
  292. # Specifies the number of days that IP addresses are stored in the database before removing.
  293. # Change this setting to None to never remove old IP addresses.
  294. MISAGO_IP_STORE_TIME = 50
  295. # Profile fields
  296. MISAGO_PROFILE_FIELDS = [
  297. {
  298. "name": _("Personal"),
  299. "fields": [
  300. "misago.users.profilefields.default.RealNameField",
  301. "misago.users.profilefields.default.GenderField",
  302. "misago.users.profilefields.default.BioField",
  303. "misago.users.profilefields.default.LocationField",
  304. ],
  305. },
  306. {
  307. "name": _("Contact"),
  308. "fields": [
  309. "misago.users.profilefields.default.TwitterHandleField",
  310. "misago.users.profilefields.default.SkypeIdField",
  311. "misago.users.profilefields.default.WebsiteField",
  312. ],
  313. },
  314. {
  315. "name": _("IP address"),
  316. "fields": ["misago.users.profilefields.default.JoinIpField"],
  317. },
  318. ]
  319. # Set dev instance to send e-mails to console
  320. EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
  321. # Display debug toolbar if IN_MISAGO_DOCKER enviroment var is set to "1"
  322. DEBUG_TOOLBAR_CONFIG = {
  323. "SHOW_TOOLBAR_CALLBACK": "misago.conf.debugtoolbar.enable_debug_toolbar"
  324. }