0002_db_settings.py 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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': 'password_complexity',
  78. 'name': _("Complexity"),
  79. 'python_type': 'list',
  80. 'value': [],
  81. 'form_field': 'checkbox',
  82. 'field_extra': {
  83. 'choices': (
  84. ('case', _("Require mixed Case")),
  85. ('alphanumerics', _("Require alphanumeric characters")),
  86. ('special', _("Require special characters"))
  87. ),
  88. },
  89. },
  90. {
  91. 'setting': 'avatars_types',
  92. 'name': _("Available avatar types"),
  93. 'legend': _("Avatars"),
  94. 'python_type': 'list',
  95. 'value': ['gravatar', 'upload'],
  96. 'form_field': 'checkbox',
  97. 'field_extra': {
  98. 'choices': (
  99. ('gravatar', _("Gravatar")),
  100. ('upload', _("Uploaded avatar")),
  101. ('gallery', _("Avatars gallery"))
  102. ),
  103. },
  104. },
  105. {
  106. 'setting': 'default_avatar',
  107. 'name': _("Default avatar"),
  108. 'value': 'gravatar',
  109. 'form_field': 'select',
  110. 'field_extra': {
  111. 'choices': (
  112. ('gravatar', _("Gravatar")),
  113. ('gallery', _("Random avatar from gallery")),
  114. ),
  115. },
  116. },
  117. {
  118. 'setting': 'avatar_upload_limit',
  119. 'name': _("Maximum size of uploaded avatar"),
  120. 'description': _("Enter maximum allowed file size "
  121. "(in KB) for avatar uploads"),
  122. 'python_type': 'int',
  123. 'value': 128,
  124. 'field_extra': {
  125. 'min_value': 0,
  126. },
  127. },
  128. {
  129. 'setting': 'subscribe_start',
  130. 'name': _("Subscribe to started threads"),
  131. 'legend': _("Default subscriptions settings"),
  132. 'value': 'watch_email',
  133. 'form_field': 'select',
  134. 'field_extra': {
  135. 'choices': (
  136. ('no', _("Don't watch")),
  137. ('', _("Put on watched threads list")),
  138. ('watch_email', _("Put on watched threads "
  139. "list and e-mail user when "
  140. "somebody replies")),
  141. ),
  142. },
  143. },
  144. {
  145. 'setting': 'subscribe_reply',
  146. 'name': _("Subscribe to replied threads"),
  147. 'value': 'watch_email',
  148. 'form_field': 'select',
  149. 'field_extra': {
  150. 'choices': (
  151. ('no', _("Don't watch")),
  152. ('', _("Put on watched threads list")),
  153. ('watch_email', _("Put on watched threads "
  154. "list and e-mail user when "
  155. "somebody replies")),
  156. ),
  157. },
  158. },
  159. )
  160. },
  161. )
  162. def backwards(self, orm):
  163. "Write your backwards methods here."
  164. models = with_conf_models('0001_initial')
  165. complete_apps = ['core']
  166. symmetrical = True
  167. depends_on = (
  168. ("conf", "0001_initial"),
  169. )