0002_users_settings.py 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from django.db import models, migrations
  4. from django.utils.translation import ugettext as _
  5. from misago.conf.migrationutils import migrate_settings_group
  6. def create_users_settings_group(apps, schema_editor):
  7. migrate_settings_group(
  8. apps,
  9. {
  10. 'key': 'users',
  11. 'name': _("Users"),
  12. 'description': _("Those settings control user accounts default behaviour and features availability."),
  13. 'settings': (
  14. {
  15. 'setting': 'account_activation',
  16. 'name': _("New accounts activation"),
  17. 'legend': _("New accounts"),
  18. 'value': 'none',
  19. 'form_field': 'select',
  20. 'field_extra': {
  21. 'choices': (
  22. ('none', _("No activation required")),
  23. ('user', _("Activation Token sent to User")),
  24. ('admin', _("Activation by Administrator")),
  25. ('disabled', _("Don't allow new registrations"))
  26. )
  27. },
  28. },
  29. {
  30. 'setting': 'default_timezone',
  31. 'name': _("Default timezone"),
  32. 'description': _("Default timezone for newly "
  33. "registered accouts as well as "
  34. "unsigned users."),
  35. 'value': 'utc',
  36. 'form_field': 'select',
  37. 'field_extra': {
  38. 'choices': '#TZ#',
  39. },
  40. },
  41. {
  42. 'setting': 'username_length_min',
  43. 'name': _("Minimum length"),
  44. 'description': _("Minimum allowed username length."),
  45. 'legend': _("User names"),
  46. 'python_type': 'int',
  47. 'value': 3,
  48. 'field_extra': {
  49. 'min_value': 2,
  50. 'max_value': 255,
  51. },
  52. },
  53. {
  54. 'setting': 'username_length_max',
  55. 'name': _("Maximum length"),
  56. 'description': _("Maximum allowed username length."),
  57. 'python_type': 'int',
  58. 'value': 14,
  59. 'field_extra': {
  60. 'min_value': 2,
  61. 'max_value': 255,
  62. },
  63. },
  64. {
  65. 'setting': 'password_length_min',
  66. 'name': _("Minimum length"),
  67. 'description': _("Minimum allowed user password length."),
  68. 'legend': _("Passwords"),
  69. 'python_type': 'int',
  70. 'value': 5,
  71. 'field_extra': {
  72. 'min_value': 2,
  73. 'max_value': 255,
  74. },
  75. },
  76. {
  77. 'setting': 'allow_custom_avatars',
  78. 'name': _("Allow custom avatars"),
  79. 'legend': _("Avatars"),
  80. 'description': _("Turning this option off will forbid "
  81. "forum users from using avatars from "
  82. "outside forums. Good for forums "
  83. "adressed at young users."),
  84. 'python_type': 'bool',
  85. 'value': True,
  86. 'form_field': 'yesno',
  87. },
  88. {
  89. 'setting': 'default_avatar',
  90. 'name': _("Default avatar"),
  91. 'value': 'dynamic',
  92. 'form_field': 'select',
  93. 'field_extra': {
  94. 'choices': (
  95. ('dynamic', _("Individual")),
  96. ('gravatar', _("Gravatar")),
  97. ('gallery', _("Random avatar from gallery")),
  98. ),
  99. },
  100. },
  101. {
  102. 'setting': 'avatar_upload_limit',
  103. 'name': _("Maximum size of uploaded avatar"),
  104. 'description': _("Enter maximum allowed file size "
  105. "(in KB) for avatar uploads"),
  106. 'python_type': 'int',
  107. 'value': 128,
  108. 'field_extra': {
  109. 'min_value': 0,
  110. },
  111. },
  112. {
  113. 'setting': 'signature_length_max',
  114. 'name': _("Maximum length"),
  115. 'legend': _("Signatures"),
  116. 'description': _("Maximum allowed signature length."),
  117. 'python_type': 'int',
  118. 'value': 1048,
  119. 'field_extra': {
  120. 'min_value': 256,
  121. 'max_value': 10000,
  122. },
  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. ('watch_email', _("Put on watched threads "
  135. "list and e-mail user when "
  136. "somebody replies")),
  137. ),
  138. },
  139. },
  140. {
  141. 'setting': 'subscribe_reply',
  142. 'name': _("Replied threads"),
  143. 'value': 'watch_email',
  144. 'form_field': 'select',
  145. 'field_extra': {
  146. 'choices': (
  147. ('no', _("Don't watch")),
  148. ('watch', _("Put on watched threads list")),
  149. ('watch_email', _("Put on watched threads "
  150. "list and e-mail user when "
  151. "somebody replies")),
  152. ),
  153. },
  154. },
  155. )
  156. })
  157. class Migration(migrations.Migration):
  158. dependencies = [
  159. ('misago_users', '0001_initial'),
  160. ('misago_conf', '0001_initial'),
  161. ]
  162. operations = [
  163. migrations.RunPython(create_users_settings_group),
  164. ]