0006_update_settings.py 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. # -*- coding: utf-8 -*-
  2. # Generated by Django 1.10.5 on 2017-02-05 14:34
  3. from __future__ import unicode_literals
  4. from django.db import migrations
  5. from misago.conf.migrationutils import delete_settings_cache, migrate_settings_group
  6. _ = lambda x: x
  7. def update_users_settings(apps, schema_editor):
  8. migrate_settings_group(
  9. apps, {
  10. 'key':
  11. 'users',
  12. 'name':
  13. _("Users"),
  14. 'description':
  15. _(
  16. "Those settings control user accounts default behaviour and features availability."
  17. ),
  18. 'settings': [
  19. {
  20. 'setting': 'account_activation',
  21. 'name': _("New accounts activation"),
  22. 'legend': _("New accounts"),
  23. 'value': 'none',
  24. 'form_field': 'select',
  25. 'field_extra': {
  26. 'choices': [
  27. ('none', _("No activation required")),
  28. ('user', _("Activation token sent to User")),
  29. ('admin', _("Activation by administrator")),
  30. ('closed', _("Don't allow new registrations")),
  31. ],
  32. },
  33. 'is_public': True,
  34. },
  35. {
  36. 'setting': 'username_length_min',
  37. 'name': _("Minimum length"),
  38. 'description': _("Minimum allowed username length."),
  39. 'legend': _("User names"),
  40. 'python_type': 'int',
  41. 'default_value': 3,
  42. 'field_extra': {
  43. 'min_value': 2,
  44. 'max_value': 20,
  45. },
  46. },
  47. {
  48. 'setting': 'username_length_max',
  49. 'name': _("Maximum length"),
  50. 'description': _("Maximum allowed username length."),
  51. 'python_type': 'int',
  52. 'default_value': 14,
  53. 'field_extra': {
  54. 'min_value': 2,
  55. 'max_value': 20,
  56. },
  57. },
  58. {
  59. 'setting':
  60. 'allow_custom_avatars',
  61. 'name':
  62. _("Allow custom avatars"),
  63. 'legend':
  64. _("Avatars"),
  65. 'description':
  66. _(
  67. "Turning this option off will forbid "
  68. "forum users from using avatars from "
  69. "outside forums. Good for forums "
  70. "adressed at young users."
  71. ),
  72. 'python_type':
  73. 'bool',
  74. 'value':
  75. True,
  76. 'form_field':
  77. 'yesno',
  78. },
  79. {
  80. 'setting': 'default_avatar',
  81. 'name': _("Default avatar"),
  82. 'value': 'gravatar',
  83. 'form_field': 'select',
  84. 'field_extra': {
  85. 'choices': [
  86. ('dynamic', _("Individual")),
  87. ('gravatar', _("Gravatar")),
  88. ('gallery', _("Random avatar from gallery")),
  89. ],
  90. },
  91. },
  92. {
  93. 'setting':
  94. 'default_gravatar_fallback',
  95. 'name':
  96. _("Fallback for default gravatar"),
  97. 'description':
  98. _(
  99. "Select which avatar to use when user "
  100. "has no gravatar associated with his "
  101. "e-mail address."
  102. ),
  103. 'value':
  104. 'dynamic',
  105. 'form_field':
  106. 'select',
  107. 'field_extra': {
  108. 'choices': [
  109. ('dynamic', _("Individual")),
  110. ('gallery', _("Random avatar from gallery")),
  111. ],
  112. },
  113. },
  114. {
  115. 'setting':
  116. 'avatar_upload_limit',
  117. 'name':
  118. _("Maximum size of uploaded avatar"),
  119. 'description':
  120. _("Enter maximum allowed file size "
  121. "(in KB) for avatar uploads"),
  122. 'python_type':
  123. 'int',
  124. 'default_value':
  125. 1536,
  126. 'field_extra': {
  127. 'min_value': 0,
  128. },
  129. 'is_public':
  130. True,
  131. },
  132. {
  133. 'setting': 'signature_length_max',
  134. 'name': _("Maximum length"),
  135. 'legend': _("Signatures"),
  136. 'description': _("Maximum allowed signature length."),
  137. 'python_type': 'int',
  138. 'default_value': 256,
  139. 'field_extra': {
  140. 'min_value': 10,
  141. 'max_value': 5000,
  142. },
  143. 'is_public': True,
  144. },
  145. {
  146. 'setting': 'subscribe_start',
  147. 'name': _("Started threads"),
  148. 'legend': _("Default subscriptions settings"),
  149. 'value': 'watch_email',
  150. 'form_field': 'select',
  151. 'field_extra': {
  152. 'choices': [
  153. ('no', _("Don't watch")),
  154. ('watch', _("Put on watched threads list")),
  155. (
  156. 'watch_email', _(
  157. "Put on watched threads "
  158. "list and e-mail user when "
  159. "somebody replies"
  160. )
  161. ),
  162. ],
  163. },
  164. },
  165. {
  166. 'setting': 'subscribe_reply',
  167. 'name': _("Replied threads"),
  168. 'value': 'watch_email',
  169. 'form_field': 'select',
  170. 'field_extra': {
  171. 'choices': [
  172. ('no', _("Don't watch")),
  173. ('watch', _("Put on watched threads list")),
  174. (
  175. 'watch_email', _(
  176. "Put on watched threads "
  177. "list and e-mail user when "
  178. "somebody replies"
  179. )
  180. ),
  181. ],
  182. },
  183. },
  184. ],
  185. }
  186. )
  187. delete_settings_cache()
  188. class Migration(migrations.Migration):
  189. dependencies = [
  190. ('misago_users', '0005_dj_19_update'),
  191. ]
  192. operations = [
  193. migrations.RunPython(update_users_settings),
  194. ]