0004_update_settings.py 2.7 KB

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