0002_users_settings.py 9.0 KB

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