destroying.py 887 B

12345678910111213141516171819202122232425262728
  1. from django.utils.translation import ugettext_lazy as _
  2. from misago.acl.models import Role
  3. from misago.core import forms
  4. DEFAULT_PERMISSIONS = {
  5. 'can_destroy_user_newer_than': 0,
  6. 'can_destroy_users_with_less_posts_than': 0,
  7. }
  8. class PermissionsForm(forms.Form):
  9. legend = _("Destroying user accounts")
  10. can_destroy_user_newer_than = forms.IntegerField(
  11. label=_("Maximum age of destroyed account (in days)"),
  12. help_text=_("Enter zero to disable this check."),
  13. min_value=0)
  14. can_destroy_users_with_less_posts_than = forms.IntegerField(
  15. label=_("Maximum number of posts on destroyed account"),
  16. help_text=_("Enter zero to disable this check."),
  17. min_value=0)
  18. def change_permissions_form(role):
  19. if role.__class__ == Role and role.special_role != 'anonymous':
  20. return PermissionsForm
  21. else:
  22. return None