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
|
|
|
|
2017-09-26 22:18:39 +02:00
|
|
|
from .fields import GroupsField, CorePermissionsField
|
|
|
|
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):
|
2017-10-15 23:46:54 +02:00
|
|
|
permissions = CorePermissionsField(label='', required=False)
|
2017-09-26 22:18:39 +02:00
|
|
|
|
|
|
|
keep_unselectable_fields = ['permissions']
|
2017-09-13 01:57:31 +02:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Group
|
|
|
|
fields = ['name', 'permissions']
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2017-09-26 22:18:39 +02:00
|
|
|
keep_unselectable_fields = ['groups']
|
2017-09-13 01:57:31 +02:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = User
|
|
|
|
fields = ['groups']
|