0002_users_settings.py 10 KB

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