forms.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. layout = (
  27. (
  28. _("Ban Details"),
  29. (
  30. ('nested', (('test', {'label': _("Ban Rule"), '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."), 'width': 25}),
  31. ('ban', {'width': 75}))),
  32. ('expires', {'label': _("Ban Expiration"), '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.")}),
  33. ),
  34. ),
  35. (
  36. _("Ban Message"),
  37. (
  38. ('reason_user', {'label': _("User-visible Ban Message"), 'help_text': _("Optional Ban message that will be displayed to banned members.")}),
  39. ('reason_admin', {'label': _("Team-visible Ban Message"), 'help_text': _("Optional Ban message that will be displayed to forum team members.")}),
  40. ),
  41. ),
  42. )
  43. class SearchBansForm(Form):
  44. ban = forms.CharField(label=_("Ban"), required=False)
  45. reason = forms.CharField(label=_("Messages"), required=False)
  46. test = forms.TypedMultipleChoiceField(label=_("Type"),
  47. widget=forms.CheckboxSelectMultiple,
  48. coerce=int, required=False,
  49. choices=(
  50. (0, _('Username and e-mail')),
  51. (1, _('Username')),
  52. (2, _('E-mail address')),
  53. (3, _('IP Address'))
  54. ))