mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-24 20:33:11 +00:00
Add autocomplete on preferences pannel
This commit is contained in:
parent
188bed9c18
commit
5c0131d760
3 changed files with 23 additions and 7 deletions
|
@ -29,7 +29,7 @@ from django.forms import ModelForm, Form
|
|||
from django.db.models import Q
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from re2o.mixins import FormRevMixin
|
||||
from re2o.mixins import FormRevMixin, AutocompleteModelMixin, AutocompleteMultipleModelMixin
|
||||
from .models import (
|
||||
OptionalUser,
|
||||
OptionalMachine,
|
||||
|
@ -168,6 +168,11 @@ class EditAssoOptionForm(ModelForm):
|
|||
class Meta:
|
||||
model = AssoOption
|
||||
fields = "__all__"
|
||||
widgets = {
|
||||
"utilisateur_asso": AutocompleteModelMixin(
|
||||
url="/users/user-autocomplete",
|
||||
),
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop("prefix", self.Meta.model.__name__)
|
||||
|
@ -254,6 +259,11 @@ class MandateForm(ModelForm):
|
|||
class Meta:
|
||||
model = Mandate
|
||||
fields = "__all__"
|
||||
widgets = {
|
||||
"president": AutocompleteModelMixin(
|
||||
url="/users/user-autocomplete",
|
||||
),
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop("prefix", self.Meta.model.__name__)
|
||||
|
@ -368,7 +378,9 @@ class RadiusKeyForm(FormRevMixin, ModelForm):
|
|||
"""Form used to add and edit RADIUS keys."""
|
||||
|
||||
members = forms.ModelMultipleChoiceField(
|
||||
queryset=Switch.objects.all(), required=False
|
||||
queryset=Switch.objects.all(),
|
||||
required=False,
|
||||
widget=AutocompleteMultipleModelMixin(url="/topologie/switch-autocomplete"),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
|
@ -391,7 +403,11 @@ class RadiusKeyForm(FormRevMixin, ModelForm):
|
|||
class SwitchManagementCredForm(FormRevMixin, ModelForm):
|
||||
"""Form used to add and edit switch management credentials."""
|
||||
|
||||
members = forms.ModelMultipleChoiceField(Switch.objects.all(), required=False)
|
||||
members = forms.ModelMultipleChoiceField(
|
||||
Switch.objects.all(),
|
||||
required=False,
|
||||
widget=AutocompleteMultipleModelMixin(url="/topologie/switch-autocomplete"),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = SwitchManagementCred
|
||||
|
|
|
@ -24,19 +24,19 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
{% endcomment %}
|
||||
|
||||
{% load bootstrap3 %}
|
||||
{% load massive_bootstrap_form %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block title %}{% trans "Preferences" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% bootstrap_form_errors options %}
|
||||
{{ options.media }}
|
||||
|
||||
<h3>{% trans "Editing of preferences" %}</h3>
|
||||
|
||||
<form class="form" method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{% massive_bootstrap_form options 'utilisateur_asso,automatic_provision_switchs' %}
|
||||
{% bootstrap_form options %}
|
||||
{% if formset %}
|
||||
{{ formset.management_form }}
|
||||
{% for f in formset %}
|
||||
|
|
|
@ -25,20 +25,20 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
|
||||
{% load bootstrap3 %}
|
||||
{% load i18n %}
|
||||
{% load massive_bootstrap_form %}
|
||||
|
||||
{% block title %}{% trans "Preferences" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if preferenceform %}
|
||||
{% bootstrap_form_errors preferenceform %}
|
||||
{{ preferenceform.media }}
|
||||
{% endif %}
|
||||
|
||||
|
||||
<form class="form" method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{% if preferenceform %}
|
||||
{% massive_bootstrap_form preferenceform 'members,president' %}
|
||||
{% bootstrap_form preferenceform %}
|
||||
{% endif %}
|
||||
{% bootstrap_button action_name button_type="submit" icon='ok' button_class='btn-success' %}
|
||||
</form>
|
||||
|
|
Loading…
Reference in a new issue