gestioCOF/kfet/auth/forms.py
2024-07-12 14:54:14 +02:00

30 lines
676 B
Python

from django.contrib.auth.models import User
from django.utils.translation import gettext_lazy as _
from shared.forms import ProtectedModelForm
from .fields import KFetGroupsField, KFetPermissionsField
from .models import KFetGroup
class GroupForm(ProtectedModelForm):
permissions = KFetPermissionsField()
protected_fields = ["permissions"]
class Meta:
model = KFetGroup
fields = ["name", "permissions"]
class UserGroupForm(ProtectedModelForm):
groups = KFetGroupsField(
label=_("Statut équipe"),
required=False,
)
protected_fields = ["groups"]
class Meta:
model = User
fields = ["groups"]