forms.py 950 B

12345678910111213141516171819202122
  1. from django.utils.translation import ugettext_lazy as _
  2. from django import forms
  3. from misago.forms import Form, YesNoSwitch
  4. class RoleForm(Form):
  5. name = forms.CharField(max_length=255)
  6. protected = forms.BooleanField(widget=YesNoSwitch,required=False)
  7. def finalize_form(self):
  8. self.layout = [
  9. [
  10. _("Basic Role Options"),
  11. [
  12. ('name', {'label': _("Role Name"), 'help_text': _("Role Name is used to identify this role in Admin Control Panel.")}),
  13. ('protected', {'label': _("Protect this Role"), 'help_text': _("Only system administrators can edit or assign protected roles.")}),
  14. ],
  15. ],
  16. ]
  17. if self.request.user.is_god():
  18. del self.fields['protected']
  19. del self.layout[0][1][1]