0002_users_settings.py 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. from django.db import migrations
  2. from misago.conf.migrationutils import migrate_settings_group
  3. _ = lambda s: s
  4. def create_users_settings_group(apps, schema_editor):
  5. migrate_settings_group(
  6. apps, {
  7. 'key': 'users',
  8. 'name': _("Users"),
  9. 'description': _(
  10. "Those settings control user accounts default behaviour and features availability."
  11. ),
  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': _(
  72. "Turning this option off will forbid "
  73. "forum users from using avatars from "
  74. "outside forums. Good for forums "
  75. "adressed at young users."
  76. ),
  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': _(
  98. "Select which avatar to use when user has no "
  99. "gravatar associated with his e-mail address."
  100. ),
  101. 'value': 'dynamic',
  102. 'form_field': 'select',
  103. 'field_extra': {
  104. 'choices': [
  105. ('dynamic', _("Individual")),
  106. ('gallery', _("Random avatar from gallery")),
  107. ],
  108. },
  109. },
  110. {
  111. 'setting': 'avatar_upload_limit',
  112. 'name': _("Maximum size of uploaded avatar"),
  113. 'description': _("Enter maximum allowed file size (in KB) for avatar uploads."),
  114. 'python_type': 'int',
  115. 'value': 1536,
  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. (
  145. 'watch_email', _(
  146. "Put on watched threads "
  147. "list and e-mail user when "
  148. "somebody replies"
  149. )
  150. ),
  151. ],
  152. },
  153. },
  154. {
  155. 'setting': 'subscribe_reply',
  156. 'name': _("Replied threads"),
  157. 'value': 'watch_email',
  158. 'form_field': 'select',
  159. 'field_extra': {
  160. 'choices': [
  161. ('no', _("Don't watch")),
  162. ('watch', _("Put on watched threads list")),
  163. (
  164. 'watch_email', _(
  165. "Put on watched threads "
  166. "list and e-mail user when "
  167. "somebody replies"
  168. )
  169. ),
  170. ],
  171. },
  172. },
  173. ],
  174. }
  175. )
  176. migrate_settings_group(
  177. apps, {
  178. 'key': 'captcha',
  179. 'name': _("CAPTCHA"),
  180. 'description': _("Those settings allow you to combat automatic 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. Answers are case-insensitive."),
  240. 'value': '',
  241. 'form_field': 'textarea',
  242. 'field_extra': {
  243. 'rows': 4,
  244. 'required': False,
  245. 'max_length': 250,
  246. },
  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. ]