0002_db_settings.py 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. # -*- coding: utf-8 -*-
  2. from south.utils import datetime_utils as datetime
  3. from south.db import db
  4. from south.v2 import DataMigration
  5. from django.db import models
  6. from misago.conf.migrationutils import migrate_settings_group, with_conf_models
  7. from misago.core.migrationutils import ugettext_lazy as _
  8. class Migration(DataMigration):
  9. def forwards(self, orm):
  10. "Write your forwards methods here."
  11. migrate_settings_group(
  12. orm,
  13. {
  14. 'key': 'users',
  15. 'name': _("Users"),
  16. 'settings': (
  17. {
  18. 'setting': 'account_activation',
  19. 'name': _("New accounts activation"),
  20. 'legend': _("New accounts"),
  21. 'value': 'none',
  22. 'form_field': 'select',
  23. 'field_extra': {
  24. 'choices': (
  25. ('none', _("No activation required")),
  26. ('user', _("Activation Token sent to User")),
  27. ('admin', _("Activation by Administrator")),
  28. ('block', _("Don't allow new registrations"))
  29. )
  30. },
  31. },
  32. {
  33. 'setting': 'default_timezone',
  34. 'name': _("Default timezone"),
  35. 'description': _("Default timezone for newly "
  36. "registered accouts as well as "
  37. "unsigned users."),
  38. 'value': 'utc',
  39. 'form_field': 'select',
  40. 'field_extra': {
  41. 'choices': '#TZ#',
  42. },
  43. },
  44. {
  45. 'setting': 'username_length_min',
  46. 'name': _("Minimal 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': _("Maximal 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 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. },
  90. },
  91. {
  92. 'setting': 'default_avatar',
  93. 'name': _("Default avatar"),
  94. 'value': 'gravatar',
  95. 'form_field': 'select',
  96. 'field_extra': {
  97. 'choices': (
  98. ('gravatar', _("Gravatar")),
  99. ('gallery', _("Random avatar from gallery")),
  100. ),
  101. },
  102. },
  103. {
  104. 'setting': 'avatar_upload_limit',
  105. 'name': _("Maximum size of uploaded avatar"),
  106. 'description': _("Enter maximum allowed file size "
  107. "(in KB) for avatar uploads"),
  108. 'python_type': 'int',
  109. 'value': 128,
  110. 'field_extra': {
  111. 'min_value': 0,
  112. },
  113. },
  114. {
  115. 'setting': 'subscribe_start',
  116. 'name': _("Subscribe to started threads"),
  117. 'legend': _("Default subscriptions settings"),
  118. 'value': 'watch_email',
  119. 'form_field': 'select',
  120. 'field_extra': {
  121. 'choices': (
  122. ('no', _("Don't watch")),
  123. ('', _("Put on watched threads list")),
  124. ('watch_email', _("Put on watched threads "
  125. "list and e-mail user when "
  126. "somebody replies")),
  127. ),
  128. },
  129. },
  130. {
  131. 'setting': 'subscribe_reply',
  132. 'name': _("Subscribe to replied threads"),
  133. 'value': 'watch_email',
  134. 'form_field': 'select',
  135. 'field_extra': {
  136. 'choices': (
  137. ('no', _("Don't watch")),
  138. ('', _("Put on watched threads list")),
  139. ('watch_email', _("Put on watched threads "
  140. "list and e-mail user when "
  141. "somebody replies")),
  142. ),
  143. },
  144. },
  145. )
  146. },
  147. )
  148. def backwards(self, orm):
  149. "Write your backwards methods here."
  150. models = with_conf_models('0001_initial')
  151. complete_apps = ['core']
  152. symmetrical = True
  153. depends_on = (
  154. ("conf", "0001_initial"),
  155. )