0004_update_settings.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from django.db import migrations
  4. from misago.conf.migrationutils import migrate_settings_group, delete_settings_cache
  5. _ = lambda x: x
  6. def update_threads_settings(apps, schema_editor):
  7. migrate_settings_group(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. delete_settings_cache()
  66. class Migration(migrations.Migration):
  67. dependencies = [
  68. ('misago_threads', '0003_attachment_types'),
  69. ]
  70. operations = [
  71. migrations.RunPython(update_threads_settings),
  72. ]