From 9f3a10ca71391e0d93c271e8e45011dafc02acca Mon Sep 17 00:00:00 2001 From: imperosol Date: Fri, 20 Dec 2024 11:00:57 +0100 Subject: [PATCH] fix user groups form --- core/views/forms.py | 7 ++++--- core/views/user.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/views/forms.py b/core/views/forms.py index 88963789..8a998ab0 100644 --- a/core/views/forms.py +++ b/core/views/forms.py @@ -285,13 +285,14 @@ class UserProfileForm(forms.ModelForm): self._post_clean() -class UserRealGroupForm(forms.ModelForm): +class UserGroupsForm(forms.ModelForm): error_css_class = "error" required_css_class = "required" - groups = forms.ModelChoiceField( - RealGroup.objects.all(), + groups = forms.ModelMultipleChoiceField( + queryset=RealGroup.objects.all(), widget=CheckboxSelectMultiple, + label=_("Groups"), ) class Meta: diff --git a/core/views/user.py b/core/views/user.py index 7b6c146b..264a8dd6 100644 --- a/core/views/user.py +++ b/core/views/user.py @@ -67,8 +67,8 @@ from core.views.forms import ( LoginForm, RegisteringForm, UserGodfathersForm, + UserGroupsForm, UserProfileForm, - UserRealGroupForm, ) from counter.models import Refilling, Selling from counter.views.student_card import StudentCardFormView @@ -583,7 +583,7 @@ class UserUpdateGroupView(UserTabsMixin, CanEditPropMixin, UpdateView): model = User pk_url_kwarg = "user_id" template_name = "core/user_group.jinja" - form_class = UserRealGroupForm + form_class = UserGroupsForm context_object_name = "profile" current_tab = "groups"