0006_update_settings.py 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. 'setting': 'account_activation',
  20. 'name': _("New accounts activation"),
  21. 'legend': _("New accounts"),
  22. 'value': 'none',
  23. 'form_field': 'select',
  24. 'field_extra': {
  25. 'choices': (('none', _("No activation required")),
  26. ('user', _("Activation token sent to User")),
  27. ('admin', _("Activation by administrator")),
  28. ('closed', _("Don't allow new registrations")))
  29. },
  30. 'is_public': True,
  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. 'setting': 'username_length_max',
  44. 'name': _("Maximum length"),
  45. 'description': _("Maximum allowed username length."),
  46. 'python_type': 'int',
  47. 'default_value': 14,
  48. 'field_extra': {
  49. 'min_value': 2,
  50. 'max_value': 20,
  51. },
  52. }, {
  53. 'setting':
  54. 'allow_custom_avatars',
  55. 'name':
  56. _("Allow custom avatars"),
  57. 'legend':
  58. _("Avatars"),
  59. 'description':
  60. _(
  61. "Turning this option off will forbid "
  62. "forum users from using avatars from "
  63. "outside forums. Good for forums "
  64. "adressed at young users."
  65. ),
  66. 'python_type':
  67. 'bool',
  68. 'value':
  69. True,
  70. 'form_field':
  71. 'yesno',
  72. }, {
  73. 'setting': 'default_avatar',
  74. 'name': _("Default avatar"),
  75. 'value': 'gravatar',
  76. 'form_field': 'select',
  77. 'field_extra': {
  78. 'choices': (('dynamic', _("Individual")), ('gravatar', _("Gravatar")),
  79. ('gallery', _("Random avatar from gallery")), ),
  80. },
  81. }, {
  82. 'setting':
  83. 'default_gravatar_fallback',
  84. 'name':
  85. _("Fallback for default gravatar"),
  86. 'description':
  87. _(
  88. "Select which avatar to use when user "
  89. "has no gravatar associated with his "
  90. "e-mail address."
  91. ),
  92. 'value':
  93. 'dynamic',
  94. 'form_field':
  95. 'select',
  96. 'field_extra': {
  97. 'choices': (('dynamic', _("Individual")),
  98. ('gallery', _("Random avatar from gallery")), ),
  99. },
  100. }, {
  101. 'setting': 'avatar_upload_limit',
  102. 'name': _("Maximum size of uploaded avatar"),
  103. 'description': _("Enter maximum allowed file size "
  104. "(in KB) for avatar uploads"),
  105. 'python_type': 'int',
  106. 'default_value': 1536,
  107. 'field_extra': {
  108. 'min_value': 0,
  109. },
  110. 'is_public': True,
  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. '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': (('no', _("Don't watch")),
  131. ('watch', _("Put on watched threads list")), (
  132. 'watch_email', _(
  133. "Put on watched threads "
  134. "list and e-mail user when "
  135. "somebody replies"
  136. )
  137. ), ),
  138. },
  139. }, {
  140. 'setting': 'subscribe_reply',
  141. 'name': _("Replied threads"),
  142. 'value': 'watch_email',
  143. 'form_field': 'select',
  144. 'field_extra': {
  145. 'choices': (('no', _("Don't watch")),
  146. ('watch', _("Put on watched threads list")), (
  147. 'watch_email', _(
  148. "Put on watched threads "
  149. "list and e-mail user when "
  150. "somebody replies"
  151. )
  152. ), ),
  153. },
  154. }, )
  155. }
  156. )
  157. delete_settings_cache()
  158. class Migration(migrations.Migration):
  159. dependencies = [
  160. ('misago_users', '0005_dj_19_update'),
  161. ]
  162. operations = [
  163. migrations.RunPython(update_users_settings),
  164. ]