0002_users_settings.py 10 KB

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