forked from DGNum/gestioCOF
82582866b4
…and it becomes possible to add extra forms/formsets to the create and update group views.
28 lines
772 B
Python
28 lines
772 B
Python
from django import forms
|
|
from django.contrib.auth.models import User
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
from utils.forms import KeepUnselectableModelFormMixin
|
|
|
|
from .fields import GroupsField, CorePermissionsField
|
|
from .models import Group
|
|
|
|
|
|
class GroupForm(KeepUnselectableModelFormMixin, forms.ModelForm):
|
|
permissions = CorePermissionsField(label='', required=False)
|
|
|
|
keep_unselectable_fields = ['permissions']
|
|
|
|
class Meta:
|
|
model = Group
|
|
fields = ['name', 'permissions']
|
|
|
|
|
|
class UserGroupForm(KeepUnselectableModelFormMixin, forms.ModelForm):
|
|
groups = GroupsField(label=_("Statut équipe"), required=False)
|
|
|
|
keep_unselectable_fields = ['groups']
|
|
|
|
class Meta:
|
|
model = User
|
|
fields = ['groups']
|