0002_users_settings.py 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. 'is_public': True,
  30. },
  31. {
  32. 'setting': 'default_timezone',
  33. 'name': _("Default timezone"),
  34. 'description': _("Default timezone for newly "
  35. "registered accouts as well as "
  36. "unsigned users."),
  37. 'value': 'utc',
  38. 'form_field': 'select',
  39. 'field_extra': {
  40. 'choices': '#TZ#',
  41. },
  42. },
  43. {
  44. 'setting': 'username_length_min',
  45. 'name': _("Minimum length"),
  46. 'description': _("Minimum allowed username length."),
  47. 'legend': _("User names"),
  48. 'python_type': 'int',
  49. 'value': 3,
  50. 'field_extra': {
  51. 'min_value': 2,
  52. 'max_value': 255,
  53. },
  54. },
  55. {
  56. 'setting': 'username_length_max',
  57. 'name': _("Maximum length"),
  58. 'description': _("Maximum allowed username length."),
  59. 'python_type': 'int',
  60. 'value': 14,
  61. 'field_extra': {
  62. 'min_value': 2,
  63. 'max_value': 255,
  64. },
  65. },
  66. {
  67. 'setting': 'password_length_min',
  68. 'name': _("Minimum length"),
  69. 'description': _("Minimum allowed user password length."),
  70. 'legend': _("Passwords"),
  71. 'python_type': 'int',
  72. 'value': 5,
  73. 'field_extra': {
  74. 'min_value': 2,
  75. 'max_value': 255,
  76. },
  77. },
  78. {
  79. 'setting': 'allow_custom_avatars',
  80. 'name': _("Allow custom avatars"),
  81. 'legend': _("Avatars"),
  82. 'description': _("Turning this option off will forbid "
  83. "forum users from using avatars from "
  84. "outside forums. Good for forums "
  85. "adressed at young users."),
  86. 'python_type': 'bool',
  87. 'value': True,
  88. 'form_field': 'yesno',
  89. },
  90. {
  91. 'setting': 'default_avatar',
  92. 'name': _("Default avatar"),
  93. 'value': 'gravatar',
  94. 'form_field': 'select',
  95. 'field_extra': {
  96. 'choices': (
  97. ('dynamic', _("Individual")),
  98. ('gravatar', _("Gravatar")),
  99. ('gallery', _("Random avatar from gallery")),
  100. ),
  101. },
  102. },
  103. {
  104. 'setting': 'default_gravatar_fallback',
  105. 'name': _("Fallback for default gravatar"),
  106. 'description': _("Select which avatar to use when user "
  107. "has no gravatar associated with his "
  108. "e-mail address."),
  109. 'value': 'dynamic',
  110. 'form_field': 'select',
  111. 'field_extra': {
  112. 'choices': (
  113. ('dynamic', _("Individual")),
  114. ('gallery', _("Random avatar from gallery")),
  115. ),
  116. },
  117. },
  118. {
  119. 'setting': 'avatar_upload_limit',
  120. 'name': _("Maximum size of uploaded avatar"),
  121. 'description': _("Enter maximum allowed file size "
  122. "(in KB) for avatar uploads"),
  123. 'python_type': 'int',
  124. 'value': 750,
  125. 'field_extra': {
  126. 'min_value': 0,
  127. },
  128. },
  129. {
  130. 'setting': 'signature_length_max',
  131. 'name': _("Maximum length"),
  132. 'legend': _("Signatures"),
  133. 'description': _("Maximum allowed signature length."),
  134. 'python_type': 'int',
  135. 'value': 1048,
  136. 'field_extra': {
  137. 'min_value': 256,
  138. 'max_value': 10000,
  139. },
  140. },
  141. {
  142. 'setting': 'subscribe_start',
  143. 'name': _("Started threads"),
  144. 'legend': _("Default subscriptions settings"),
  145. 'value': 'watch_email',
  146. 'form_field': 'select',
  147. 'field_extra': {
  148. 'choices': (
  149. ('no', _("Don't watch")),
  150. ('watch', _("Put on watched threads list")),
  151. ('watch_email', _("Put on watched threads "
  152. "list and e-mail user when "
  153. "somebody replies")),
  154. ),
  155. },
  156. },
  157. {
  158. 'setting': 'subscribe_reply',
  159. 'name': _("Replied threads"),
  160. 'value': 'watch_email',
  161. 'form_field': 'select',
  162. 'field_extra': {
  163. 'choices': (
  164. ('no', _("Don't watch")),
  165. ('watch', _("Put on watched threads list")),
  166. ('watch_email', _("Put on watched threads "
  167. "list and e-mail user when "
  168. "somebody replies")),
  169. ),
  170. },
  171. },
  172. )
  173. })
  174. class Migration(migrations.Migration):
  175. dependencies = [
  176. ('misago_users', '0001_initial'),
  177. ('misago_conf', '0001_initial'),
  178. ]
  179. operations = [
  180. migrations.RunPython(create_users_settings_group),
  181. ]