forms.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. from django.utils.translation import ugettext_lazy as _
  2. import floppyforms as forms
  3. from misago.forms import Form, YesNoSwitch
  4. from misago.models import WarnLevel
  5. from misago.validators import validate_sluggable
  6. class WarnLevelForm(Form):
  7. name = forms.CharField(label=_("Warning Level Name"),
  8. max_length=255, validators=[validate_sluggable(
  9. _("Warning level name must contain alphanumeric characters."),
  10. _("Warning level name is too long.")
  11. )])
  12. description = forms.CharField(label=_("Warning Level Description"),
  13. help_text=_("Optional message displayed to members with this warning level."),
  14. widget=forms.Textarea, required=False)
  15. expires_after_minutes = forms.IntegerField(label=_("Warning Level Expiration"),
  16. help_text=_("Enter number of minutes since this warning level was imposed on member until it's reduced and lower level is imposed, or 0 to make this warning level permanent."),
  17. initial=0, min_value=0)
  18. restrict_posting_replies = forms.TypedChoiceField(
  19. label=_("Restrict Replies Posting"),
  20. choices=(
  21. (WarnLevel.RESTRICT_NO, _("No restrictions")),
  22. (WarnLevel.RESTRICT_MODERATOR_REVIEW, _("Review by moderator")),
  23. (WarnLevel.RESTRICT_DISALLOW, _("Disallowed")),
  24. ),
  25. coerce=int, initial=0)
  26. restrict_posting_threads = forms.TypedChoiceField(
  27. label=_("Restrict Threads Posting"),
  28. choices=(
  29. (WarnLevel.RESTRICT_NO, _("No restrictions")),
  30. (WarnLevel.RESTRICT_MODERATOR_REVIEW, _("Review by moderator")),
  31. (WarnLevel.RESTRICT_DISALLOW, _("Disallowed")),
  32. ),
  33. coerce=int, initial=0)