0002_users_settings.py 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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 s: s
  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': _("Those settings allow you to combat automatic registrations on your forum."),
  183. 'settings': [
  184. {
  185. 'setting': 'captcha_type',
  186. 'name': _("Select CAPTCHA type"),
  187. 'legend': _("CAPTCHA type"),
  188. 'value': 'no',
  189. 'form_field': 'select',
  190. 'field_extra': {
  191. 'choices': [
  192. ('no', _("No CAPTCHA")),
  193. ('re', _("reCaptcha")),
  194. ('qa', _("Question and answer")),
  195. ],
  196. },
  197. 'is_public': True,
  198. },
  199. {
  200. 'setting': 'recaptcha_site_key',
  201. 'name': _("Site key"),
  202. 'legend': _("reCAPTCHA"),
  203. 'value': '',
  204. 'field_extra': {
  205. 'required': False,
  206. 'max_length': 100,
  207. },
  208. 'is_public': True,
  209. },
  210. {
  211. 'setting': 'recaptcha_secret_key',
  212. 'name': _("Secret key"),
  213. 'value': '',
  214. 'field_extra': {
  215. 'required': False,
  216. 'max_length': 100,
  217. },
  218. },
  219. {
  220. 'setting': 'qa_question',
  221. 'name': _("Test question"),
  222. 'legend': _("Question and answer"),
  223. 'value': '',
  224. 'field_extra': {
  225. 'required': False,
  226. 'max_length': 250,
  227. },
  228. },
  229. {
  230. 'setting': 'qa_help_text',
  231. 'name': _("Question help text"),
  232. 'value': '',
  233. 'field_extra': {
  234. 'required': False,
  235. 'max_length': 250,
  236. },
  237. },
  238. {
  239. 'setting': 'qa_answers',
  240. 'name': _("Valid answers"),
  241. 'description': _("Enter each answer in new line. Answers are case-insensitive."),
  242. 'value': '',
  243. 'form_field': 'textarea',
  244. 'field_extra': {
  245. 'rows': 4,
  246. 'required': False,
  247. 'max_length': 250,
  248. },
  249. },
  250. ],
  251. }
  252. )
  253. class Migration(migrations.Migration):
  254. dependencies = [
  255. ('misago_users', '0001_initial'),
  256. ('misago_conf', '0001_initial'),
  257. ]
  258. operations = [
  259. migrations.RunPython(create_users_settings_group),
  260. ]