0006_update_settings.py 6.9 KB

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