0002_users_settings.py 7.5 KB

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