0004_update_settings.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. 'setting': 'thread_title_length_min',
  17. 'name': _("Minimum length"),
  18. 'description': _("Minimum allowed thread title length."),
  19. 'legend': _("Thread titles"),
  20. 'python_type': 'int',
  21. 'default_value': 5,
  22. 'field_extra': {
  23. 'min_value': 2,
  24. 'max_value': 255,
  25. },
  26. 'is_public': True,
  27. }, {
  28. 'setting': 'thread_title_length_max',
  29. 'name': _("Maximum length"),
  30. 'description': _("Maximum allowed thread length."),
  31. 'python_type': 'int',
  32. 'default_value': 90,
  33. 'field_extra': {
  34. 'min_value': 2,
  35. 'max_value': 255,
  36. },
  37. 'is_public': True,
  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. 'setting':
  51. 'post_length_max',
  52. 'name':
  53. _("Maximum length"),
  54. 'description':
  55. _(
  56. "Maximum allowed user post length. Enter zero to disable. "
  57. "Longer posts are more costful to parse and index."
  58. ),
  59. 'python_type':
  60. 'int',
  61. 'default_value':
  62. 60000,
  63. 'field_extra': {
  64. 'min_value': 0,
  65. },
  66. 'is_public':
  67. True,
  68. }, )
  69. }
  70. )
  71. delete_settings_cache()
  72. class Migration(migrations.Migration):
  73. dependencies = [
  74. ('misago_threads', '0003_attachment_types'),
  75. ]
  76. operations = [
  77. migrations.RunPython(update_threads_settings),
  78. ]