0002_users_settings.py 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from django.db import migrations
  4. from misago.conf.migrationutils import migrate_settings_group
  5. _ = lambda x: x
  6. def create_users_settings_group(apps, schema_editor):
  7. migrate_settings_group(
  8. apps, {
  9. 'key': 'users',
  10. 'name': _("Users"),
  11. 'description': _(
  12. "Those settings control user accounts default behaviour and features availability."
  13. ),
  14. 'settings': [
  15. {
  16. 'setting': 'account_activation',
  17. 'name': _("New accounts activation"),
  18. 'legend': _("New accounts"),
  19. 'value': 'none',
  20. 'form_field': 'select',
  21. 'field_extra': {
  22. 'choices': [
  23. ('none', _("No activation required")),
  24. ('user', _("Activation token sent to User")),
  25. ('admin', _("Activation by administrator")),
  26. ('closed', _("Don't allow new registrations")),
  27. ],
  28. },
  29. 'is_public': True,
  30. },
  31. {
  32. 'setting': 'username_length_min',
  33. 'name': _("Minimum length"),
  34. 'description': _("Minimum allowed username length."),
  35. 'legend': _("User names"),
  36. 'python_type': 'int',
  37. 'value': 3,
  38. 'field_extra': {
  39. 'min_value': 2,
  40. 'max_value': 20,
  41. },
  42. 'is_public': True,
  43. },
  44. {
  45. 'setting': 'username_length_max',
  46. 'name': _("Maximum length"),
  47. 'description': _("Maximum allowed username length."),
  48. 'python_type': 'int',
  49. 'value': 14,
  50. 'field_extra': {
  51. 'min_value': 2,
  52. 'max_value': 20,
  53. },
  54. 'is_public': True,
  55. },
  56. {
  57. 'setting': 'password_length_min',
  58. 'name': _("Minimum length"),
  59. 'description': _("Minimum allowed user password length."),
  60. 'legend': _("Passwords"),
  61. 'python_type': 'int',
  62. 'value': 5,
  63. 'field_extra': {
  64. 'min_value': 2,
  65. 'max_value': 255,
  66. },
  67. 'is_public': True,
  68. },
  69. {
  70. 'setting': 'allow_custom_avatars',
  71. 'name': _("Allow custom avatars"),
  72. 'legend': _("Avatars"),
  73. 'description': _(
  74. "Turning this option off will forbid "
  75. "forum users from using avatars from "
  76. "outside forums. Good for forums "
  77. "adressed at young users."
  78. ),
  79. 'python_type': 'bool',
  80. 'value': True,
  81. 'form_field': 'yesno',
  82. },
  83. {
  84. 'setting': 'default_avatar',
  85. 'name': _("Default avatar"),
  86. 'value': 'gravatar',
  87. 'form_field': 'select',
  88. 'field_extra': {
  89. 'choices': [
  90. ('dynamic', _("Individual")),
  91. ('gravatar', _("Gravatar")),
  92. ('gallery', _("Random avatar from gallery")),
  93. ],
  94. },
  95. },
  96. {
  97. 'setting': 'default_gravatar_fallback',
  98. 'name': _("Fallback for default gravatar"),
  99. 'description': _(
  100. "Select which avatar to use when user has no "
  101. "gravatar associated with his e-mail address."
  102. ),
  103. 'value': 'dynamic',
  104. 'form_field': 'select',
  105. 'field_extra': {
  106. 'choices': [
  107. ('dynamic', _("Individual")),
  108. ('gallery', _("Random avatar from gallery")),
  109. ],
  110. },
  111. },
  112. {
  113. 'setting': 'avatar_upload_limit',
  114. 'name': _("Maximum size of uploaded avatar"),
  115. 'description': _("Enter maximum allowed file size (in KB) for avatar uploads."),
  116. 'python_type': 'int',
  117. 'value': 1536,
  118. 'field_extra': {
  119. 'min_value': 0,
  120. },
  121. 'is_public': True,
  122. },
  123. {
  124. 'setting': 'signature_length_max',
  125. 'name': _("Maximum length"),
  126. 'legend': _("Signatures"),
  127. 'description': _("Maximum allowed signature length."),
  128. 'python_type': 'int',
  129. 'value': 256,
  130. 'field_extra': {
  131. 'min_value': 10,
  132. 'max_value': 5000,
  133. },
  134. 'is_public': True,
  135. },
  136. {
  137. 'setting': 'subscribe_start',
  138. 'name': _("Started threads"),
  139. 'legend': _("Default subscriptions settings"),
  140. 'value': 'watch_email',
  141. 'form_field': 'select',
  142. 'field_extra': {
  143. 'choices': [
  144. ('no', _("Don't watch")),
  145. ('watch', _("Put on watched threads list")),
  146. (
  147. 'watch_email', _(
  148. "Put on watched threads "
  149. "list and e-mail user when "
  150. "somebody replies"
  151. )
  152. ),
  153. ],
  154. },
  155. },
  156. {
  157. 'setting': 'subscribe_reply',
  158. 'name': _("Replied threads"),
  159. 'value': 'watch_email',
  160. 'form_field': 'select',
  161. 'field_extra': {
  162. 'choices': [
  163. ('no', _("Don't watch")),
  164. ('watch', _("Put on watched threads list")),
  165. (
  166. 'watch_email', _(
  167. "Put on watched threads "
  168. "list and e-mail user when "
  169. "somebody replies"
  170. )
  171. ),
  172. ],
  173. },
  174. },
  175. ],
  176. }
  177. )
  178. migrate_settings_group(
  179. apps, {
  180. 'key': 'captcha',
  181. 'name': _("CAPTCHA"),
  182. 'description': _(
  183. "Those settings allow you to combat automatic registrations on your forum."
  184. ),
  185. 'settings': [
  186. {
  187. 'setting': 'captcha_type',
  188. 'name': _("Select CAPTCHA type"),
  189. 'legend': _("CAPTCHA type"),
  190. 'value': 'no',
  191. 'form_field': 'select',
  192. 'field_extra': {
  193. 'choices': [
  194. ('no', _("No CAPTCHA")),
  195. ('re', _("reCaptcha")),
  196. ('qa', _("Question and answer")),
  197. ],
  198. },
  199. 'is_public': True,
  200. },
  201. {
  202. 'setting': 'recaptcha_site_key',
  203. 'name': _("Site key"),
  204. 'legend': _("reCAPTCHA"),
  205. 'value': '',
  206. 'field_extra': {
  207. 'required': False,
  208. 'max_length': 100,
  209. },
  210. 'is_public': True,
  211. },
  212. {
  213. 'setting': 'recaptcha_secret_key',
  214. 'name': _("Secret key"),
  215. 'value': '',
  216. 'field_extra': {
  217. 'required': False,
  218. 'max_length': 100,
  219. },
  220. },
  221. {
  222. 'setting': 'qa_question',
  223. 'name': _("Test question"),
  224. 'legend': _("Question and answer"),
  225. 'value': '',
  226. 'field_extra': {
  227. 'required': False,
  228. 'max_length': 250,
  229. },
  230. },
  231. {
  232. 'setting': 'qa_help_text',
  233. 'name': _("Question help text"),
  234. 'value': '',
  235. 'field_extra': {
  236. 'required': False,
  237. 'max_length': 250,
  238. },
  239. },
  240. {
  241. 'setting': 'qa_answers',
  242. 'name': _("Valid answers"),
  243. 'description': _(
  244. "Enter each answer in new line. Answers are case-insensitive."
  245. ),
  246. 'value': '',
  247. 'form_field': 'textarea',
  248. 'field_extra': {
  249. 'rows': 4,
  250. 'required': False,
  251. 'max_length': 250,
  252. },
  253. },
  254. ],
  255. }
  256. )
  257. class Migration(migrations.Migration):
  258. dependencies = [
  259. ('misago_users', '0001_initial'),
  260. ('misago_conf', '0001_initial'),
  261. ]
  262. operations = [
  263. migrations.RunPython(create_users_settings_group),
  264. ]