gestioCOF/kfet/auth/forms.py

29 lines
772 B
Python
Raw Normal View History

from django import forms
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from utils.forms import KeepUnselectableModelFormMixin
from .fields import GroupsField, CorePermissionsField
from .models import Group
class GroupForm(KeepUnselectableModelFormMixin, forms.ModelForm):
permissions = CorePermissionsField(label='', required=False)
keep_unselectable_fields = ['permissions']
class Meta:
model = Group
fields = ['name', 'permissions']
class UserGroupForm(KeepUnselectableModelFormMixin, forms.ModelForm):
groups = GroupsField(label=_("Statut équipe"), required=False)
keep_unselectable_fields = ['groups']
class Meta:
model = User
fields = ['groups']