0002_users_settings.py 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from django.conf import settings
  4. from django.db import models, migrations
  5. from django.utils.translation import ugettext as _
  6. from misago.conf.migrationutils import migrate_settings_group
  7. def create_users_settings_group(apps, schema_editor):
  8. migrate_settings_group(
  9. apps,
  10. {
  11. 'key': 'users',
  12. 'name': _("Users"),
  13. 'description': _("Those settings control user accounts default behaviour and features availability."),
  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': _("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. 'python_type': 'bool',
  78. 'value': True,
  79. 'form_field': 'yesno',
  80. },
  81. {
  82. 'setting': 'default_avatar',
  83. 'name': _("Default avatar"),
  84. 'value': 'gravatar',
  85. 'form_field': 'select',
  86. 'field_extra': {
  87. 'choices': (
  88. ('dynamic', _("Individual")),
  89. ('gravatar', _("Gravatar")),
  90. ('gallery', _("Random avatar from gallery")),
  91. ),
  92. },
  93. },
  94. {
  95. 'setting': 'default_gravatar_fallback',
  96. 'name': _("Fallback for default gravatar"),
  97. 'description': _("Select which avatar to use when user "
  98. "has no gravatar associated with his "
  99. "e-mail address."),
  100. 'value': 'dynamic',
  101. 'form_field': 'select',
  102. 'field_extra': {
  103. 'choices': (
  104. ('dynamic', _("Individual")),
  105. ('gallery', _("Random avatar from gallery")),
  106. ),
  107. },
  108. },
  109. {
  110. 'setting': 'avatar_upload_limit',
  111. 'name': _("Maximum size of uploaded avatar"),
  112. 'description': _("Enter maximum allowed file size "
  113. "(in KB) for avatar uploads"),
  114. 'python_type': 'int',
  115. 'value': 750,
  116. 'field_extra': {
  117. 'min_value': 0,
  118. },
  119. 'is_public': True,
  120. },
  121. {
  122. 'setting': 'signature_length_max',
  123. 'name': _("Maximum length"),
  124. 'legend': _("Signatures"),
  125. 'description': _("Maximum allowed signature length."),
  126. 'python_type': 'int',
  127. 'value': 256,
  128. 'field_extra': {
  129. 'min_value': 10,
  130. 'max_value': 5000,
  131. },
  132. 'is_public': True,
  133. },
  134. {
  135. 'setting': 'subscribe_start',
  136. 'name': _("Started threads"),
  137. 'legend': _("Default subscriptions settings"),
  138. 'value': 'watch_email',
  139. 'form_field': 'select',
  140. 'field_extra': {
  141. 'choices': (
  142. ('no', _("Don't watch")),
  143. ('watch', _("Put on watched threads list")),
  144. ('watch_email', _("Put on watched threads "
  145. "list and e-mail user when "
  146. "somebody replies")),
  147. ),
  148. },
  149. },
  150. {
  151. 'setting': 'subscribe_reply',
  152. 'name': _("Replied threads"),
  153. 'value': 'watch_email',
  154. 'form_field': 'select',
  155. 'field_extra': {
  156. 'choices': (
  157. ('no', _("Don't watch")),
  158. ('watch', _("Put on watched threads list")),
  159. ('watch_email', _("Put on watched threads "
  160. "list and e-mail user when "
  161. "somebody replies")),
  162. ),
  163. },
  164. },
  165. )
  166. })
  167. migrate_settings_group(
  168. apps,
  169. {
  170. 'key': 'captcha',
  171. 'name': _("CAPTCHA"),
  172. 'description': _("Those settings allow you to combat automatic "
  173. "registrations on your forum."),
  174. 'settings': (
  175. {
  176. 'setting': 'captcha_type',
  177. 'name': _("Select CAPTCHA type"),
  178. 'legend': _("CAPTCHA type"),
  179. 'value': 'no',
  180. 'form_field': 'select',
  181. 'field_extra': {
  182. 'choices': (
  183. ('no', _("No CAPTCHA")),
  184. ('re', _("reCaptcha")),
  185. ('qa', _("Question and answer")),
  186. ),
  187. },
  188. 'is_public': True,
  189. },
  190. {
  191. 'setting': 'recaptcha_site_key',
  192. 'name': _("Site key"),
  193. 'legend': _("reCAPTCHA"),
  194. 'value': '',
  195. 'field_extra': {
  196. 'required': False,
  197. 'max_length': 100,
  198. },
  199. 'is_public': True,
  200. },
  201. {
  202. 'setting': 'recaptcha_secret_key',
  203. 'name': _("Secret key"),
  204. 'value': '',
  205. 'field_extra': {
  206. 'required': False,
  207. 'max_length': 100,
  208. },
  209. },
  210. {
  211. 'setting': 'qa_question',
  212. 'name': _("Test question"),
  213. 'legend': _("Question and answer"),
  214. 'value': '',
  215. 'field_extra': {
  216. 'required': False,
  217. 'max_length': 250,
  218. },
  219. },
  220. {
  221. 'setting': 'qa_help_text',
  222. 'name': _("Question help text"),
  223. 'value': '',
  224. 'field_extra': {
  225. 'required': False,
  226. 'max_length': 250,
  227. },
  228. },
  229. {
  230. 'setting': 'qa_answers',
  231. 'name': _("Valid answers"),
  232. 'description': _("Enter each answer in new line. "
  233. "Answers are case-insensitive."),
  234. 'value': '',
  235. 'form_field': 'textarea',
  236. 'field_extra': {
  237. 'rows': 4,
  238. 'required': False,
  239. 'max_length': 250,
  240. },
  241. },
  242. )
  243. })
  244. class Migration(migrations.Migration):
  245. dependencies = [
  246. ('misago_users', '0001_initial'),
  247. ('misago_conf', '0001_initial'),
  248. ]
  249. operations = [
  250. migrations.RunPython(create_users_settings_group),
  251. ]