0002_users_settings.py 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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': _("Minimal allowed username length"),
  44. 'legend': _("User names"),
  45. 'python_type': 'int',
  46. 'value': 3,
  47. 'field_extra': {
  48. 'min_value': 2,
  49. 'max_value': 255,
  50. },
  51. },
  52. {
  53. 'setting': 'username_length_max',
  54. 'name': _("Maximal allowed username length"),
  55. 'python_type': 'int',
  56. 'value': 14,
  57. 'field_extra': {
  58. 'min_value': 2,
  59. 'max_value': 255,
  60. },
  61. },
  62. {
  63. 'setting': 'password_length_min',
  64. 'name': _("Minimum user password length"),
  65. 'legend': _("Passwords"),
  66. 'python_type': 'int',
  67. 'value': 5,
  68. 'field_extra': {
  69. 'min_value': 2,
  70. 'max_value': 255,
  71. },
  72. },
  73. {
  74. 'setting': 'avatars_types',
  75. 'name': _("Available avatar types"),
  76. 'legend': _("Avatars"),
  77. 'python_type': 'list',
  78. 'value': ['gravatar', 'upload'],
  79. 'form_field': 'checkbox',
  80. 'field_extra': {
  81. 'choices': (
  82. ('gravatar', _("Gravatar")),
  83. ('upload', _("Uploaded avatar")),
  84. ('gallery', _("Avatars gallery"))
  85. ),
  86. 'min': 1,
  87. },
  88. },
  89. {
  90. 'setting': 'default_avatar',
  91. 'name': _("Default avatar"),
  92. 'value': 'gravatar',
  93. 'form_field': 'select',
  94. 'field_extra': {
  95. 'choices': (
  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': 'subscribe_start',
  114. 'name': _("Subscribe to started threads"),
  115. 'legend': _("Default subscriptions settings"),
  116. 'value': 'watch_email',
  117. 'form_field': 'select',
  118. 'field_extra': {
  119. 'choices': (
  120. ('no', _("Don't watch")),
  121. ('', _("Put on watched threads list")),
  122. ('watch_email', _("Put on watched threads "
  123. "list and e-mail user when "
  124. "somebody replies")),
  125. ),
  126. },
  127. },
  128. {
  129. 'setting': 'subscribe_reply',
  130. 'name': _("Subscribe to replied threads"),
  131. 'value': 'watch_email',
  132. 'form_field': 'select',
  133. 'field_extra': {
  134. 'choices': (
  135. ('no', _("Don't watch")),
  136. ('', _("Put on watched threads list")),
  137. ('watch_email', _("Put on watched threads "
  138. "list and e-mail user when "
  139. "somebody replies")),
  140. ),
  141. },
  142. },
  143. )
  144. })
  145. class Migration(migrations.Migration):
  146. dependencies = [
  147. ('misago_users', '0001_initial'),
  148. ('misago_conf', '0001_initial'),
  149. ]
  150. operations = [
  151. migrations.RunPython(create_users_settings_group),
  152. ]