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

Remove and replace massive_bootstrap; forms change for autocomplete

This commit is contained in:
chirac 2020-12-28 12:16:08 +01:00
parent 1d011435f5
commit ecd468201a
2 changed files with 30 additions and 6 deletions

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 from re2o.mixins import FormRevMixin, AutocompleteModelMixin
from re2o.field_permissions import FieldPermissionFormMixin from re2o.field_permissions import FieldPermissionFormMixin
from preferences.models import GeneralOption from preferences.models import GeneralOption
@ -350,6 +350,17 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
"telephone", "telephone",
"room", "room",
] ]
widgets = {
"school": AutocompleteModelMixin(
url="/users/school-autocomplete",
),
"room": AutocompleteModelMixin(
url="/topologie/room-autocomplete",
),
"shell": AutocompleteModelMixin(
url="/users/shell-autocomplete",
)
}
force = forms.BooleanField( force = forms.BooleanField(
label=_("Force the move?"), initial=False, required=False label=_("Force the move?"), initial=False, required=False
@ -461,7 +472,7 @@ class AdherentCreationForm(AdherentForm):
# Checkbox for GTU # Checkbox for GTU
gtu_check = forms.BooleanField(required=True) gtu_check = forms.BooleanField(required=True)
class Meta: class Meta(AdherentForm.Meta):
model = Adherent model = Adherent
fields = [ fields = [
"name", "name",
@ -556,7 +567,7 @@ class AdherentEditForm(AdherentForm):
if "shell" in self.fields: if "shell" in self.fields:
self.fields["shell"].empty_label = _("Default shell") self.fields["shell"].empty_label = _("Default shell")
class Meta: class Meta(AdherentForm.Meta):
model = Adherent model = Adherent
fields = [ fields = [
"name", "name",
@ -609,6 +620,17 @@ class ClubForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
"shell", "shell",
"mailing", "mailing",
] ]
widgets = {
"school": AutocompleteModelMixin(
url="/users/school-autocomplete",
),
"room": AutocompleteModelMixin(
url="/topologie/room-autocomplete",
),
"shell": AutocompleteModelMixin(
url="/users/shell-autocomplete",
)
}
def clean_telephone(self): def clean_telephone(self):
"""Clean telephone, check if telephone is made mandatory, and """Clean telephone, check if telephone is made mandatory, and

View file

@ -24,7 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %} {% endcomment %}
{% load bootstrap3 %} {% load bootstrap3 %}
{% load massive_bootstrap_form %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
{% block title %}{% trans "Users" %}{% endblock %} {% block title %}{% trans "Users" %}{% endblock %}
@ -34,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<form class="form" method="post" enctype="multipart/form-data"> <form class="form" method="post" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
{% massive_bootstrap_form userform 'room,school,administrators,members' %} {% bootstrap_form userform %}
{% bootstrap_button action_name button_type="submit" icon='ok' button_class='btn-success' %} {% bootstrap_button action_name button_type="submit" icon='ok' button_class='btn-success' %}
</form> </form>
{% if load_js_file %} {% if load_js_file %}
@ -48,5 +47,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<br/> <br/>
<br/> <br/>
<br/> <br/>
{{ userform.media }}
{% endblock %} {% endblock %}