0002_users_settings.py 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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': 'default_gravatar_fallback',
  103. 'name': _("Fallback for default gravatar"),
  104. 'description': _("Select which avatar to use when user "
  105. "has no gravatar associated with his "
  106. "e-mail address."),
  107. 'value': 'dynamic',
  108. 'form_field': 'select',
  109. 'field_extra': {
  110. 'choices': (
  111. ('dynamic', _("Individual")),
  112. ('gallery', _("Random avatar from gallery")),
  113. ),
  114. },
  115. },
  116. {
  117. 'setting': 'avatar_upload_limit',
  118. 'name': _("Maximum size of uploaded avatar"),
  119. 'description': _("Enter maximum allowed file size "
  120. "(in KB) for avatar uploads"),
  121. 'python_type': 'int',
  122. 'value': 128,
  123. 'field_extra': {
  124. 'min_value': 0,
  125. },
  126. },
  127. {
  128. 'setting': 'signature_length_max',
  129. 'name': _("Maximum length"),
  130. 'legend': _("Signatures"),
  131. 'description': _("Maximum allowed signature length."),
  132. 'python_type': 'int',
  133. 'value': 1048,
  134. 'field_extra': {
  135. 'min_value': 256,
  136. 'max_value': 10000,
  137. },
  138. },
  139. {
  140. 'setting': 'subscribe_start',
  141. 'name': _("Started threads"),
  142. 'legend': _("Default subscriptions settings"),
  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. 'setting': 'subscribe_reply',
  157. 'name': _("Replied threads"),
  158. 'value': 'watch_email',
  159. 'form_field': 'select',
  160. 'field_extra': {
  161. 'choices': (
  162. ('no', _("Don't watch")),
  163. ('watch', _("Put on watched threads list")),
  164. ('watch_email', _("Put on watched threads "
  165. "list and e-mail user when "
  166. "somebody replies")),
  167. ),
  168. },
  169. },
  170. )
  171. })
  172. class Migration(migrations.Migration):
  173. dependencies = [
  174. ('misago_users', '0001_initial'),
  175. ('misago_conf', '0001_initial'),
  176. ]
  177. operations = [
  178. migrations.RunPython(create_users_settings_group),
  179. ]