0002_users_settings.py 9.3 KB

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