2020-08-03 19:06:48 +02:00
|
|
|
from django.contrib.auth.models import User
|
2022-06-29 16:09:50 +02:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2017-09-13 01:57:31 +02:00
|
|
|
|
2020-08-03 19:06:48 +02:00
|
|
|
from shared.forms import ProtectedModelForm
|
2017-09-13 01:57:31 +02:00
|
|
|
|
2020-08-03 19:06:48 +02:00
|
|
|
from .fields import KFetGroupsField, KFetPermissionsField
|
|
|
|
from .models import KFetGroup
|
2017-09-13 01:57:31 +02:00
|
|
|
|
2020-08-03 19:06:48 +02:00
|
|
|
|
|
|
|
class GroupForm(ProtectedModelForm):
|
2017-09-13 01:57:31 +02:00
|
|
|
permissions = KFetPermissionsField()
|
|
|
|
|
2020-08-03 19:06:48 +02:00
|
|
|
protected_fields = ["permissions"]
|
2017-09-13 01:57:31 +02:00
|
|
|
|
|
|
|
class Meta:
|
2020-08-03 19:06:48 +02:00
|
|
|
model = KFetGroup
|
2018-10-06 12:35:49 +02:00
|
|
|
fields = ["name", "permissions"]
|
2017-09-13 01:57:31 +02:00
|
|
|
|
|
|
|
|
2020-08-03 19:06:48 +02:00
|
|
|
class UserGroupForm(ProtectedModelForm):
|
2020-08-28 19:06:10 +02:00
|
|
|
groups = KFetGroupsField(
|
|
|
|
label=_("Statut équipe"),
|
|
|
|
required=False,
|
|
|
|
)
|
2017-09-13 01:57:31 +02:00
|
|
|
|
2020-08-03 19:06:48 +02:00
|
|
|
protected_fields = ["groups"]
|
2017-09-13 01:57:31 +02:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = User
|
2018-10-06 12:35:49 +02:00
|
|
|
fields = ["groups"]
|