From 033921669edb9a9b38bbff764ee4b3268b2bffbd Mon Sep 17 00:00:00 2001 From: chirac Date: Mon, 28 Dec 2020 21:06:24 +0100 Subject: [PATCH] Autocomplete for club edition --- users/forms.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/users/forms.py b/users/forms.py index 3bf19dcc..195807a3 100644 --- a/users/forms.py +++ b/users/forms.py @@ -60,7 +60,7 @@ from topologie.models import Port from preferences.models import OptionalUser from re2o.utils import remove_user_room from re2o.base import get_input_formats_help_text -from re2o.mixins import FormRevMixin, AutocompleteModelMixin +from re2o.mixins import FormRevMixin, AutocompleteMultipleModelMixin, AutocompleteModelMixin from re2o.field_permissions import FieldPermissionFormMixin from preferences.models import GeneralOption @@ -356,6 +356,9 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): ), "room": AutocompleteModelMixin( url="/topologie/room-autocomplete", + attrs = { + "data-minimum-input-length": 3 # Only trigger autocompletion after 3 characters have been typed + } ), "shell": AutocompleteModelMixin( url="/users/shell-autocomplete", @@ -659,6 +662,14 @@ class ClubAdminandMembersForm(FormRevMixin, ModelForm): class Meta: model = Club fields = ["administrators", "members"] + widgets = { + "administrators": AutocompleteMultipleModelMixin( + url="/users/adherent-autocomplete", + ), + "members": AutocompleteMultipleModelMixin( + url="/users/adherent-autocomplete", + ) + } def __init__(self, *args, **kwargs): prefix = kwargs.pop("prefix", self.Meta.model.__name__)