0002_users_settings.py 9.4 KB

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