0002_users_settings.py 9.0 KB

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