0002_users_settings.py 11 KB

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