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