0004_update_settings.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from django.db import migrations
  4. from misago.conf.migrationutils import delete_settings_cache, migrate_settings_group
  5. _ = lambda x: x
  6. def update_threads_settings(apps, schema_editor):
  7. migrate_settings_group(
  8. apps, {
  9. 'key':
  10. 'threads',
  11. 'name':
  12. _("Threads"),
  13. 'description':
  14. _("Those settings control threads and posts."),
  15. 'settings': [
  16. {
  17. 'setting': 'thread_title_length_min',
  18. 'name': _("Minimum length"),
  19. 'description': _("Minimum allowed thread title length."),
  20. 'legend': _("Thread titles"),
  21. 'python_type': 'int',
  22. 'default_value': 5,
  23. 'field_extra': {
  24. 'min_value': 2,
  25. 'max_value': 255,
  26. },
  27. 'is_public': True,
  28. },
  29. {
  30. 'setting': 'thread_title_length_max',
  31. 'name': _("Maximum length"),
  32. 'description': _("Maximum allowed thread length."),
  33. 'python_type': 'int',
  34. 'default_value': 90,
  35. 'field_extra': {
  36. 'min_value': 2,
  37. 'max_value': 255,
  38. },
  39. 'is_public': True,
  40. },
  41. {
  42. 'setting': 'post_length_min',
  43. 'name': _("Minimum length"),
  44. 'description': _("Minimum allowed user post length."),
  45. 'legend': _("Posts"),
  46. 'python_type': 'int',
  47. 'default_value': 5,
  48. 'field_extra': {
  49. 'min_value': 1,
  50. },
  51. 'is_public': True,
  52. },
  53. {
  54. 'setting':
  55. 'post_length_max',
  56. 'name':
  57. _("Maximum length"),
  58. 'description':
  59. _(
  60. "Maximum allowed user post length. Enter zero to disable. "
  61. "Longer posts are more costful to parse and index."
  62. ),
  63. 'python_type':
  64. 'int',
  65. 'default_value':
  66. 60000,
  67. 'field_extra': {
  68. 'min_value': 0,
  69. },
  70. 'is_public':
  71. True,
  72. },
  73. ],
  74. }
  75. )
  76. delete_settings_cache()
  77. class Migration(migrations.Migration):
  78. dependencies = [
  79. ('misago_threads', '0003_attachment_types'),
  80. ]
  81. operations = [
  82. migrations.RunPython(update_threads_settings),
  83. ]