From ed123792057526412010ac3e957a089391df5df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Sun, 8 Oct 2017 02:01:45 +0000 Subject: [PATCH] =?UTF-8?q?Utilisation=20du=20BFT=20tag=20sur=20les=20mach?= =?UTF-8?q?ines=20dans=20l'=C3=A9dition=20d'interface?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit +Corretion d'une typo sur la génération de la variable choices --- machines/templates/machines/machine.html | 8 ++++++++ machines/templatetags/bootstrap_form_typeahead.py | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/machines/templates/machines/machine.html b/machines/templates/machines/machine.html index 4b308a11..d34dccb9 100644 --- a/machines/templates/machines/machine.html +++ b/machines/templates/machines/machine.html @@ -49,9 +49,17 @@ with this program; if not, write to the Free Software Foundation, Inc., {% if interfaceform %}

Interface

{% if i_bft_param %} + {% if 'machine' in interfaceform.fields %} + {% bootstrap_form_typeahead interfaceform 'ipv4,machine' bft_param=i_bft_param %} + {% else %} {% bootstrap_form_typeahead interfaceform 'ipv4' bft_param=i_bft_param %} + {% endif %} {% else %} + {% if 'machine' in interfaceform.fields %} + {% bootstrap_form_typeahead interfaceform 'ipv4,machine' %} + {% else %} {% bootstrap_form_typeahead interfaceform 'ipv4' %} + {% endif %} {% endif %} {% endif %} {% if domainform %} diff --git a/machines/templatetags/bootstrap_form_typeahead.py b/machines/templatetags/bootstrap_form_typeahead.py index e076b52c..05dd3147 100644 --- a/machines/templatetags/bootstrap_form_typeahead.py +++ b/machines/templatetags/bootstrap_form_typeahead.py @@ -298,9 +298,9 @@ def reset_input( f_name ) : def default_choices( f_value ) : """ The JS script creating the variable choices_ """ - return '[ {objects} ]'.format( - objects = ', '.join( - [ '{{ key: {k}, value: "{k}" }}'.format( + return '[{objects}]'.format( + objects = ','.join( + [ '{{key:{k},value:"{v}"}}'.format( k = choice[0] if choice[0] != '' else '""', v = choice[1] ) for choice in f_value.choices ]