forked from DGNum/gestioCOF
fixes #87
This commit is contained in:
parent
0ac1eaf414
commit
47d7a3ec6e
1 changed files with 14 additions and 9 deletions
|
@ -1,21 +1,17 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from __future__ import (absolute_import, division,
|
|
||||||
print_function, unicode_literals)
|
|
||||||
from builtins import *
|
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core.validators import MinLengthValidator
|
from django.core.validators import MinLengthValidator
|
||||||
from django.contrib.auth.models import User, Group, Permission
|
from django.contrib.auth.models import User, Group, Permission
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.forms import modelformset_factory, inlineformset_factory
|
from django.forms import modelformset_factory
|
||||||
from django.forms.models import BaseInlineFormSet
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from kfet.models import (Account, Checkout, Article, OperationGroup, Operation,
|
from kfet.models import (
|
||||||
|
Account, Checkout, Article, OperationGroup, Operation,
|
||||||
CheckoutStatement, ArticleCategory, Settings, AccountNegative, Transfer,
|
CheckoutStatement, ArticleCategory, Settings, AccountNegative, Transfer,
|
||||||
TransferGroup, Supplier, Inventory, InventoryArticle)
|
TransferGroup, Supplier)
|
||||||
from gestioncof.models import CofProfile
|
from gestioncof.models import CofProfile
|
||||||
|
|
||||||
# -----
|
# -----
|
||||||
|
@ -131,7 +127,16 @@ class UserRestrictTeamForm(UserForm):
|
||||||
|
|
||||||
class UserGroupForm(forms.ModelForm):
|
class UserGroupForm(forms.ModelForm):
|
||||||
groups = forms.ModelMultipleChoiceField(
|
groups = forms.ModelMultipleChoiceField(
|
||||||
Group.objects.filter(name__icontains='K-Fêt'))
|
Group.objects.filter(name__icontains='K-Fêt'),
|
||||||
|
required=False)
|
||||||
|
|
||||||
|
def clean_groups(self):
|
||||||
|
groups = self.cleaned_data.get('groups')
|
||||||
|
# Si aucun groupe, on le dénomme
|
||||||
|
if not groups:
|
||||||
|
groups = self.instance.groups.exclude(name__icontains='K-Fêt')
|
||||||
|
return groups
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = ['groups']
|
fields = ['groups']
|
||||||
|
|
Loading…
Reference in a new issue