forms.py 2.3 KB

1234567891011121314151617181920212223242526272829303132
  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. inhibit_posting_replies = forms.TypedChoiceField(label=_("Restrict Replies Posting"),
  19. choices=(
  20. (0, _("No restrictions")),
  21. (1, _("Review by moderator")),
  22. (2, _("Disallowed")),
  23. ),
  24. coerce=int, initial=0)
  25. inhibit_posting_threads = forms.TypedChoiceField(label=_("Restrict Threads Posting"),
  26. choices=(
  27. (0, _("No restrictions")),
  28. (1, _("Review by moderator")),
  29. (2, _("Disallowed")),
  30. ),
  31. coerce=int, initial=0)