forked from DGNum/gestioCOF
…and it becomes possible to add extra forms/formsets to the create and update group views.
29 lines
772 B
Python
29 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']
|