0004_update_settings.py 2.7 KB

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