0006_update_settings.py 6.8 KB

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