0006_update_settings.py 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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': _(
  102. "Enter maximum allowed file size (in KB) for avatar uploads."
  103. ),
  104. 'python_type': 'int',
  105. 'default_value': 1536,
  106. 'field_extra': {
  107. 'min_value': 0,
  108. },
  109. 'is_public': True,
  110. },
  111. {
  112. 'setting': 'signature_length_max',
  113. 'name': _("Maximum length"),
  114. 'legend': _("Signatures"),
  115. 'description': _("Maximum allowed signature length."),
  116. 'python_type': 'int',
  117. 'default_value': 256,
  118. 'field_extra': {
  119. 'min_value': 10,
  120. 'max_value': 5000,
  121. },
  122. 'is_public': True,
  123. },
  124. {
  125. 'setting': 'subscribe_start',
  126. 'name': _("Started threads"),
  127. 'legend': _("Default subscriptions settings"),
  128. 'value': 'watch_email',
  129. 'form_field': 'select',
  130. 'field_extra': {
  131. 'choices': [
  132. ('no', _("Don't watch")),
  133. ('watch', _("Put on watched threads list")),
  134. (
  135. 'watch_email', _(
  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. "Put on watched threads "
  156. "list and e-mail user when "
  157. "somebody replies"
  158. )
  159. ),
  160. ],
  161. },
  162. },
  163. ],
  164. }
  165. )
  166. delete_settings_cache()
  167. class Migration(migrations.Migration):
  168. dependencies = [
  169. ('misago_users', '0005_dj_19_update'),
  170. ]
  171. operations = [
  172. migrations.RunPython(update_users_settings),
  173. ]