0004_update_settings.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. from django.db import migrations
  2. from ...conf.migrationutils import migrate_settings_group
  3. _ = lambda s: s
  4. def update_threads_settings(apps, schema_editor):
  5. migrate_settings_group(
  6. apps,
  7. {
  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": {"min_value": 2, "max_value": 255},
  20. "is_public": True,
  21. },
  22. {
  23. "setting": "thread_title_length_max",
  24. "name": _("Maximum length"),
  25. "description": _("Maximum allowed thread length."),
  26. "python_type": "int",
  27. "default_value": 90,
  28. "field_extra": {"min_value": 2, "max_value": 255},
  29. "is_public": True,
  30. },
  31. {
  32. "setting": "post_length_min",
  33. "name": _("Minimum length"),
  34. "description": _("Minimum allowed user post length."),
  35. "legend": _("Posts"),
  36. "python_type": "int",
  37. "default_value": 5,
  38. "field_extra": {"min_value": 1},
  39. "is_public": True,
  40. },
  41. {
  42. "setting": "post_length_max",
  43. "name": _("Maximum length"),
  44. "description": _(
  45. "Maximum allowed user post length. Enter zero to disable. "
  46. "Longer posts are more costful to parse and index."
  47. ),
  48. "python_type": "int",
  49. "default_value": 60000,
  50. "field_extra": {"min_value": 0},
  51. "is_public": True,
  52. },
  53. ],
  54. },
  55. )
  56. class Migration(migrations.Migration):
  57. dependencies = [("misago_threads", "0003_attachment_types")]
  58. operations = [migrations.RunPython(update_threads_settings)]