0002_users_settings.py 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. ('block', _("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': 'avatars_types',
  78. 'name': _("Available avatar types"),
  79. 'legend': _("Avatars"),
  80. 'python_type': 'list',
  81. 'value': ['gravatar', 'upload'],
  82. 'form_field': 'checkbox',
  83. 'field_extra': {
  84. 'choices': (
  85. ('gravatar', _("Gravatar")),
  86. ('upload', _("Uploaded avatar")),
  87. ('gallery', _("Avatars gallery"))
  88. ),
  89. 'min': 1,
  90. },
  91. },
  92. {
  93. 'setting': 'default_avatar',
  94. 'name': _("Default avatar"),
  95. 'value': 'gravatar',
  96. 'form_field': 'select',
  97. 'field_extra': {
  98. 'choices': (
  99. ('gravatar', _("Gravatar")),
  100. ('gallery', _("Random avatar from gallery")),
  101. ),
  102. },
  103. },
  104. {
  105. 'setting': 'avatar_upload_limit',
  106. 'name': _("Maximum size of uploaded avatar"),
  107. 'description': _("Enter maximum allowed file size "
  108. "(in KB) for avatar uploads"),
  109. 'python_type': 'int',
  110. 'value': 128,
  111. 'field_extra': {
  112. 'min_value': 0,
  113. },
  114. },
  115. {
  116. 'setting': 'subscribe_start',
  117. 'name': _("Started threads"),
  118. 'legend': _("Default subscriptions settings"),
  119. 'value': 'watch_email',
  120. 'form_field': 'select',
  121. 'field_extra': {
  122. 'choices': (
  123. ('no', _("Don't watch")),
  124. ('', _("Put on watched threads list")),
  125. ('watch_email', _("Put on watched threads "
  126. "list and e-mail user when "
  127. "somebody replies")),
  128. ),
  129. },
  130. },
  131. {
  132. 'setting': 'subscribe_reply',
  133. 'name': _("Replied threads"),
  134. 'value': 'watch_email',
  135. 'form_field': 'select',
  136. 'field_extra': {
  137. 'choices': (
  138. ('no', _("Don't watch")),
  139. ('', _("Put on watched threads list")),
  140. ('watch_email', _("Put on watched threads "
  141. "list and e-mail user when "
  142. "somebody replies")),
  143. ),
  144. },
  145. },
  146. )
  147. })
  148. class Migration(migrations.Migration):
  149. dependencies = [
  150. ('misago_users', '0001_initial'),
  151. ('misago_conf', '0001_initial'),
  152. ]
  153. operations = [
  154. migrations.RunPython(create_users_settings_group),
  155. ]