8
0
Fork 0
mirror of https://gitlab.federez.net/re2o/re2o synced 2024-05-16 23:56:12 +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 committed by Gabriel Detraz
parent 639aa86684
commit ec4ddb12e6
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 re2o.utils import remove_user_room
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 preferences.models import GeneralOption
@ -350,6 +350,17 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
"telephone",
"room",
]
widgets = {
"school": AutocompleteModelMixin(
url="/users/school-autocomplete",
),
"room": AutocompleteModelMixin(
url="/topologie/room-autocomplete",
),
"shell": AutocompleteModelMixin(
url="/users/shell-autocomplete",
)
}
force = forms.BooleanField(
label=_("Force the move?"), initial=False, required=False
@ -461,7 +472,7 @@ class AdherentCreationForm(AdherentForm):
# Checkbox for GTU
gtu_check = forms.BooleanField(required=True)
class Meta:
class Meta(AdherentForm.Meta):
model = Adherent
fields = [
"name",
@ -556,7 +567,7 @@ class AdherentEditForm(AdherentForm):
if "shell" in self.fields:
self.fields["shell"].empty_label = _("Default shell")
class Meta:
class Meta(AdherentForm.Meta):
model = Adherent
fields = [
"name",
@ -609,6 +620,17 @@ class ClubForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
"shell",
"mailing",
]
widgets = {
"school": AutocompleteModelMixin(
url="/users/school-autocomplete",
),
"room": AutocompleteModelMixin(
url="/topologie/room-autocomplete",
),
"shell": AutocompleteModelMixin(
url="/users/shell-autocomplete",
)
}
def clean_telephone(self):
"""Clean telephone, check if telephone is made mandatory, and
@ -1056,4 +1078,4 @@ class ThemeForm(FormRevMixin, forms.Form):
if not themes:
themes = ["default.css"]
super(ThemeForm, self).__init__(*args, **kwargs)
self.fields['theme'].choices = [(theme, theme) for theme in themes]
self.fields['theme'].choices = [(theme, theme) for theme in themes]

View file

@ -24,7 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% load bootstrap3 %}
{% load massive_bootstrap_form %}
{% load static %}
{% load i18n %}
{% 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">
{% 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' %}
</form>
{% if load_js_file %}
@ -48,5 +47,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<br/>
<br/>
<br/>
{{ userform.media }}
{% endblock %}