settings.py 14 KB

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