users.py 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. from django import forms
  2. from django.utils.translation import gettext_lazy as _
  3. from ....admin.forms import YesNoSwitch
  4. from .base import ChangeSettingsForm
  5. class ChangeUsersSettingsForm(ChangeSettingsForm):
  6. settings = [
  7. "account_activation",
  8. "allow_custom_avatars",
  9. "avatar_upload_limit",
  10. "default_avatar",
  11. "default_gravatar_fallback",
  12. "signature_length_max",
  13. "subscribe_reply",
  14. "subscribe_start",
  15. "username_length_max",
  16. "username_length_min",
  17. ]
  18. account_activation = forms.ChoiceField(
  19. label=_("Require new accounts activation"),
  20. choices=[
  21. ("none", _("No activation required")),
  22. ("user", _("Activation token sent to user e-mail")),
  23. ("admin", _("Activation by administrator")),
  24. ("closed", _("Disable new registrations")),
  25. ],
  26. widget=forms.RadioSelect(),
  27. )
  28. username_length_min = forms.IntegerField(
  29. label=_("Minimum allowed username length"), min_value=2, max_value=20
  30. )
  31. username_length_max = forms.IntegerField(
  32. label=_("Maximum allowed username length"), min_value=2, max_value=20
  33. )
  34. allow_custom_avatars = YesNoSwitch(
  35. label=_("Allow custom avatar uploads"),
  36. help_text=_(
  37. "Turning this option off will forbid forum users from uploading custom "
  38. "avatars. Good for forums adressed at young users."
  39. ),
  40. )
  41. avatar_upload_limit = forms.IntegerField(
  42. label=_("Maximum size of uploaded avatar"),
  43. help_text=_("Enter maximum allowed file size (in KB) for avatar uploads."),
  44. min_value=0,
  45. )
  46. default_avatar = forms.ChoiceField(
  47. label=_("Default avatar"),
  48. choices=[
  49. ("dynamic", _("Individual")),
  50. ("gravatar", _("Gravatar")),
  51. ("gallery", _("Random avatar from gallery")),
  52. ],
  53. widget=forms.RadioSelect(),
  54. )
  55. default_gravatar_fallback = forms.ChoiceField(
  56. label=_("Fallback for default gravatar"),
  57. help_text=_(
  58. "Select which avatar to use when user has no gravatar associated with "
  59. "their e-mail address."
  60. ),
  61. choices=[
  62. ("dynamic", _("Individual")),
  63. ("gallery", _("Random avatar from gallery")),
  64. ],
  65. widget=forms.RadioSelect(),
  66. )
  67. signature_length_max = forms.IntegerField(
  68. label=_("Maximum allowed signature length"), min_value=10, max_value=5000
  69. )
  70. subscribe_start = forms.ChoiceField(
  71. label=_("Started threads"),
  72. choices=[
  73. ("no", _("Don't watch")),
  74. ("watch", _("Put on watched threads list")),
  75. (
  76. "watch_email",
  77. _("Put on watched threads list and e-mail user when somebody replies"),
  78. ),
  79. ],
  80. widget=forms.RadioSelect(),
  81. )
  82. subscribe_reply = forms.ChoiceField(
  83. label=_("Replied threads"),
  84. choices=[
  85. ("no", _("Don't watch")),
  86. ("watch", _("Put on watched threads list")),
  87. (
  88. "watch_email",
  89. _("Put on watched threads list and e-mail user when somebody replies"),
  90. ),
  91. ],
  92. widget=forms.RadioSelect(),
  93. )