8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 07:02:26 +00:00

Autocomplete for club edition

This commit is contained in:
chirac 2020-12-28 21:06:24 +01:00 committed by Gabriel Detraz
parent faac45dec5
commit 033921669e

View file

@ -60,7 +60,7 @@ from topologie.models import Port
from preferences.models import OptionalUser from preferences.models import OptionalUser
from re2o.utils import remove_user_room from re2o.utils import remove_user_room
from re2o.base import get_input_formats_help_text 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 re2o.field_permissions import FieldPermissionFormMixin
from preferences.models import GeneralOption from preferences.models import GeneralOption
@ -356,6 +356,9 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
), ),
"room": AutocompleteModelMixin( "room": AutocompleteModelMixin(
url="/topologie/room-autocomplete", url="/topologie/room-autocomplete",
attrs = {
"data-minimum-input-length": 3 # Only trigger autocompletion after 3 characters have been typed
}
), ),
"shell": AutocompleteModelMixin( "shell": AutocompleteModelMixin(
url="/users/shell-autocomplete", url="/users/shell-autocomplete",
@ -659,6 +662,14 @@ class ClubAdminandMembersForm(FormRevMixin, ModelForm):
class Meta: class Meta:
model = Club model = Club
fields = ["administrators", "members"] fields = ["administrators", "members"]
widgets = {
"administrators": AutocompleteMultipleModelMixin(
url="/users/adherent-autocomplete",
),
"members": AutocompleteMultipleModelMixin(
url="/users/adherent-autocomplete",
)
}
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
prefix = kwargs.pop("prefix", self.Meta.model.__name__) prefix = kwargs.pop("prefix", self.Meta.model.__name__)