settings.py 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. # -*- coding: utf-8 -*-
  2. """
  3. flaskbb.fixtures.settings
  4. ~~~~~~~~~~~~~~~~~~~~~~~~~
  5. The fixtures module for our settings.
  6. :copyright: (c) 2014 by the FlaskBB Team.
  7. :license: BSD, see LICENSE for more details.
  8. """
  9. # import .. as .. to make it backwards compatible
  10. from flaskbb.utils.helpers import \
  11. get_available_languages as available_languages, \
  12. get_available_themes as available_themes
  13. from flaskbb.utils.forms import SettingsValueTypes
  14. def available_avatar_types():
  15. return [("PNG", "PNG"), ("JPEG", "JPG"), ("GIF", "GIF")]
  16. fixture = (
  17. # Settings Group
  18. ('general', {
  19. 'name': "General Settings",
  20. 'description': "How many items per page are displayed.",
  21. 'settings': (
  22. ('project_title', {
  23. 'value': "FlaskBB",
  24. 'value_type': SettingsValueTypes.string,
  25. 'name': "Project title",
  26. 'description': "The title of the project.",
  27. }),
  28. ('project_subtitle', {
  29. 'value': "A lightweight forum software in Flask",
  30. 'value_type': SettingsValueTypes.string,
  31. 'name': "Project subtitle",
  32. 'description': "A short description of the project.",
  33. }),
  34. ('posts_per_page', {
  35. 'value': 10,
  36. 'value_type': SettingsValueTypes.integer,
  37. 'extra': {'min': 5},
  38. 'name': "Posts per page",
  39. 'description': "Number of posts displayed per page.",
  40. }),
  41. ('topics_per_page', {
  42. 'value': 10,
  43. 'value_type': SettingsValueTypes.integer,
  44. 'extra': {'min': 5},
  45. 'name': "Topics per page",
  46. 'description': "Number of topics displayed per page.",
  47. }),
  48. ('users_per_page', {
  49. 'value': 10,
  50. 'value_type': SettingsValueTypes.integer,
  51. 'extra': {'min': 5},
  52. 'name': "Users per page",
  53. 'description': "Number of users displayed per page.",
  54. }),
  55. ),
  56. }),
  57. ('auth', {
  58. 'name': 'Authentication Settings',
  59. 'description': 'Configurations for the Login and Register process.',
  60. 'settings': (
  61. ('registration_enabled', {
  62. 'value': True,
  63. 'value_type': SettingsValueTypes.boolean,
  64. 'name': "Enable Registration",
  65. 'description': "Enable or disable the registration",
  66. }),
  67. ('activate_account', {
  68. 'value': True,
  69. 'value_type': SettingsValueTypes.boolean,
  70. 'name': "Enable Account Activation",
  71. 'description': "Enable to let the user activate their account by sending a email with an activation link."
  72. }),
  73. ('auth_username_min_length', {
  74. 'value': 3,
  75. 'value_type': SettingsValueTypes.integer,
  76. 'extra': {'min': 0},
  77. 'name': "Username Minimum Length",
  78. 'description': "The minimum length of the username. Changing this will only affect new registrations.",
  79. }),
  80. ('auth_username_max_length', {
  81. 'value': 20,
  82. 'value_type': SettingsValueTypes.integer,
  83. 'extra': {'min': 0},
  84. 'name': "Username Maximum Length",
  85. 'description': "The Maximum length of the username. Changing this will only affect new registrations.",
  86. }),
  87. ('auth_username_blacklist', {
  88. 'value': "me,administrator,moderator",
  89. 'value_type': SettingsValueTypes.string,
  90. 'name': "Username Blacklist",
  91. 'description': "A comma seperated list with forbidden usernames.",
  92. }),
  93. ('auth_ratelimit_enabled', {
  94. 'value': True,
  95. 'value_type': SettingsValueTypes.boolean,
  96. 'name': "Enable Auth Rate Limiting",
  97. 'description': "Enable rate limiting on 'auth' routes. This will limit the amount of requests per minute to a given amount and time.",
  98. }),
  99. ('auth_requests', {
  100. 'value': 20,
  101. 'value_type': SettingsValueTypes.integer,
  102. 'extra': {'min': 1},
  103. 'name': "Auth Requests",
  104. 'description': "Number of requests on each 'auth' route before the user has to wait a given timeout until he can access the resource again.",
  105. }),
  106. ('auth_timeout', {
  107. 'value': 15,
  108. 'value_type': SettingsValueTypes.integer,
  109. 'extra': {'min': 0},
  110. 'name': "Auth Timeout",
  111. 'description': "The timeout for how long the user has to wait until he can access the resource again (in minutes).",
  112. }),
  113. ('login_recaptcha', {
  114. 'value': 5,
  115. 'value_type': SettingsValueTypes.integer,
  116. 'extra': {'min': 0},
  117. 'name': "Login reCAPTCHA",
  118. 'description': "Use a CAPTCHA after a specified amount of failed login attempts."
  119. }),
  120. ('recaptcha_enabled', {
  121. 'value': False,
  122. 'value_type': SettingsValueTypes.boolean,
  123. 'name': "Enable reCAPTCHA",
  124. 'description': ("Helps to prevent bots from creating accounts. "
  125. "For more information visit this link: <a href=http://www.google.com/recaptcha>http://www.google.com/recaptcha</a>"),
  126. }),
  127. ('recaptcha_public_key', {
  128. 'value': "",
  129. 'value_type': SettingsValueTypes.string,
  130. 'name': "reCAPTCHA Site Key",
  131. 'description': "Your public recaptcha key ('Site key').",
  132. }),
  133. ('recaptcha_private_key', {
  134. 'value': "",
  135. 'value_type': SettingsValueTypes.string,
  136. 'name': "reCAPTCHA Secret Key",
  137. 'description': "The private key ('Secret key'). Keep this a secret!",
  138. }),
  139. ),
  140. }),
  141. ('misc', {
  142. 'name': "Misc Settings",
  143. 'description': "Miscellaneous settings.",
  144. 'settings': (
  145. ('message_quota', {
  146. 'value': 50,
  147. 'value_type': SettingsValueTypes.integer,
  148. 'extra': {"min": 0},
  149. 'name': "Private Message Quota",
  150. 'description': "The amount of messages a user can have."
  151. }),
  152. ('online_last_minutes', {
  153. 'value': 15,
  154. 'value_type': SettingsValueTypes.integer,
  155. 'extra': {'min': 0},
  156. 'name': "Online last minutes",
  157. 'description': "How long a user can be inactive before he is marked as offline. 0 to disable it.",
  158. }),
  159. ('title_length', {
  160. 'value': 15,
  161. 'value_type': SettingsValueTypes.integer,
  162. 'extra': {'min': 0},
  163. 'name': "Topic title length",
  164. 'description': "The length of the topic title shown on the index."
  165. }),
  166. ('tracker_length', {
  167. 'value': 7,
  168. 'value_type': SettingsValueTypes.integer,
  169. 'extra': {'min': 0},
  170. 'name': "Tracker length",
  171. 'description': "The days for how long the forum should deal with unread topics. 0 to disable it."
  172. }),
  173. ('avatar_height', {
  174. 'value': 150,
  175. 'value_type': SettingsValueTypes.integer,
  176. 'extra': {'min': 0},
  177. 'name': "Avatar Height",
  178. 'description': "The allowed height of an avatar in pixels."
  179. }),
  180. ('avatar_width', {
  181. 'value': 150,
  182. 'value_type': SettingsValueTypes.integer,
  183. 'extra': {'min': 0},
  184. 'name': "Avatar Width",
  185. 'description': "The allowed width of an avatar in pixels."
  186. }),
  187. ('avatar_size', {
  188. 'value': 200,
  189. 'value_type': SettingsValueTypes.integer,
  190. 'extra': {'min': 0},
  191. 'name': "Avatar Size",
  192. 'description': "The allowed size of the avatar in kilobytes."
  193. }),
  194. ('avatar_types', {
  195. 'value': ["PNG", "JPEG", "GIF"],
  196. 'value_type': SettingsValueTypes.selectmultiple,
  197. 'extra': {"choices": available_avatar_types},
  198. 'name': "Avatar Types",
  199. 'description': "The allowed types of an avatar. Such as JPEG, GIF or PNG."
  200. }),
  201. ('signature_enabled', {
  202. 'value': True,
  203. 'value_type': SettingsValueTypes.boolean,
  204. 'extra': {},
  205. 'name': "Enable Signatures",
  206. 'description': "Enable signatures in posts."
  207. })
  208. ),
  209. }),
  210. ('appearance', {
  211. 'name': "Appearance Settings",
  212. "description": "Change the theme and language for your forum.",
  213. "settings": (
  214. ('default_theme', {
  215. 'value': "aurora",
  216. 'value_type': SettingsValueTypes.select,
  217. 'extra': {'choices': available_themes},
  218. 'name': "Default Theme",
  219. 'description': "Change the default theme for your forum."
  220. }),
  221. ('default_language', {
  222. 'value': "en",
  223. 'value_type': SettingsValueTypes.select,
  224. 'extra': {'choices': available_languages},
  225. 'name': "Default Language",
  226. 'description': "Change the default language for your forum."
  227. }),
  228. ),
  229. }),
  230. )