defaults.py 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. """
  2. Misago default settings
  3. This fille sets everything Misago needs to run.
  4. If you want to add custom app, middleware or path, please update setting vallue
  5. defined in this file instead of copying setting from here to your settings.py.
  6. Yes:
  7. #yourproject/settings.py
  8. INSTALLED_APPS += (
  9. 'myawesomeapp',
  10. )
  11. No:
  12. #yourproject/settings.py
  13. INSTALLED_APPS = (
  14. 'django.contrib.admin',
  15. 'django.contrib.auth',
  16. 'misago.core',
  17. 'misago.conf',
  18. ...
  19. 'myawesomeapp',
  20. )
  21. """
  22. # Build paths inside the project like this: os.path.join(MISAGO_BASE_DIR, ...)
  23. import os
  24. MISAGO_BASE_DIR = os.path.dirname(os.path.dirname(__file__))
  25. # Default JS debug to false
  26. # This setting used exclusively by test runner and isn't part of public API
  27. _MISAGO_JS_DEBUG = False
  28. # Application definition
  29. INSTALLED_APPS = (
  30. 'django.contrib.admin',
  31. # Keep misago.users above django.contrib.auth
  32. # so our management commands take precedence over theirs
  33. 'misago.users',
  34. 'django.contrib.auth',
  35. 'django.contrib.contenttypes',
  36. 'django.contrib.sessions',
  37. 'django.contrib.messages',
  38. 'django.contrib.staticfiles',
  39. 'django.contrib.humanize',
  40. 'debug_toolbar',
  41. 'crispy_forms',
  42. 'mptt',
  43. 'rest_framework',
  44. 'misago.admin',
  45. 'misago.acl',
  46. 'misago.core',
  47. 'misago.conf',
  48. 'misago.markup',
  49. 'misago.legal',
  50. 'misago.categories',
  51. 'misago.threads',
  52. 'misago.readtracker',
  53. 'misago.faker',
  54. )
  55. MIDDLEWARE_CLASSES = (
  56. 'misago.users.middleware.AvatarServerMiddleware',
  57. 'misago.users.middleware.RealIPMiddleware',
  58. 'misago.core.middleware.frontendcontext.FrontendContextMiddleware',
  59. 'django.contrib.sessions.middleware.SessionMiddleware',
  60. 'django.middleware.common.CommonMiddleware',
  61. 'django.middleware.csrf.CsrfViewMiddleware',
  62. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  63. 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
  64. 'misago.users.middleware.UserMiddleware',
  65. 'django.contrib.messages.middleware.MessageMiddleware',
  66. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  67. 'misago.core.middleware.exceptionhandler.ExceptionHandlerMiddleware',
  68. 'misago.users.middleware.OnlineTrackerMiddleware',
  69. 'misago.admin.middleware.AdminAuthMiddleware',
  70. 'misago.threads.middleware.UnreadThreadsCountMiddleware',
  71. 'misago.core.middleware.threadstore.ThreadStoreMiddleware',
  72. )
  73. TEMPLATE_CONTEXT_PROCESSORS = (
  74. 'django.contrib.auth.context_processors.auth',
  75. 'django.core.context_processors.debug',
  76. 'django.core.context_processors.i18n',
  77. 'django.core.context_processors.media',
  78. 'django.core.context_processors.static',
  79. 'django.core.context_processors.tz',
  80. 'django.contrib.messages.context_processors.messages',
  81. 'misago.core.context_processors.site_address',
  82. 'misago.conf.context_processors.settings',
  83. 'misago.users.context_processors.user_links',
  84. 'misago.legal.context_processors.legal_links',
  85. # Data preloaders
  86. 'misago.conf.context_processors.preload_settings_json',
  87. 'misago.markup.context_processors.preload_api_url',
  88. 'misago.threads.context_processors.preload_threads_urls',
  89. 'misago.users.context_processors.preload_user_json',
  90. # Note: keep frontend_context processor last for previous processors
  91. # to be able to add data to request.frontend_context
  92. 'misago.core.context_processors.frontend_context',
  93. )
  94. MISAGO_ACL_EXTENSIONS = (
  95. 'misago.users.permissions.account',
  96. 'misago.users.permissions.profiles',
  97. 'misago.users.permissions.warnings',
  98. 'misago.users.permissions.moderation',
  99. 'misago.users.permissions.delete',
  100. 'misago.categories.permissions',
  101. 'misago.threads.permissions.attachments',
  102. 'misago.threads.permissions.threads',
  103. 'misago.threads.permissions.privatethreads',
  104. )
  105. MISAGO_MARKUP_EXTENSIONS = ()
  106. MISAGO_POSTING_MIDDLEWARES = (
  107. # Note: always keep FloodProtectionMiddleware middleware first one
  108. 'misago.threads.api.postingendpoint.floodprotection.FloodProtectionMiddleware',
  109. 'misago.threads.api.postingendpoint.category.CategoryMiddleware',
  110. 'misago.threads.api.postingendpoint.reply.ReplyMiddleware',
  111. # 'misago.threads.api.postingendpoint.participants.ThreadParticipantsFormMiddleware',
  112. 'misago.threads.api.postingendpoint.pin.PinMiddleware',
  113. 'misago.threads.api.postingendpoint.close.CloseMiddleware',
  114. 'misago.threads.api.postingendpoint.hide.HideMiddleware',
  115. 'misago.threads.api.postingendpoint.protect.ProtectMiddleware',
  116. # 'misago.threads.api.postingendpoint.recordedit.RecordEditMiddleware',
  117. 'misago.threads.api.postingendpoint.updatestats.UpdateStatsMiddleware',
  118. 'misago.threads.api.postingendpoint.mentions.MentionsMiddleware',
  119. 'misago.threads.api.postingendpoint.subscribe.SubscribeMiddleware',
  120. # Note: always keep SaveChangesMiddleware middleware after all state-changing middlewares
  121. 'misago.threads.api.postingendpoint.savechanges.SaveChangesMiddleware',
  122. # Those middlewares are last because they don't change app state
  123. 'misago.threads.api.postingendpoint.emailnotification.EmailNotificationMiddleware',
  124. )
  125. MISAGO_THREAD_TYPES = (
  126. 'misago.threads.threadtypes.thread.Thread',
  127. 'misago.threads.threadtypes.privatethread.PrivateThread',
  128. )
  129. # Register Misago directories
  130. LOCALE_PATHS = (
  131. os.path.join(MISAGO_BASE_DIR, 'locale'),
  132. )
  133. STATICFILES_DIRS = (
  134. os.path.join(MISAGO_BASE_DIR, 'static'),
  135. )
  136. TEMPLATE_DIRS = (
  137. os.path.join(MISAGO_BASE_DIR, 'templates'),
  138. )
  139. # Internationalization
  140. USE_I18N = True
  141. USE_L10N = True
  142. USE_TZ = True
  143. TIME_ZONE = 'UTC'
  144. # Misago specific date formats
  145. # https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
  146. MISAGO_COMPACT_DATE_FORMAT_DAY_MONTH = 'j M'
  147. MISAGO_COMPACT_DATE_FORMAT_DAY_MONTH_YEAR = 'M \'y'
  148. # Use Misago CSRF Failure Page
  149. CSRF_FAILURE_VIEW = 'misago.core.errorpages.csrf_failure'
  150. # Use Misago authentication
  151. AUTH_USER_MODEL = 'misago_users.User'
  152. AUTHENTICATION_BACKENDS = (
  153. 'misago.users.authbackends.MisagoBackend',
  154. )
  155. MISAGO_NEW_REGISTRATIONS_VALIDATORS = (
  156. 'misago.users.validators.validate_gmail_email',
  157. 'misago.users.validators.validate_with_sfs',
  158. )
  159. MISAGO_STOP_FORUM_SPAM_USE = True
  160. MISAGO_STOP_FORUM_SPAM_MIN_CONFIDENCE = 80
  161. # How many e-mails should be sent in single step.
  162. # This is used for conserving memory usage when mailing many users at same time
  163. MISAGO_MAILER_BATCH_SIZE = 20
  164. # Auth paths
  165. MISAGO_LOGIN_API_URL = 'auth'
  166. LOGIN_REDIRECT_URL = 'misago:index'
  167. LOGIN_URL = 'misago:login'
  168. LOGOUT_URL = 'misago:logout'
  169. # Misago Admin Path
  170. # Omit starting and trailing slashes
  171. # To disable Misago admin, empty this value
  172. MISAGO_ADMIN_PATH = 'admincp'
  173. # Admin urls namespaces that Misago's AdminAuthMiddleware should protect
  174. MISAGO_ADMIN_NAMESPACES = (
  175. 'admin',
  176. 'misago:admin',
  177. )
  178. # How long (in minutes) since previous request to admin namespace should
  179. # admin session last.
  180. MISAGO_ADMIN_SESSION_EXPIRATION = 60
  181. # Display threads on forum index
  182. # Change this to false to display categories list instead
  183. MISAGO_THREADS_ON_INDEX = True
  184. # Max age of notifications in days
  185. # Notifications older than this are deleted
  186. # On very active forums its better to keep this smaller
  187. MISAGO_NOTIFICATIONS_MAX_AGE = 40
  188. # Fail-safe limits in case forum is raided by spambot
  189. # No user may exceed those limits, however you may disable
  190. # them by changing them to 0
  191. MISAGO_DIALY_POST_LIMIT = 600
  192. MISAGO_HOURLY_POST_LIMIT = 100
  193. # Function used for generating individual avatar for user
  194. MISAGO_DYNAMIC_AVATAR_DRAWER = 'misago.users.avatars.dynamic.draw_default'
  195. # For which sizes avatars should be cached
  196. # Keep sizes ordered from greatest to smallest
  197. # Max size also controls min size of uploaded image as well as crop size
  198. MISAGO_AVATARS_SIZES = (400, 200, 150, 100, 64, 50, 30, 20)
  199. # Path to avatar server
  200. # This path is used to detect avatar requests, which bypass most of
  201. # Request/Response processing for performance reasons
  202. MISAGO_AVATAR_SERVER_PATH = '/user-avatar'
  203. # Number of threads displayed on single page
  204. MISAGO_THREADS_PER_PAGE = 25
  205. MISAGO_THREADS_TAIL = 15
  206. # Number of posts displayed on single thread page
  207. MISAGO_POSTS_PER_PAGE = 15
  208. MISAGO_POSTS_TAIL = 7
  209. # Number of attachments possible to assign to single post
  210. MISAGO_POST_ATTACHMENTS_LIMIT = 16
  211. # Length of secret used for attachments url tokens and filenames
  212. MISAGO_ATTACHMENT_SECRET_LENGTH = 64
  213. # Names of files served when user requests file that doesn't exist or is unavailable
  214. # Those files will be sought within STATIC_ROOT directory
  215. MISAGO_404_IMAGE = 'misago/error-404.png'
  216. MISAGO_403_IMAGE = 'misago/error-403.png'
  217. # Controls max age in days of items that Misago has to process to make rankings
  218. # Used for active posters and most liked users lists
  219. # If your forum runs out of memory when trying to generate users rankings list
  220. # or you want those to be more dynamic, give this setting lower value
  221. # You don't have to be overzelous with this as user rankings are cached for 24h
  222. MISAGO_RANKING_LENGTH = 30
  223. # Controls max number of items displayed on ranked lists
  224. MISAGO_RANKING_SIZE = 50
  225. # Controls number of users displayed on single page
  226. MISAGO_USERS_PER_PAGE = 12
  227. # Controls amount of data used by readtracking system
  228. # Items older than number of days specified below are considered read
  229. # Depending on amount of new content being posted on your forum you may want
  230. # To decrease or increase this number to fine-tune readtracker performance
  231. MISAGO_READTRACKER_CUTOFF = 40
  232. # X-Sendfile
  233. # X-Sendfile is feature provided by Http servers that allows web apps to
  234. # delegate serving files over to the better performing server instead of
  235. # doing it within app.
  236. # If your server supports X-Sendfile or its variation, enter header name here.
  237. # For example if you are using Nginx with X-accel enabled, set this setting
  238. # to "X-Accel-Redirect".
  239. # Leave this setting empty to Django fallback instead
  240. MISAGO_SENDFILE_HEADER = ''
  241. # Allows you to use location feature of your Http server
  242. # For example, if you have internal location /mymisago/avatar_cache/
  243. # that points at /home/myweb/misagoforum/avatar_cache/, set this setting
  244. # to "mymisago".
  245. MISAGO_SENDFILE_LOCATIONS_PATH = ''
  246. # Default forms templates
  247. CRISPY_TEMPLATE_PACK = 'bootstrap3'
  248. # Rest Framework Configuration
  249. REST_FRAMEWORK = {
  250. 'DEFAULT_PERMISSION_CLASSES': (
  251. 'misago.users.rest_permissions.IsAuthenticatedOrReadOnly',
  252. ),
  253. 'EXCEPTION_HANDLER': 'misago.core.exceptionhandler.handle_api_exception',
  254. 'UNAUTHENTICATED_USER': 'misago.users.models.AnonymousUser',
  255. 'URL_FORMAT_OVERRIDE': None,
  256. }
  257. # Register Misago debug panels
  258. DEBUG_TOOLBAR_PANELS = (
  259. 'debug_toolbar.panels.versions.VersionsPanel',
  260. 'debug_toolbar.panels.timer.TimerPanel',
  261. 'debug_toolbar.panels.settings.SettingsPanel',
  262. 'debug_toolbar.panels.headers.HeadersPanel',
  263. 'debug_toolbar.panels.request.RequestPanel',
  264. 'debug_toolbar.panels.sql.SQLPanel',
  265. 'misago.acl.panels.MisagoACLPanel',
  266. 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
  267. 'debug_toolbar.panels.templates.TemplatesPanel',
  268. 'debug_toolbar.panels.cache.CachePanel',
  269. 'debug_toolbar.panels.signals.SignalsPanel',
  270. 'debug_toolbar.panels.logging.LoggingPanel',
  271. )