forms.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from django.utils.translation import ugettext_lazy as _
  2. import floppyforms as forms
  3. from misago.forms import Form
  4. class BanForm(Form):
  5. """
  6. New/Edit Ban form
  7. """
  8. test = forms.TypedChoiceField(label=_("Ban Rule"),
  9. help_text=_("Select ban type from list and define rule by entering it in text field. If you want to ban specific user, enter here either his Username or E-mail address. If you want to define blanket ban, you can use wildcard (\"*\"). For example to forbid all members from using name suggesting that member is an admin, you can set ban that forbids \"Admin*\" as username."),
  10. choices=(
  11. (0, _('Ban Username and e-mail')),
  12. (1, _('Ban Username')),
  13. (2, _('Ban E-mail address')),
  14. (3, _('Ban IP Address'))
  15. ), coerce=int)
  16. reason_user = forms.CharField(label=_("User-visible Ban Message"),
  17. help_text=_("Optional Ban message that will be displayed to banned members."),
  18. widget=forms.Textarea, required=False)
  19. reason_admin = forms.CharField(label=_("Team-visible Ban Message"),
  20. help_text=_("Optional Ban message that will be displayed to forum team members."),
  21. widget=forms.Textarea, required=False)
  22. ban = forms.CharField(max_length=255)
  23. expires = forms.DateField(label=_("Ban Expiration"),
  24. help_text=_("If you want to, you can set this ban's expiration date by entering it here using YYYY-MM-DD format. Otherwhise you can leave this field empty making this ban permanent."),
  25. required=False)
  26. class SearchBansForm(Form):
  27. ban = forms.CharField(label=_("Ban"), required=False)
  28. reason = forms.CharField(label=_("Messages"), required=False)
  29. test = forms.TypedMultipleChoiceField(label=_("Type"),
  30. widget=forms.CheckboxSelectMultiple,
  31. coerce=int, required=False,
  32. choices=(
  33. (0, _('Username and e-mail')),
  34. (1, _('Username')),
  35. (2, _('E-mail address')),
  36. (3, _('IP Address'))
  37. ))