gestioCOF/kfet/auth/forms.py

28 lines
655 B
Python
Raw Normal View History

2020-08-03 19:06:48 +02:00
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
2020-08-03 19:06:48 +02:00
from shared.forms import ProtectedModelForm
2020-08-03 19:06:48 +02:00
from .fields import KFetGroupsField, KFetPermissionsField
from .models import KFetGroup
2020-08-03 19:06:48 +02:00
class GroupForm(ProtectedModelForm):
permissions = KFetPermissionsField()
2020-08-03 19:06:48 +02:00
protected_fields = ["permissions"]
class Meta:
2020-08-03 19:06:48 +02:00
model = KFetGroup
fields = ["name", "permissions"]
2020-08-03 19:06:48 +02:00
class UserGroupForm(ProtectedModelForm):
groups = KFetGroupsField(label=_("Statut équipe"), required=False,)
2020-08-03 19:06:48 +02:00
protected_fields = ["groups"]
class Meta:
model = User
fields = ["groups"]