settings.py 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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': {
  52. 'user_attributes': ['username', 'email'],
  53. }
  54. },
  55. {
  56. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  57. 'OPTIONS': {
  58. 'min_length': 7,
  59. }
  60. },
  61. {
  62. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  63. },
  64. {
  65. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  66. },
  67. ]
  68. # Internationalization
  69. # https://docs.djangoproject.com/en/1.11/topics/i18n/
  70. LANGUAGE_CODE = 'en-us'
  71. TIME_ZONE = 'UTC'
  72. USE_I18N = True
  73. USE_L10N = True
  74. USE_TZ = True
  75. # Static files (CSS, JavaScript, Images)
  76. # https://docs.djangoproject.com/en/1.11/howto/static-files/
  77. STATIC_URL = '/static/'
  78. # User uploads (Avatars, Attachments, files uploaded in other Django apps, ect.)
  79. # https://docs.djangoproject.com/en/1.11/howto/static-files/
  80. MEDIA_URL = '/media/'
  81. # The absolute path to the directory where collectstatic will collect static files for deployment.
  82. # https://docs.djangoproject.com/en/1.11/ref/settings/#static-root
  83. STATIC_ROOT = os.path.join(BASE_DIR, 'static')
  84. # Absolute filesystem path to the directory that will hold user-uploaded files.
  85. # https://docs.djangoproject.com/en/1.11/ref/settings/#media-root
  86. MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
  87. # This setting defines the additional locations the staticfiles app will traverse if the FileSystemFinder finder
  88. # is enabled, e.g. if you use the collectstatic or findstatic management command or use the static file serving view.
  89. # https://docs.djangoproject.com/en/1.10/ref/settings/#staticfiles-dirs
  90. STATICFILES_DIRS = []
  91. # Email configuration
  92. # https://docs.djangoproject.com/en/1.11/ref/settings/#email-backend
  93. EMAIL_HOST = 'localhost'
  94. EMAIL_PORT = 25
  95. # If either of these settings is empty, Django won't attempt authentication.
  96. EMAIL_HOST_USER = ''
  97. EMAIL_HOST_PASSWORD = ''
  98. # Default email address to use for various automated correspondence from the site manager(s).
  99. DEFAULT_FROM_EMAIL = 'Forums <%s>' % EMAIL_HOST_USER
  100. # Application definition
  101. AUTH_USER_MODEL = 'misago_users.User'
  102. AUTHENTICATION_BACKENDS = [
  103. 'misago.users.authbackends.MisagoBackend',
  104. ]
  105. CSRF_FAILURE_VIEW = 'misago.core.errorpages.csrf_failure'
  106. INSTALLED_APPS = [
  107. # Misago overrides for Django core feature
  108. 'misago',
  109. 'misago.users',
  110. # Django apps
  111. 'django.contrib.admin',
  112. 'django.contrib.auth',
  113. 'django.contrib.contenttypes',
  114. 'django.contrib.postgres',
  115. 'django.contrib.humanize',
  116. 'django.contrib.sessions',
  117. 'django.contrib.messages',
  118. 'django.contrib.staticfiles',
  119. # 3rd party apps used by Misago
  120. 'debug_toolbar',
  121. 'mptt',
  122. 'rest_framework',
  123. 'social_django',
  124. # Misago apps
  125. 'misago.admin',
  126. 'misago.acl',
  127. 'misago.cache',
  128. 'misago.core',
  129. 'misago.conf',
  130. 'misago.markup',
  131. 'misago.legal',
  132. 'misago.categories',
  133. 'misago.threads',
  134. 'misago.readtracker',
  135. 'misago.search',
  136. 'misago.faker',
  137. ]
  138. INTERNAL_IPS = [
  139. '127.0.0.1'
  140. ]
  141. LOGIN_REDIRECT_URL = 'misago:index'
  142. LOGIN_URL = 'misago:login'
  143. LOGOUT_URL = 'misago:logout'
  144. MIDDLEWARE = [
  145. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  146. 'misago.users.middleware.RealIPMiddleware',
  147. 'misago.core.middleware.FrontendContextMiddleware',
  148. 'django.middleware.security.SecurityMiddleware',
  149. 'django.contrib.sessions.middleware.SessionMiddleware',
  150. 'django.middleware.common.CommonMiddleware',
  151. 'django.middleware.csrf.CsrfViewMiddleware',
  152. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  153. 'django.contrib.messages.middleware.MessageMiddleware',
  154. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  155. 'misago.cache.middleware.cache_versions_middleware',
  156. 'misago.users.middleware.UserMiddleware',
  157. 'misago.acl.middleware.user_acl_middleware',
  158. 'misago.core.middleware.ExceptionHandlerMiddleware',
  159. 'misago.users.middleware.OnlineTrackerMiddleware',
  160. 'misago.admin.middleware.AdminAuthMiddleware',
  161. 'misago.threads.middleware.UnreadThreadsCountMiddleware',
  162. 'misago.core.middleware.ThreadStoreMiddleware',
  163. ]
  164. ROOT_URLCONF = 'devproject.urls'
  165. SOCIAL_AUTH_PIPELINE = (
  166. # Steps required by social pipeline to work - don't delete those!
  167. 'social_core.pipeline.social_auth.social_details',
  168. 'social_core.pipeline.social_auth.social_uid',
  169. 'social_core.pipeline.social_auth.social_user',
  170. # Uncomment next line to let your users to associate their old forum account with social one.
  171. # 'misago.users.social.pipeline.associate_by_email',
  172. # Those steps make sure banned users may not join your site or use banned name or email.
  173. 'misago.users.social.pipeline.validate_ip_not_banned',
  174. 'misago.users.social.pipeline.validate_user_not_banned',
  175. # Reads user data received from social site and tries to create valid and available username
  176. # Required if you want automatic account creation to work. Otherwhise optional.
  177. 'misago.users.social.pipeline.get_username',
  178. # Uncomment next line to enable automatic account creation if data from social site is valid
  179. # and get_username found valid name for new user account:
  180. # 'misago.users.social.pipeline.create_user',
  181. # This step asks user to complete simple, pre filled registration form containing username,
  182. # email, legal note if you remove it without adding custom one, users will have no fallback
  183. # for joining your site using their social account.
  184. 'misago.users.social.pipeline.create_user_with_form',
  185. # Steps finalizing social authentication flow - don't delete those!
  186. 'social_core.pipeline.social_auth.associate_user',
  187. 'social_core.pipeline.social_auth.load_extra_data',
  188. 'misago.users.social.pipeline.require_activation',
  189. )
  190. SOCIAL_AUTH_POSTGRES_JSONFIELD = True
  191. TEMPLATES = [
  192. {
  193. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  194. 'DIRS': [],
  195. 'APP_DIRS': True,
  196. 'OPTIONS': {
  197. 'context_processors': [
  198. 'django.template.context_processors.debug',
  199. 'django.template.context_processors.i18n',
  200. 'django.template.context_processors.media',
  201. 'django.template.context_processors.request',
  202. 'django.template.context_processors.static',
  203. 'django.template.context_processors.tz',
  204. 'django.contrib.auth.context_processors.auth',
  205. 'django.contrib.messages.context_processors.messages',
  206. 'misago.acl.context_processors.user_acl',
  207. 'misago.conf.context_processors.settings',
  208. 'misago.core.context_processors.site_address',
  209. 'misago.core.context_processors.momentjs_locale',
  210. 'misago.legal.context_processors.legal_links',
  211. 'misago.search.context_processors.search_providers',
  212. 'misago.users.context_processors.user_links',
  213. # Data preloaders
  214. 'misago.conf.context_processors.preload_settings_json',
  215. 'misago.core.context_processors.current_link',
  216. 'misago.markup.context_processors.preload_api_url',
  217. 'misago.threads.context_processors.preload_threads_urls',
  218. 'misago.users.context_processors.preload_user_json',
  219. # Note: keep frontend_context processor last for previous processors
  220. # to be able to expose data UI app via request.frontend_context
  221. 'misago.core.context_processors.frontend_context',
  222. ],
  223. },
  224. },
  225. ]
  226. WSGI_APPLICATION = 'devproject.wsgi.application'
  227. # Django Debug Toolbar
  228. # http://django-debug-toolbar.readthedocs.io/en/stable/configuration.html
  229. DEBUG_TOOLBAR_PANELS = [
  230. 'debug_toolbar.panels.versions.VersionsPanel',
  231. 'debug_toolbar.panels.timer.TimerPanel',
  232. 'debug_toolbar.panels.settings.SettingsPanel',
  233. 'debug_toolbar.panels.headers.HeadersPanel',
  234. 'debug_toolbar.panels.request.RequestPanel',
  235. 'debug_toolbar.panels.sql.SQLPanel',
  236. 'misago.acl.panels.MisagoACLPanel',
  237. 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
  238. 'debug_toolbar.panels.templates.TemplatesPanel',
  239. 'debug_toolbar.panels.cache.CachePanel',
  240. 'debug_toolbar.panels.signals.SignalsPanel',
  241. 'debug_toolbar.panels.logging.LoggingPanel',
  242. ]
  243. # Django Rest Framework
  244. # http://www.django-rest-framework.org/api-guide/settings/
  245. REST_FRAMEWORK = {
  246. 'DEFAULT_PERMISSION_CLASSES': [
  247. 'misago.core.rest_permissions.IsAuthenticatedOrReadOnly',
  248. ],
  249. 'DEFAULT_RENDERER_CLASSES': [
  250. 'rest_framework.renderers.JSONRenderer',
  251. ],
  252. 'EXCEPTION_HANDLER': 'misago.core.exceptionhandler.handle_api_exception',
  253. 'UNAUTHENTICATED_USER': 'misago.users.models.AnonymousUser',
  254. 'URL_FORMAT_OVERRIDE': None,
  255. }
  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. # PostgreSQL text search configuration to use in searches
  264. # Defaults to "simple", for list of installed configurations run "\dF" in "psql".
  265. # Standard configs as of PostgreSQL 9.5 are: dutch, english, finnish, french,
  266. # german, hungarian, italian, norwegian, portuguese, romanian, russian, simple,
  267. # spanish, swedish and turkish
  268. # Example on adding custom language can be found here: https://github.com/lemonskyjwt/plpstgrssearch
  269. MISAGO_SEARCH_CONFIG = 'simple'
  270. # Allow users to download their personal data
  271. # Enables users to learn what data about them is being held by the site without having to contact
  272. # site's administrators.
  273. MISAGO_ENABLE_DOWNLOAD_OWN_DATA = True
  274. # Path to the directory that Misago should use to prepare user data downloads.
  275. # Should not be accessible from internet.
  276. MISAGO_USER_DATA_DOWNLOADS_WORKING_DIR = os.path.join(BASE_DIR, 'userdata')
  277. # Allow users to delete their accounts
  278. # Lets users delete their own account on the site without having to contact site administrators.
  279. # This mechanism doesn't delete user posts, polls or attachments, but attempts to anonymize any
  280. # data about user left behind after user is deleted.
  281. MISAGO_ENABLE_DELETE_OWN_ACCOUNT = True
  282. # Automatically delete new user accounts that weren't activated in specified time
  283. # If you rely on admin review of new registrations, make this period long, disable
  284. # the "deleteinactiveusers" management command, or change this value to zero. Otherwise
  285. # keep it short to give users a chance to retry on their own after few days pass.
  286. MISAGO_DELETE_NEW_INACTIVE_USERS_OLDER_THAN_DAYS = 2
  287. # Path to directory containing avatar galleries
  288. # Those galleries can be loaded by running loadavatargallery command
  289. MISAGO_AVATAR_GALLERY = os.path.join(BASE_DIR, 'avatargallery')
  290. # Specifies the number of days that IP addresses are stored in the database before removing.
  291. # Change this setting to None to never remove old IP addresses.
  292. MISAGO_IP_STORE_TIME = 50
  293. # Profile fields
  294. MISAGO_PROFILE_FIELDS = [
  295. {
  296. 'name': _("Personal"),
  297. 'fields': [
  298. 'misago.users.profilefields.default.RealNameField',
  299. 'misago.users.profilefields.default.GenderField',
  300. 'misago.users.profilefields.default.BioField',
  301. 'misago.users.profilefields.default.LocationField',
  302. ],
  303. },
  304. {
  305. 'name': _("Contact"),
  306. 'fields': [
  307. 'misago.users.profilefields.default.TwitterHandleField',
  308. 'misago.users.profilefields.default.SkypeIdField',
  309. 'misago.users.profilefields.default.WebsiteField',
  310. ],
  311. },
  312. {
  313. 'name': _("IP address"),
  314. 'fields': [
  315. 'misago.users.profilefields.default.JoinIpField',
  316. ],
  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. }