0002_users_settings.py 10 KB

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