0002_users_settings.py 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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 "
  101. "has no gravatar associated with his "
  102. "e-mail address."
  103. ),
  104. 'value': 'dynamic',
  105. 'form_field': 'select',
  106. 'field_extra': {
  107. 'choices': [
  108. ('dynamic', _("Individual")),
  109. ('gallery', _("Random avatar from gallery")),
  110. ],
  111. },
  112. },
  113. {
  114. 'setting': 'avatar_upload_limit',
  115. 'name': _("Maximum size of uploaded avatar"),
  116. 'description': _(
  117. "Enter maximum allowed file size "
  118. "(in KB) for avatar uploads"
  119. ),
  120. 'python_type': 'int',
  121. 'value': 1536,
  122. 'field_extra': {
  123. 'min_value': 0,
  124. },
  125. 'is_public': True,
  126. },
  127. {
  128. 'setting': 'signature_length_max',
  129. 'name': _("Maximum length"),
  130. 'legend': _("Signatures"),
  131. 'description': _("Maximum allowed signature length."),
  132. 'python_type': 'int',
  133. 'value': 256,
  134. 'field_extra': {
  135. 'min_value': 10,
  136. 'max_value': 5000,
  137. },
  138. 'is_public': True,
  139. },
  140. {
  141. 'setting': 'subscribe_start',
  142. 'name': _("Started threads"),
  143. 'legend': _("Default subscriptions settings"),
  144. 'value': 'watch_email',
  145. 'form_field': 'select',
  146. 'field_extra': {
  147. 'choices': [
  148. ('no', _("Don't watch")),
  149. ('watch', _("Put on watched threads list")),
  150. (
  151. 'watch_email', _(
  152. "Put on watched threads "
  153. "list and e-mail user when "
  154. "somebody replies"
  155. )
  156. ),
  157. ],
  158. },
  159. },
  160. {
  161. 'setting': 'subscribe_reply',
  162. 'name': _("Replied threads"),
  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. }
  181. )
  182. migrate_settings_group(
  183. apps, {
  184. 'key': 'captcha',
  185. 'name': _("CAPTCHA"),
  186. 'description': _(
  187. "Those settings allow you to combat automatic "
  188. "registrations on your forum."
  189. ),
  190. 'settings': [
  191. {
  192. 'setting': 'captcha_type',
  193. 'name': _("Select CAPTCHA type"),
  194. 'legend': _("CAPTCHA type"),
  195. 'value': 'no',
  196. 'form_field': 'select',
  197. 'field_extra': {
  198. 'choices': [
  199. ('no', _("No CAPTCHA")),
  200. ('re', _("reCaptcha")),
  201. ('qa', _("Question and answer")),
  202. ],
  203. },
  204. 'is_public': True,
  205. },
  206. {
  207. 'setting': 'recaptcha_site_key',
  208. 'name': _("Site key"),
  209. 'legend': _("reCAPTCHA"),
  210. 'value': '',
  211. 'field_extra': {
  212. 'required': False,
  213. 'max_length': 100,
  214. },
  215. 'is_public': True,
  216. },
  217. {
  218. 'setting': 'recaptcha_secret_key',
  219. 'name': _("Secret key"),
  220. 'value': '',
  221. 'field_extra': {
  222. 'required': False,
  223. 'max_length': 100,
  224. },
  225. },
  226. {
  227. 'setting': 'qa_question',
  228. 'name': _("Test question"),
  229. 'legend': _("Question and answer"),
  230. 'value': '',
  231. 'field_extra': {
  232. 'required': False,
  233. 'max_length': 250,
  234. },
  235. },
  236. {
  237. 'setting': 'qa_help_text',
  238. 'name': _("Question help text"),
  239. 'value': '',
  240. 'field_extra': {
  241. 'required': False,
  242. 'max_length': 250,
  243. },
  244. },
  245. {
  246. 'setting': 'qa_answers',
  247. 'name': _("Valid answers"),
  248. 'description': _(
  249. "Enter each answer in new line. "
  250. "Answers are case-insensitive."
  251. ),
  252. 'value': '',
  253. 'form_field': 'textarea',
  254. 'field_extra': {
  255. 'rows': 4,
  256. 'required': False,
  257. 'max_length': 250,
  258. },
  259. },
  260. ],
  261. }
  262. )
  263. class Migration(migrations.Migration):
  264. dependencies = [
  265. ('misago_users', '0001_initial'),
  266. ('misago_conf', '0001_initial'),
  267. ]
  268. operations = [
  269. migrations.RunPython(create_users_settings_group),
  270. ]