settings.rst 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. ========
  2. Settings
  3. ========
  4. Accessing Settings
  5. ==================
  6. Misago splits its settings into two groups:
  7. * **Low level settings** - those settings must be available when Misago starts or control resources usage and shouldn't be changed frequently from admin control panel. Those settings live in ``settings.py``
  8. * **High level settings** - those settings are stored in database and can be changed on runtime using interface provided by admin control panel.
  9. Both types of settings can accessed as attributes of ``misago.conf.settings`` object and high level settings can be also accessed from your templates as attributes of ``misago_settings`` context value.
  10. .. note::
  11. Not all high level settings values are available at all times. Some settings ("lazy settings"), are evaluated to ``True`` or ``None`` immediately upon load. This means that they can be checked to see if they have value or not, but require you to use special ``get_lazy_setting(setting)`` getter to obtain their real value.
  12. Defining Custom DB Settings
  13. ===========================
  14. .. note::
  15. Current Misago 0.6 migrations are south-based placeholders that will be replaced with new migrations introduced in Django 1.7 before release. For this reason this instruction focuses exclusively on usage of utility function provided by Misago.
  16. In order to define or change high-level (stored in database) settings you have to add new rows to ``conf_settingsgroup`` and ``conf_settings`` database tables. This can be done by plenty of different ways, but preffered one is by creating new data migration and using functions from ``misago.conf.migrationutils`` module.
  17. migrate_settings_group
  18. ----------------------
  19. .. function:: migrate_settings_group(orm, group_fixture, old_group_key=None)
  20. This function uses south supplied ORM instance to insert/update settings group in database according to provided dict contianing its name, description and contained settings. If new group should replace old one, you can provide its key in ``old_group_key`` argument.
  21. The ``group_fixture`` dict should define following keys:
  22. * **key** - string with settings group key.
  23. * **name** - string with settings group name.
  24. * **description** - optional string with short settings group description.
  25. * **settings** - tuple containing dics describing settings belonging to this group.
  26. Each dict in ``settings`` tuple should define following keys:
  27. * **setting** - string with internal setting name.
  28. * **name** - string with displayed setting name.
  29. * **description** - optional string with small setting help message.
  30. * **legend** - optional string indicating that before displaying this setting in form, new fieldset should be opened and this value should be used in its legend element.
  31. * **python_type** - optional string defining type of setting's value. Can be either "string", "int", "bool" or "list". If omitted "string" is used by default.
  32. * **value** - list, integer or string with default value for this setting.
  33. * **default_value** - if your setting should always have value, specify there fallabck value used if no user-defined value is available.
  34. * **is_public** - public settings are included JSON that is passed to Ember.js application. Defaults to ``False``.
  35. * **is_lazy** - if setting value may too large to be always loaded into memory, you may make setting lazily loaded by defining this key with ``True`` value assigned.
  36. * **form_field** - What form field should be used to change this setting. Can be either "text", "textarea", "select", "radio", "yesno" or "checkbox". If not defined, "text" is used. "checkbox" should be used exclusively for multiple choices list.
  37. * **field_extra** - dict that defines extra attributes of form field. For "select", "radio" and "checkbox" fields this dict should contain "choices" key with tuple of tuples that will be used for choices in input. For "string" settings you can define "min_length" and "max_length" extra specifying minmal and maximal lenght of entered text. For integer settings you can specify minimal and maximal range in which value should fall by "min_value" and "max_value". "textarea" field supports extra "rows" setting that controls generated textarea rows attribute. All text-based fields accept "required" setting. "checkbox" field supports "min" and "max" values that control minimum and maximum required choices.
  38. .. note::
  39. If you wish to make your names and messages translateable, you should use ``ugettext_lazy`` function provided by Misago instead of Django one. This function is defined in ``misago.core.migrationutils`` module and differs from Django one by the fact that it preserves untranslated message on its ``message`` attribute.
  40. For your convience ``migrate_settings_group`` triess to switch translation messages with their "message" attribute when it writes to database and thus making their translation to new languages in future possible.
  41. with_conf_models
  42. ----------------
  43. .. function:: with_conf_models(migration, this_migration=None)
  44. South migrations define special ``models`` attribute that holds dict representing structure of database at time of migration execution. This dict will by default contain only your apps models. To add settings models that ``migrate_settings_group`` requires to work, you have to use ``with_conf_models`` function. This function accepts two arguments:
  45. * **migration** - name of migration in ``misago.conf`` app containing models definitions current for the time of your data migration.
  46. * **this_migration** - dict with model definitions for this migration.
  47. In addition to this, make sure that your migration ``depends_on`` attribute defines dependency on migration from ``misago.conf`` app::
  48. class Migration(DataMigration):
  49. # Migration code...
  50. models = with_conf_models('0001_initial', {
  51. # This migration models
  52. })
  53. depends_on = (
  54. ("conf", "0001_initial"),
  55. )
  56. delete_settings_cache
  57. ---------------------
  58. .. function:: delete_settings_cache()
  59. If you have used ``migrate_settings_group`` function in your migration, make sure to call ``delete_settings_cache`` at its end to flush settings caches.
  60. Misago Settings Reference
  61. =========================
  62. By convention, low level settings are written in UPPER_CASE and high level ones are written in lower_case.
  63. account_activation
  64. ------------------
  65. Preffered way in which new user accounts are activated. Can be either of those:
  66. * **none** - no activation required.
  67. * **user** - new user has to click link in activation e-mail.
  68. * **admin** - board administrator has to activate new accounts manually.
  69. * **block** - turn new registrations off.
  70. allow_custom_avatars
  71. --------------------
  72. Controls if users may set avatars from outside forums.
  73. avatar_upload_limit
  74. -------------------
  75. Max allowed size of uploaded avatars in kilobytes.
  76. default_avatar
  77. --------------
  78. Default avatar assigned to new accounts. Can be either ``initials`` for randomly generated pic with initials, ``gravatar`` or ``gallery`` which will make Misago pick random avatar from gallery instead.
  79. default_timezone
  80. ----------------
  81. Default timezone used by guests and newly registered users that haven't changed their timezone prefferences.
  82. forum_branding_display
  83. ----------------------
  84. Controls branding's visibility in forum navbar.
  85. forum_branding_text
  86. -------------------
  87. Allows you to include text besides brand logo on your forum.
  88. forum_name
  89. ----------
  90. Forum name, displayed in titles of pages.
  91. forum_index_meta_description
  92. ----------------------------
  93. Forum index Meta Description used as value meta description attribute on forum index.
  94. forum_index_title
  95. -----------------
  96. Forum index title. Can be empty string if not set, in which case ``forum_name`` should be used instead.
  97. MISAGO_403_IMAGE
  98. ----------------
  99. Url (relative to STATIC_URL) to file that should be served if user has no permission to see requested attachment.
  100. MISAGO_404_IMAGE
  101. ----------------
  102. Url (relative to STATIC_URL) to file that should be served if user has requested nonexistant attachment.
  103. MISAGO_ACL_EXTENSIONS
  104. ---------------------
  105. List of Misago ACL framework extensions.
  106. MISAGO_ADMIN_NAMESPACES
  107. -----------------------
  108. Link namespaces that are administrator-only areas that require additional security from Misago. Users will have to re-authenticate themselves to access those namespaces, even if they are already signed in your frontend. In addition they will be requested to reauthenticated if they were inactive in those namespaces for certain time.
  109. Defautly ``misago:admin`` and ``admin`` namespaces are specified, putting both Misago and Django default admin interfaces under extended security mechanics.
  110. MISAGO_ADMIN_PATH
  111. -----------------
  112. Path prefix for Misago administration backend. Defautly "admincp", but you may set it to empty string if you with to disable your forum administration backend.
  113. MISAGO_ADMIN_SESSION_EXPIRATION
  114. -------------------------------
  115. Maximum allowed lenght of inactivity period between two requests to admin namespaces. If its exceeded, user will be asked to sign in again to admin backed before being allowed to continue activities.
  116. MISAGO_ATTACHMENT_SECRET_LENGTH
  117. -------------------------------
  118. Length of attachment's secret (filenames and url token). The longer, the harder it is to bruteforce, but too long may conflict with your uploaded files storage limits (eg. filesystem path length limits).
  119. .. warning::
  120. In order for Misago to support clustered deployments or CDN's (like Amazon's S3), its unable to validate user's permission to see the attachment at its source. Instead it has to rely on exessively long and hard to guess urls to attachments and assumption that your users will not "leak" source urls to attachments further.
  121. Generaly, neither you nor your users should use forums to exchange files containing valuable data, but if you do, you should make sure to secure it additionaly via other means like password-protected archives or file encryption solutions.
  122. MISAGO_AVATAR_SERVER_PATH
  123. -------------------------
  124. Url path that that all avatar server urls starts with. If you are running Misago subdirectory, make sure to update it (i.e. valid path for "http://somesite.com/forums/" is ``/forums/user-avatar``).
  125. MISAGO_AVATAR_STORE
  126. -------------------
  127. Path to directory that Misago should use to store user avatars. This directory shouldn't be accessible from outside world.
  128. MISAGO_AVATARS_SIZES
  129. --------------------
  130. Misago uses avatar cache that prescales avatars to requested sizes. Enter here sizes to which those should be optimized.
  131. MISAGO_COMPACT_DATE_FORMAT_DAY_MONTH
  132. ------------------------------------
  133. Date format used by Misago ``compact_date`` filter for dates in this year.
  134. Expects standard Django date format, documented `here <https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date>`_
  135. MISAGO_COMPACT_DATE_FORMAT_DAY_MONTH_YEAR
  136. -----------------------------------------
  137. Date format used by Misago ``compact_date`` filter for dates in past years.
  138. Expects standard Django date format, documented `here <https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date>`_
  139. MISAGO_DIALY_POST_LIMIT
  140. -----------------------
  141. Dialy limit of posts that may be posted from single account. Fail-safe for situations when forum is flooded by spam bot. Change to 0 to lift this restriction.
  142. MISAGO_DYNAMIC_AVATAR_DRAWER
  143. ----------------------------
  144. Function used to create unique avatar for this user. Allows for customization of algorithm used to generate those.
  145. MISAGO_HOURLY_POST_LIMIT
  146. -----------------------
  147. Hourly limit of posts that may be posted from single account. Fail-safe for situations when forum is flooded by spam bot. Change to 0 to lift this restriction.
  148. MISAGO_LOGIN_API_URL
  149. --------------------
  150. URL to API endpoint used to authenticate sign-in credentials. Musn't contain api prefix or wrapping slashes. Defaults to 'auth/login'.
  151. MISAGO_MAILER_BATCH_SIZE
  152. ------------------------
  153. Default maximum size of single mails package that Misago will build before sending mails and creating next package.
  154. MISAGO_MARKUP_EXTENSIONS
  155. ------------------------
  156. List of python modules extending Misago markup.
  157. MISAGO_NEW_REGISTRATIONS_VALIDATORS
  158. -----------------------------------
  159. List of functions to be called when somebody attempts to register on forums using registration form.
  160. MISAGO_NOTIFICATIONS_MAX_AGE
  161. ----------------------------
  162. Max age, in days, of notifications stored in database. Notifications older than this will be delted.
  163. MISAGO_POSTING_MIDDLEWARES
  164. --------------------------
  165. List of middleware classes participating in posting process.
  166. MISAGO_POSTS_PER_PAGE
  167. ---------------------
  168. Controls number of posts displayed on thread page. Greater numbers can increase number of objects loaded into memory and thus depending on features enabled greatly increase memory usage.
  169. MISAGO_POSTS_TAIL
  170. -----------------
  171. Defines minimal number of posts for thread's last page. If number of posts on last page is smaller or equal to one specified in this setting, last page will be appended to previous page instead.
  172. MISAGO_RANKING_LENGTH
  173. ---------------------
  174. Some lists act as rankings, displaying users in order of certain scoring criteria, like number of posts or likes received.
  175. This setting controls maximum age in days of items that should count to ranking.
  176. MISAGO_RANKING_SIZE
  177. -------------------
  178. Maximum number of items on ranking page.
  179. MISAGO_READTRACKER_CUTOFF
  180. -------------------------
  181. Controls amount of data used by readtracking system. All content older than number of days specified in this setting is considered old and read, even if opposite is true. Active forums can try lowering this value while less active ones may wish to increase it instead.
  182. MISAGO_SENDFILE_HEADER
  183. ----------------------
  184. If your server provides proxy for serving files from application, like "X-Sendfile", set its header name in this setting.
  185. Leave this setting empty to use Django fallback.
  186. MISAGO_SENDFILE_LOCATIONS_PATH
  187. ------------------------------
  188. Some Http servers (like Nginx) allow you to restrict X-Sendfile to certain locations.
  189. Misago supports this feature with this setting, however with limitation to one "root" path. This setting is used for paths defined in ATTACHMENTS_ROOT and AVATAR_CACHE settings.
  190. Rewrite algorithm used by Misago replaces path until last part with value of this setting.
  191. For example, defining ``MISAGO_SENDFILE_LOCATIONS_PATH = 'misago_served_internals'`` will result in following rewrite:
  192. ``/home/mysite/www/attachments/13_05/142123.rar`` => ``/misago_served_internals/attachments/13_05/142123.rar``
  193. MISAGO_STOP_FORUM_SPAM_USE
  194. --------------------------
  195. This settings allows you to decide wheter of not `Stop Forum Spam <http://www.stopforumspam.com/>`_ database should be used to validate IPs and emails during new users registrations.
  196. MISAGO_STOP_FORUM_SPAM_MIN_CONFIDENCE
  197. -------------------------------------
  198. Minimum confidence returned by `Stop Forum Spam <http://www.stopforumspam.com/>`_ for Misago to reject new registration and block IP address for 1 day.
  199. MISAGO_THREADS_ON_INDEX
  200. --------------------------
  201. Change this setting to ``False`` to display categories list instead of threads list on board index.
  202. MISAGO_THREADS_PER_PAGE
  203. ---------------------
  204. Controls number of threads displayed on page. Greater numbers can increase number of objects loaded into memory and thus depending on features enabled greatly increase memory usage.
  205. MISAGO_THREADS_TAIL
  206. ------------------
  207. Defines minimal number of threads for lists last page. If number of threads on last page is smaller or equal to one specified in this setting, last page will be appended to previous page instead.
  208. MISAGO_THREAD_TYPES
  209. -------------------
  210. List of clasess defining thread types.
  211. MISAGO_USERS_PER_PAGE
  212. ---------------------
  213. Controls pagination of users lists.
  214. password_complexity
  215. -------------------
  216. Complexity requirements for new user passwords. It's value is list of strings representing following requirements:
  217. * **case** - mixed case.
  218. * **alphanumerics** - both digits and letters.
  219. * **special** - special characters.
  220. password_length_min
  221. -------------------
  222. Minimal required length of new user passwords.
  223. post_length_max
  224. ---------------
  225. Maximal allowed post content length.
  226. post_length_min
  227. ---------------
  228. Minimal allowed post content length.
  229. signature_length_max
  230. --------------------
  231. Maximal allowed length of users signatures.
  232. subscribe_reply
  233. ---------------
  234. Default value for automatic subscription to replied threads prefference for new user accounts. Its value represents one of those settings:
  235. * **no** - don't watch.
  236. * **watch** - put on watched threads list.
  237. * **watch_email** - put on watched threads list and send e-mail when somebody replies.
  238. subscribe_start
  239. ---------------
  240. Default value for automatic subscription to started threads prefference for new user accounts. Allows for same values as ``subscribe_reply``.
  241. thread_title_length_max
  242. -----------------------
  243. Maximal allowed thread title length.
  244. thread_title_length_min
  245. -----------------------
  246. Minimal allowed thread title length.
  247. username_length_max
  248. -------------------
  249. Maximal allowed username length.
  250. username_length_min
  251. -------------------
  252. Minimal allowed username length.
  253. Django Settings Reference
  254. =========================
  255. Django defines plenty of configuration options that control behaviour of different features that Misago relies on.
  256. Those are documented and available in Django documentation: `Settings <https://docs.djangoproject.com/en/1.6/ref/settings/>`_