mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 07:41:14 +00:00
Fix groups displayed on user profile group edition
This commit is contained in:
parent
29c4a36479
commit
87b619794d
@ -44,7 +44,7 @@ from phonenumber_field.widgets import RegionalPhoneNumberWidget
|
|||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from antispam.forms import AntiSpamEmailField
|
from antispam.forms import AntiSpamEmailField
|
||||||
from core.models import Gift, Page, SithFile, User
|
from core.models import Gift, Page, RealGroup, SithFile, User
|
||||||
from core.utils import resize_image
|
from core.utils import resize_image
|
||||||
from core.views.widgets.select import (
|
from core.views.widgets.select import (
|
||||||
AutoCompleteSelect,
|
AutoCompleteSelect,
|
||||||
@ -285,15 +285,18 @@ class UserProfileForm(forms.ModelForm):
|
|||||||
self._post_clean()
|
self._post_clean()
|
||||||
|
|
||||||
|
|
||||||
class UserPropForm(forms.ModelForm):
|
class UserRealGroupForm(forms.ModelForm):
|
||||||
error_css_class = "error"
|
error_css_class = "error"
|
||||||
required_css_class = "required"
|
required_css_class = "required"
|
||||||
|
|
||||||
|
groups = forms.ModelChoiceField(
|
||||||
|
RealGroup.objects.all(),
|
||||||
|
widget=CheckboxSelectMultiple,
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = ["groups"]
|
fields = ["groups"]
|
||||||
help_texts = {"groups": "Which groups this user belongs to"}
|
|
||||||
widgets = {"groups": CheckboxSelectMultiple}
|
|
||||||
|
|
||||||
|
|
||||||
class UserGodfathersForm(forms.Form):
|
class UserGodfathersForm(forms.Form):
|
||||||
|
@ -35,7 +35,6 @@ from django.contrib.auth.mixins import LoginRequiredMixin
|
|||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.db.models import DateField, QuerySet
|
from django.db.models import DateField, QuerySet
|
||||||
from django.db.models.functions import Trunc
|
from django.db.models.functions import Trunc
|
||||||
from django.forms import CheckboxSelectMultiple
|
|
||||||
from django.forms.models import modelform_factory
|
from django.forms.models import modelform_factory
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
@ -69,6 +68,7 @@ from core.views.forms import (
|
|||||||
RegisteringForm,
|
RegisteringForm,
|
||||||
UserGodfathersForm,
|
UserGodfathersForm,
|
||||||
UserProfileForm,
|
UserProfileForm,
|
||||||
|
UserRealGroupForm,
|
||||||
)
|
)
|
||||||
from counter.models import Refilling, Selling
|
from counter.models import Refilling, Selling
|
||||||
from counter.views.student_card import StudentCardFormView
|
from counter.views.student_card import StudentCardFormView
|
||||||
@ -583,9 +583,7 @@ class UserUpdateGroupView(UserTabsMixin, CanEditPropMixin, UpdateView):
|
|||||||
model = User
|
model = User
|
||||||
pk_url_kwarg = "user_id"
|
pk_url_kwarg = "user_id"
|
||||||
template_name = "core/user_group.jinja"
|
template_name = "core/user_group.jinja"
|
||||||
form_class = modelform_factory(
|
form_class = UserRealGroupForm
|
||||||
User, fields=["groups"], widgets={"groups": CheckboxSelectMultiple}
|
|
||||||
)
|
|
||||||
context_object_name = "profile"
|
context_object_name = "profile"
|
||||||
current_tab = "groups"
|
current_tab = "groups"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user