0002_users_settings.py 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. 'settings': (
  13. {
  14. 'setting': 'account_activation',
  15. 'name': _("New accounts activation"),
  16. 'legend': _("New accounts"),
  17. 'value': 'none',
  18. 'form_field': 'select',
  19. 'field_extra': {
  20. 'choices': (
  21. ('none', _("No activation required")),
  22. ('user', _("Activation Token sent to User")),
  23. ('admin', _("Activation by Administrator")),
  24. ('block', _("Don't allow new registrations"))
  25. )
  26. },
  27. },
  28. {
  29. 'setting': 'default_timezone',
  30. 'name': _("Default timezone"),
  31. 'description': _("Default timezone for newly "
  32. "registered accouts as well as "
  33. "unsigned users."),
  34. 'value': 'utc',
  35. 'form_field': 'select',
  36. 'field_extra': {
  37. 'choices': '#TZ#',
  38. },
  39. },
  40. {
  41. 'setting': 'username_length_min',
  42. 'name': _("Minimal allowed username length"),
  43. 'legend': _("User names"),
  44. 'python_type': 'int',
  45. 'value': 3,
  46. 'field_extra': {
  47. 'min_value': 2,
  48. 'max_value': 255,
  49. },
  50. },
  51. {
  52. 'setting': 'username_length_max',
  53. 'name': _("Maximal allowed username length"),
  54. 'python_type': 'int',
  55. 'value': 14,
  56. 'field_extra': {
  57. 'min_value': 2,
  58. 'max_value': 255,
  59. },
  60. },
  61. {
  62. 'setting': 'password_length_min',
  63. 'name': _("Minimum user password length"),
  64. 'legend': _("Passwords"),
  65. 'python_type': 'int',
  66. 'value': 5,
  67. 'field_extra': {
  68. 'min_value': 2,
  69. 'max_value': 255,
  70. },
  71. },
  72. {
  73. 'setting': 'avatars_types',
  74. 'name': _("Available avatar types"),
  75. 'legend': _("Avatars"),
  76. 'python_type': 'list',
  77. 'value': ['gravatar', 'upload'],
  78. 'form_field': 'checkbox',
  79. 'field_extra': {
  80. 'choices': (
  81. ('gravatar', _("Gravatar")),
  82. ('upload', _("Uploaded avatar")),
  83. ('gallery', _("Avatars gallery"))
  84. ),
  85. 'min': 1,
  86. },
  87. },
  88. {
  89. 'setting': 'default_avatar',
  90. 'name': _("Default avatar"),
  91. 'value': 'gravatar',
  92. 'form_field': 'select',
  93. 'field_extra': {
  94. 'choices': (
  95. ('gravatar', _("Gravatar")),
  96. ('gallery', _("Random avatar from gallery")),
  97. ),
  98. },
  99. },
  100. {
  101. 'setting': 'avatar_upload_limit',
  102. 'name': _("Maximum size of uploaded avatar"),
  103. 'description': _("Enter maximum allowed file size "
  104. "(in KB) for avatar uploads"),
  105. 'python_type': 'int',
  106. 'value': 128,
  107. 'field_extra': {
  108. 'min_value': 0,
  109. },
  110. },
  111. {
  112. 'setting': 'subscribe_start',
  113. 'name': _("Subscribe to started threads"),
  114. 'legend': _("Default subscriptions settings"),
  115. 'value': 'watch_email',
  116. 'form_field': 'select',
  117. 'field_extra': {
  118. 'choices': (
  119. ('no', _("Don't watch")),
  120. ('', _("Put on watched threads list")),
  121. ('watch_email', _("Put on watched threads "
  122. "list and e-mail user when "
  123. "somebody replies")),
  124. ),
  125. },
  126. },
  127. {
  128. 'setting': 'subscribe_reply',
  129. 'name': _("Subscribe to replied threads"),
  130. 'value': 'watch_email',
  131. 'form_field': 'select',
  132. 'field_extra': {
  133. 'choices': (
  134. ('no', _("Don't watch")),
  135. ('', _("Put on watched threads list")),
  136. ('watch_email', _("Put on watched threads "
  137. "list and e-mail user when "
  138. "somebody replies")),
  139. ),
  140. },
  141. },
  142. )
  143. })
  144. class Migration(migrations.Migration):
  145. dependencies = [
  146. ('misago_users', '0001_initial'),
  147. ('misago_conf', '0001_initial'),
  148. ]
  149. operations = [
  150. migrations.RunPython(create_users_settings_group),
  151. ]