2017-09-13 01:57:31 +02:00
|
|
|
from django import forms
|
2017-09-26 22:18:39 +02:00
|
|
|
from django.contrib.auth.models import User
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2017-09-13 01:57:31 +02:00
|
|
|
|
2017-09-26 22:18:39 +02:00
|
|
|
from utils.forms import KeepUnselectableModelFormMixin
|
2017-09-13 01:57:31 +02:00
|
|
|
|
2019-01-14 22:41:38 +01:00
|
|
|
from .fields import CorePermissionsField, GroupsField
|
2017-09-26 22:18:39 +02:00
|
|
|
from .models import Group
|
2017-09-13 01:57:31 +02:00
|
|
|
|
|
|
|
|
2017-09-26 22:18:39 +02:00
|
|
|
class GroupForm(KeepUnselectableModelFormMixin, forms.ModelForm):
|
|
|
|
permissions = CorePermissionsField(label=_("Permissions"), required=False)
|
|
|
|
|
2019-01-14 22:41:38 +01:00
|
|
|
keep_unselectable_fields = ["permissions"]
|
2017-09-13 01:57:31 +02:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Group
|
2018-10-06 12:35:49 +02:00
|
|
|
fields = ["name", "permissions"]
|
2017-09-13 01:57:31 +02:00
|
|
|
|
|
|
|
|
2017-09-26 22:18:39 +02:00
|
|
|
class UserGroupForm(KeepUnselectableModelFormMixin, forms.ModelForm):
|
|
|
|
groups = GroupsField(label=_("Statut équipe"), required=False)
|
2017-09-13 01:57:31 +02:00
|
|
|
|
2019-01-14 22:41:38 +01:00
|
|
|
keep_unselectable_fields = ["groups"]
|
2017-09-13 01:57:31 +02:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = User
|
2018-10-06 12:35:49 +02:00
|
|
|
fields = ["groups"]
|