0002_db_settings.py 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. # -*- coding: utf-8 -*-
  2. from south.utils import datetime_utils as datetime
  3. from south.db import db
  4. from south.v2 import SchemaMigration
  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(SchemaMigration):
  9. def forwards(self, orm):
  10. migrate_settings_group(
  11. orm,
  12. {
  13. 'key': 'users',
  14. 'name': _("Users"),
  15. 'settings': (
  16. {
  17. 'setting': 'account_activation',
  18. 'name': _("New accounts activation"),
  19. 'legend': _("New accounts"),
  20. 'value': 'none',
  21. 'form_field': 'select',
  22. 'field_extra': {
  23. 'choices': (
  24. ('none', _("No activation required")),
  25. ('user', _("Activation Token sent to User")),
  26. ('admin', _("Activation by Administrator")),
  27. ('block', _("Don't allow new registrations"))
  28. )
  29. },
  30. },
  31. {
  32. 'setting': 'default_timezone',
  33. 'name': _("Default timezone"),
  34. 'description': _("Default timezone for newly "
  35. "registered accouts as well as "
  36. "unsigned users."),
  37. 'value': 'utc',
  38. 'form_field': 'select',
  39. 'field_extra': {
  40. 'choices': '#TZ#',
  41. },
  42. },
  43. {
  44. 'setting': 'username_length_min',
  45. 'name': _("Minimal allowed username length"),
  46. 'legend': _("User names"),
  47. 'python_type': 'int',
  48. 'value': 3,
  49. 'field_extra': {
  50. 'min_value': 2,
  51. 'max_value': 255,
  52. },
  53. },
  54. {
  55. 'setting': 'username_length_max',
  56. 'name': _("Maximal 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 user password length"),
  67. 'legend': _("Passwords"),
  68. 'python_type': 'int',
  69. 'value': 5,
  70. 'field_extra': {
  71. 'min_value': 2,
  72. 'max_value': 255,
  73. },
  74. },
  75. {
  76. 'setting': 'avatars_types',
  77. 'name': _("Available avatar types"),
  78. 'legend': _("Avatars"),
  79. 'python_type': 'list',
  80. 'value': ['gravatar', 'upload'],
  81. 'form_field': 'checkbox',
  82. 'field_extra': {
  83. 'choices': (
  84. ('gravatar', _("Gravatar")),
  85. ('upload', _("Uploaded avatar")),
  86. ('gallery', _("Avatars gallery"))
  87. ),
  88. 'min': 1,
  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. pass
  150. models = with_conf_models('0001_initial', {
  151. u'auth.group': {
  152. 'Meta': {'object_name': 'Group'},
  153. u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  154. 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
  155. 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
  156. },
  157. u'auth.permission': {
  158. 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
  159. 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
  160. 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
  161. u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  162. 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
  163. },
  164. u'contenttypes.contenttype': {
  165. 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
  166. 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
  167. u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  168. 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
  169. 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
  170. },
  171. 'users.rank': {
  172. 'Meta': {'object_name': 'Rank'},
  173. 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
  174. u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  175. 'is_default': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  176. 'is_on_index': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  177. 'is_tab': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  178. 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
  179. 'order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
  180. 'slug': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
  181. 'style': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
  182. 'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'})
  183. },
  184. 'users.user': {
  185. 'Meta': {'object_name': 'User'},
  186. 'email': ('django.db.models.fields.EmailField', [], {'max_length': '255', 'db_index': 'True'}),
  187. 'email_hash': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'}),
  188. 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
  189. u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  190. 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
  191. 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  192. 'joined_on': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
  193. 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
  194. 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
  195. 'rank': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['users.Rank']", 'on_delete': 'models.PROTECT'}),
  196. 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
  197. 'username': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
  198. 'username_slug': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
  199. }
  200. })
  201. no_dry_run = True
  202. complete_apps = ['users']
  203. depends_on = (
  204. ("conf", "0001_initial"),
  205. )