forms.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. from django.utils.translation import ugettext_lazy as _
  2. from django import forms
  3. from misago.forms import Form
  4. class BanForm(Form):
  5. """
  6. New/Edit Ban form
  7. """
  8. type = forms.ChoiceField(choices=(
  9. (0, _('Ban Username and e-mail')),
  10. (1, _('Ban Username')),
  11. (2, _('Ban E-mail address')),
  12. (3, _('Ban IP Address'))
  13. ))
  14. reason_user = forms.CharField(widget=forms.Textarea, required=False)
  15. reason_admin = forms.CharField(widget=forms.Textarea, required=False)
  16. ban = forms.CharField(max_length=255)
  17. expires = forms.DateField(required=False)
  18. layout = (
  19. (
  20. _("Ban Details"),
  21. (
  22. ('nested', (('type', {'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}),
  23. ('ban', {'width': 75}))),
  24. ('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.")}),
  25. ),
  26. ),
  27. (
  28. _("Ban Message"),
  29. (
  30. ('reason_user', {'label': _("User-visible Ban Message"), 'help_text': _("Optional Ban message that will be displayed to banned members.")}),
  31. ('reason_admin', {'label': _("Team-visible Ban Message"), 'help_text': _("Optional Ban message that will be displayed to forum team members.")}),
  32. ),
  33. ),
  34. )
  35. class SearchBansForm(Form):
  36. ban = forms.CharField(required=False)
  37. reason = forms.CharField(required=False)
  38. type = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=(
  39. ("0", _('Username and e-mail')),
  40. ("1", _('Username')),
  41. ("2", _('E-mail address')),
  42. ("3", _('IP Address'))
  43. ), required=False)
  44. layout = (
  45. (
  46. _("Search Bans"),
  47. (
  48. ('ban', {'label': _("Ban"), 'attrs': {'placeholder': _("Ban contains...")}}),
  49. ('reason', {'label': _("Messages"), 'attrs': {'placeholder': _("User or Team message contains...")}}),
  50. ('type', {'label': _("Type")}),
  51. ),
  52. ),
  53. )