gestioCOF/kfet/auth/forms.py

29 lines
786 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 CorePermissionsField, GroupsField
from .models import Group
class GroupForm(KeepUnselectableModelFormMixin, forms.ModelForm):
permissions = CorePermissionsField(label=_("Permissions"), 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"]