0002_users_settings.py 10 KB

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