mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-27 15:12:25 +00:00
Renomme bft en mfb (massive_bootstrap_form)
Plus adapté aux nouvelles fonctions incoming
This commit is contained in:
parent
575923536e
commit
a92eaae633
9 changed files with 93 additions and 86 deletions
|
@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
|
||||||
{% load bootstrap3 %}
|
{% load bootstrap3 %}
|
||||||
{% load staticfiles%}
|
{% load staticfiles%}
|
||||||
{% load bootstrap_form_typeahead %}
|
{% load massive_bootstrap_form %}
|
||||||
|
|
||||||
{% block title %}Création et modification de factures{% endblock %}
|
{% block title %}Création et modification de factures{% endblock %}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<form class="form" method="post">
|
<form class="form" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<h3>Editer la facture</h3>
|
<h3>Editer la facture</h3>
|
||||||
{% bootstrap_form_typeahead factureform 'user' %}
|
{% massive_bootstrap_form factureform 'user' %}
|
||||||
{{ venteform.management_form }}
|
{{ venteform.management_form }}
|
||||||
<h3>Articles de la facture</h3>
|
<h3>Articles de la facture</h3>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
|
|
|
@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|
||||||
{% load bootstrap3 %}
|
{% load bootstrap3 %}
|
||||||
{% load bootstrap_form_typeahead %}
|
{% load massive_bootstrap_form %}
|
||||||
|
|
||||||
{% block title %}Création et modification de machines{% endblock %}
|
{% block title %}Création et modification de machines{% endblock %}
|
||||||
|
|
||||||
|
@ -78,10 +78,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if interfaceform %}
|
{% if interfaceform %}
|
||||||
<h3>Interface</h3>
|
<h3>Interface</h3>
|
||||||
{% if i_bft_param %}
|
{% if i_mbf_param %}
|
||||||
{% bootstrap_form_typeahead interfaceform 'ipv4,machine' bft_param=i_bft_param %}
|
{% massive_bootstrap_form interfaceform 'ipv4,machine' mbf_param=i_mbf_param %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% bootstrap_form_typeahead interfaceform 'ipv4,machine' %}
|
{% massive_bootstrap_form interfaceform 'ipv4,machine' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if domainform %}
|
{% if domainform %}
|
||||||
|
@ -98,15 +98,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if extensionform %}
|
{% if extensionform %}
|
||||||
<h3>Extension</h3>
|
<h3>Extension</h3>
|
||||||
{% bootstrap_form_typeahead extensionform 'origin' %}
|
{% massive_bootstrap_form extensionform 'origin' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if mxform %}
|
{% if mxform %}
|
||||||
<h3>Enregistrement MX</h3>
|
<h3>Enregistrement MX</h3>
|
||||||
{% bootstrap_form_typeahead mxform 'name' %}
|
{% massive_bootstrap_form mxform 'name' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if nsform %}
|
{% if nsform %}
|
||||||
<h3>Enregistrement NS</h3>
|
<h3>Enregistrement NS</h3>
|
||||||
{% bootstrap_form_typeahead nsform 'ns' %}
|
{% massive_bootstrap_form nsform 'ns' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if txtform %}
|
{% if txtform %}
|
||||||
<h3>Enregistrement TXT</h3>
|
<h3>Enregistrement TXT</h3>
|
||||||
|
|
|
@ -55,7 +55,7 @@ from .models import IpType, Machine, Interface, IpList, MachineType, Extension,
|
||||||
from users.models import User
|
from users.models import User
|
||||||
from users.models import all_has_access
|
from users.models import all_has_access
|
||||||
from preferences.models import GeneralOption, OptionalMachine
|
from preferences.models import GeneralOption, OptionalMachine
|
||||||
from re2o.templatetags.bootstrap_form_typeahead import hidden_id, input_id
|
from re2o.templatetags.massive_bootstrap_form import hidden_id, input_id
|
||||||
|
|
||||||
def all_active_interfaces():
|
def all_active_interfaces():
|
||||||
"""Renvoie l'ensemble des machines autorisées à sortir sur internet """
|
"""Renvoie l'ensemble des machines autorisées à sortir sur internet """
|
||||||
|
@ -85,7 +85,7 @@ def f_type_id( is_type_tt ):
|
||||||
return 'id_Interface-type_hidden' if is_type_tt else 'id_Interface-type'
|
return 'id_Interface-type_hidden' if is_type_tt else 'id_Interface-type'
|
||||||
|
|
||||||
def generate_ipv4_choices( form ) :
|
def generate_ipv4_choices( form ) :
|
||||||
""" Generate the parameter choices for the bootstrap_form_typeahead tag
|
""" Generate the parameter choices for the massive_bootstrap_form tag
|
||||||
"""
|
"""
|
||||||
f_ipv4 = form.fields['ipv4']
|
f_ipv4 = form.fields['ipv4']
|
||||||
used_mtype_id = []
|
used_mtype_id = []
|
||||||
|
@ -112,7 +112,7 @@ def generate_ipv4_choices( form ) :
|
||||||
return choices
|
return choices
|
||||||
|
|
||||||
def generate_ipv4_engine( is_type_tt ) :
|
def generate_ipv4_engine( is_type_tt ) :
|
||||||
""" Generate the parameter engine for the bootstrap_form_typeahead tag
|
""" Generate the parameter engine for the massive_bootstrap_form tag
|
||||||
"""
|
"""
|
||||||
return (
|
return (
|
||||||
'new Bloodhound( {{'
|
'new Bloodhound( {{'
|
||||||
|
@ -126,7 +126,7 @@ def generate_ipv4_engine( is_type_tt ) :
|
||||||
)
|
)
|
||||||
|
|
||||||
def generate_ipv4_match_func( is_type_tt ) :
|
def generate_ipv4_match_func( is_type_tt ) :
|
||||||
""" Generate the parameter match_func for the bootstrap_form_typeahead tag
|
""" Generate the parameter match_func for the massive_bootstrap_form tag
|
||||||
"""
|
"""
|
||||||
return (
|
return (
|
||||||
'function(q, sync) {{'
|
'function(q, sync) {{'
|
||||||
|
@ -142,20 +142,20 @@ def generate_ipv4_match_func( is_type_tt ) :
|
||||||
type_id = f_type_id( is_type_tt )
|
type_id = f_type_id( is_type_tt )
|
||||||
)
|
)
|
||||||
|
|
||||||
def generate_ipv4_bft_param( form, is_type_tt ):
|
def generate_ipv4_mbf_param( form, is_type_tt ):
|
||||||
""" Generate all the parameters to use with the bootstrap_form_typeahead
|
""" Generate all the parameters to use with the massive_bootstrap_form
|
||||||
tag """
|
tag """
|
||||||
i_choices = { 'ipv4': generate_ipv4_choices( form ) }
|
i_choices = { 'ipv4': generate_ipv4_choices( form ) }
|
||||||
i_engine = { 'ipv4': generate_ipv4_engine( is_type_tt ) }
|
i_engine = { 'ipv4': generate_ipv4_engine( is_type_tt ) }
|
||||||
i_match_func = { 'ipv4': generate_ipv4_match_func( is_type_tt ) }
|
i_match_func = { 'ipv4': generate_ipv4_match_func( is_type_tt ) }
|
||||||
i_update_on = { 'ipv4': [f_type_id( is_type_tt )] }
|
i_update_on = { 'ipv4': [f_type_id( is_type_tt )] }
|
||||||
i_bft_param = {
|
i_mbf_param = {
|
||||||
'choices': i_choices,
|
'choices': i_choices,
|
||||||
'engine': i_engine,
|
'engine': i_engine,
|
||||||
'match_func': i_match_func,
|
'match_func': i_match_func,
|
||||||
'update_on': i_update_on
|
'update_on': i_update_on
|
||||||
}
|
}
|
||||||
return i_bft_param
|
return i_mbf_param
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def new_machine(request, userid):
|
def new_machine(request, userid):
|
||||||
|
@ -203,8 +203,8 @@ def new_machine(request, userid):
|
||||||
reversion.set_comment("Création")
|
reversion.set_comment("Création")
|
||||||
messages.success(request, "La machine a été créée")
|
messages.success(request, "La machine a été créée")
|
||||||
return redirect("/users/profil/" + str(user.id))
|
return redirect("/users/profil/" + str(user.id))
|
||||||
i_bft_param = generate_ipv4_bft_param( interface, False )
|
i_mbf_param = generate_ipv4_mbf_param( interface, False )
|
||||||
return form({'machineform': machine, 'interfaceform': interface, 'domainform': domain, 'i_bft_param': i_bft_param}, 'machines/machine.html', request)
|
return form({'machineform': machine, 'interfaceform': interface, 'domainform': domain, 'i_mbf_param': i_mbf_param}, 'machines/machine.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def edit_interface(request, interfaceid):
|
def edit_interface(request, interfaceid):
|
||||||
|
@ -243,8 +243,8 @@ def edit_interface(request, interfaceid):
|
||||||
reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in domain_form.changed_data))
|
reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in domain_form.changed_data))
|
||||||
messages.success(request, "La machine a été modifiée")
|
messages.success(request, "La machine a été modifiée")
|
||||||
return redirect("/users/profil/" + str(interface.machine.user.id))
|
return redirect("/users/profil/" + str(interface.machine.user.id))
|
||||||
i_bft_param = generate_ipv4_bft_param( interface_form, False )
|
i_mbf_param = generate_ipv4_mbf_param( interface_form, False )
|
||||||
return form({'machineform': machine_form, 'interfaceform': interface_form, 'domainform': domain_form, 'i_bft_param': i_bft_param}, 'machines/machine.html', request)
|
return form({'machineform': machine_form, 'interfaceform': interface_form, 'domainform': domain_form, 'i_mbf_param': i_mbf_param}, 'machines/machine.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def del_machine(request, machineid):
|
def del_machine(request, machineid):
|
||||||
|
@ -302,8 +302,8 @@ def new_interface(request, machineid):
|
||||||
reversion.set_comment("Création")
|
reversion.set_comment("Création")
|
||||||
messages.success(request, "L'interface a été ajoutée")
|
messages.success(request, "L'interface a été ajoutée")
|
||||||
return redirect("/users/profil/" + str(machine.user.id))
|
return redirect("/users/profil/" + str(machine.user.id))
|
||||||
i_bft_param = generate_ipv4_bft_param( interface_form, False )
|
i_mbf_param = generate_ipv4_mbf_param( interface_form, False )
|
||||||
return form({'interfaceform': interface_form, 'domainform': domain_form, 'i_bft_param': i_bft_param}, 'machines/machine.html', request)
|
return form({'interfaceform': interface_form, 'domainform': domain_form, 'i_mbf_param': i_mbf_param}, 'machines/machine.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def del_interface(request, interfaceid):
|
def del_interface(request, interfaceid):
|
||||||
|
|
|
@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|
||||||
{% load bootstrap3 %}
|
{% load bootstrap3 %}
|
||||||
{% load bootstrap_form_typeahead %}
|
{% load massive_bootstrap_form %}
|
||||||
|
|
||||||
{% block title %}Création et modification des préférences{% endblock %}
|
{% block title %}Création et modification des préférences{% endblock %}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
|
||||||
<form class="form" method="post">
|
<form class="form" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% bootstrap_form_typeahead options 'utilisateur_asso' %}
|
{% massive_bootstrap_form options 'utilisateur_asso' %}
|
||||||
{% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %}
|
{% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %}
|
||||||
</form>
|
</form>
|
||||||
<br />
|
<br />
|
||||||
|
|
|
@ -29,32 +29,40 @@ from bootstrap3.forms import render_field
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def bootstrap_form_typeahead(django_form, typeahead_fields, *args, **kwargs):
|
def massive_bootstrap_form(form, mbf_fields, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Render a form where some specific fields are rendered using Typeahead.
|
Render a form where some specific fields are rendered using Twitter
|
||||||
Using Typeahead really improves the performance, the speed and UX when
|
Typeahead and/or splitree's Bootstrap Tokenfield to improve the performance, the
|
||||||
dealing with very large datasets (select with 50k+ elts for instance).
|
speed and UX when dealing with very large datasets (select with 50k+ elts
|
||||||
|
for instance).
|
||||||
|
When the fields specified should normally be rendered as a select with
|
||||||
|
single selectable option, Twitter Typeahead is used for a better display
|
||||||
|
and the matching query engine. When dealing with multiple selectable
|
||||||
|
options, sliptree's Bootstrap Tokenfield in addition with Typeahead.
|
||||||
For convenience, it accepts the same parameters as a standard bootstrap
|
For convenience, it accepts the same parameters as a standard bootstrap
|
||||||
can accept.
|
can accept.
|
||||||
|
|
||||||
**Tag name**::
|
**Tag name**::
|
||||||
|
|
||||||
bootstrap_form_typeahead
|
massive_bootstrap_form
|
||||||
|
|
||||||
**Parameters**:
|
**Parameters**:
|
||||||
|
|
||||||
form
|
form (required)
|
||||||
The form that is to be rendered
|
The form that is to be rendered
|
||||||
|
|
||||||
typeahead_fields
|
mbf_fields (optional)
|
||||||
A list of field names (comma separated) that should be rendered
|
A list of field names (comma separated) that should be rendered
|
||||||
with typeahead instead of the default bootstrap renderer.
|
with Typeahead/Tokenfield instead of the default bootstrap
|
||||||
|
renderer.
|
||||||
|
If not specified, all fields will be rendered as a normal bootstrap
|
||||||
|
field.
|
||||||
|
|
||||||
bft_param
|
mbf_param (optional)
|
||||||
A dict of parameters for the bootstrap_form_typeahead tag. The
|
A dict of parameters for the massive_bootstrap_form tag. The
|
||||||
possible parameters are the following.
|
possible parameters are the following.
|
||||||
|
|
||||||
choices
|
choices (optional)
|
||||||
A dict of strings representing the choices in JS. The keys of
|
A dict of strings representing the choices in JS. The keys of
|
||||||
the dict are the names of the concerned fields. The choices
|
the dict are the names of the concerned fields. The choices
|
||||||
must be an array of objects. Each of those objects must at
|
must be an array of objects. Each of those objects must at
|
||||||
|
@ -71,7 +79,7 @@ def bootstrap_form_typeahead(django_form, typeahead_fields, *args, **kwargs):
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
engine
|
engine (optional)
|
||||||
A dict of strings representating the engine used for matching
|
A dict of strings representating the engine used for matching
|
||||||
queries and possible values with typeahead. The keys of the
|
queries and possible values with typeahead. The keys of the
|
||||||
dict are the names of the concerned fields. The string is valid
|
dict are the names of the concerned fields. The string is valid
|
||||||
|
@ -81,7 +89,7 @@ def bootstrap_form_typeahead(django_form, typeahead_fields, *args, **kwargs):
|
||||||
Example :
|
Example :
|
||||||
'engine' : {'field_A': 'new Bloodhound()', 'field_B': ..., ...}
|
'engine' : {'field_A': 'new Bloodhound()', 'field_B': ..., ...}
|
||||||
|
|
||||||
match_func
|
match_func (optional)
|
||||||
A dict of strings representing a valid JS function used in the
|
A dict of strings representing a valid JS function used in the
|
||||||
dataset to overload the matching engine. The keys of the dict
|
dataset to overload the matching engine. The keys of the dict
|
||||||
are the names of the concerned fields. This function is used
|
are the names of the concerned fields. This function is used
|
||||||
|
@ -100,7 +108,7 @@ def bootstrap_form_typeahead(django_form, typeahead_fields, *args, **kwargs):
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
update_on
|
update_on (optional)
|
||||||
A dict of list of ids that the values depends on. The engine
|
A dict of list of ids that the values depends on. The engine
|
||||||
and the typeahead properties are recalculated and reapplied.
|
and the typeahead properties are recalculated and reapplied.
|
||||||
Example :
|
Example :
|
||||||
|
@ -114,10 +122,10 @@ def bootstrap_form_typeahead(django_form, typeahead_fields, *args, **kwargs):
|
||||||
|
|
||||||
**Usage**::
|
**Usage**::
|
||||||
|
|
||||||
{% bootstrap_form_typeahead
|
{% massive_bootstrap_form
|
||||||
form
|
form
|
||||||
[ '<field1>[,<field2>[,...]]' ]
|
[ '<field1>[,<field2>[,...]]' ]
|
||||||
[ {
|
[ mbf_param = {
|
||||||
[ 'choices': {
|
[ 'choices': {
|
||||||
[ '<field1>': '<choices1>'
|
[ '<field1>': '<choices1>'
|
||||||
[, '<field2>': '<choices2>'
|
[, '<field2>': '<choices2>'
|
||||||
|
@ -144,56 +152,55 @@ def bootstrap_form_typeahead(django_form, typeahead_fields, *args, **kwargs):
|
||||||
|
|
||||||
**Example**:
|
**Example**:
|
||||||
|
|
||||||
{% bootstrap_form_typeahead form 'ipv4' choices='[...]' %}
|
{% massive_bootstrap_form form 'ipv4' choices='[...]' %}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
t_fields = typeahead_fields.split(',')
|
fields = mbf_fields.split(',')
|
||||||
params = kwargs.get('bft_param', {})
|
param = kwargs.pop('mbf_param', {})
|
||||||
exclude = params.get('exclude', None)
|
exclude = param.get('exclude', '').split(',')
|
||||||
exclude = exclude.split(',') if exclude else []
|
choices = param.get('choices', {})
|
||||||
t_choices = params.get('choices', {})
|
engine = param.get('engine', {})
|
||||||
t_engine = params.get('engine', {})
|
match_func = param.get('match_func', {})
|
||||||
t_match_func = params.get('match_func', {})
|
update_on = param.get('update_on', {})
|
||||||
t_update_on = params.get('update_on', {})
|
hidden_fields = [h.name for h in form.hidden_fields()]
|
||||||
hidden = [h.name for h in django_form.hidden_fields()]
|
|
||||||
|
|
||||||
form = ''
|
html = ''
|
||||||
for f_name, f_value in django_form.fields.items() :
|
for f_name, f_value in form.fields.items() :
|
||||||
if not f_name in exclude :
|
if not f_name in exclude :
|
||||||
if f_name in t_fields and not f_name in hidden :
|
if f_name in fields and not f_name in hidden_fields :
|
||||||
f_bound = f_value.get_bound_field( django_form, f_name )
|
f_bound = f_value.get_bound_field( form, f_name )
|
||||||
f_value.widget = TextInput(
|
f_value.widget = TextInput(
|
||||||
attrs={
|
attrs={
|
||||||
'name': 'typeahead_'+f_name,
|
'name': 'mbf_'+f_name,
|
||||||
'placeholder': f_value.empty_label
|
'placeholder': f_value.empty_label
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
form += render_field(
|
html += render_field(
|
||||||
f_value.get_bound_field( django_form, f_name ),
|
f_value.get_bound_field( form, f_name ),
|
||||||
*args,
|
*args,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
form += render_tag(
|
html += render_tag(
|
||||||
'div',
|
'div',
|
||||||
content = hidden_tag( f_bound, f_name ) +
|
content = hidden_tag( f_bound, f_name ) +
|
||||||
typeahead_js(
|
mbf_js(
|
||||||
f_name,
|
f_name,
|
||||||
f_value,
|
f_value,
|
||||||
f_bound,
|
f_bound,
|
||||||
t_choices,
|
choices,
|
||||||
t_engine,
|
engine,
|
||||||
t_match_func,
|
match_func,
|
||||||
t_update_on
|
update_on
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
form += render_field(
|
html += render_field(
|
||||||
f_value.get_bound_field(django_form, f_name),
|
f_value.get_bound_field( form, f_name ),
|
||||||
*args,
|
*args,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
return mark_safe( form )
|
return mark_safe( html )
|
||||||
|
|
||||||
def input_id( f_bound ) :
|
def input_id( f_bound ) :
|
||||||
""" The id of the HTML input element """
|
""" The id of the HTML input element """
|
||||||
|
@ -215,20 +222,20 @@ def hidden_tag( f_bound, f_name ):
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
def typeahead_js( f_name, f_value, f_bound,
|
def mbf_js( f_name, f_value, f_bound,
|
||||||
t_choices, t_engine, t_match_func, t_update_on ) :
|
choices_, engine_, match_func_, update_on_ ) :
|
||||||
""" The whole script to use """
|
""" The whole script to use """
|
||||||
|
|
||||||
choices = mark_safe( t_choices[f_name] ) if f_name in t_choices.keys() \
|
choices = mark_safe( choices_[f_name] ) if f_name in choices_.keys() \
|
||||||
else default_choices( f_value )
|
else default_choices( f_value )
|
||||||
|
|
||||||
engine = mark_safe( t_engine[f_name] ) if f_name in t_engine.keys() \
|
engine = mark_safe( engine_[f_name] ) if f_name in engine_.keys() \
|
||||||
else default_engine ( f_name )
|
else default_engine ( f_name )
|
||||||
|
|
||||||
match_func = mark_safe(t_match_func[f_name]) \
|
match_func = mark_safe( match_func_[f_name] ) \
|
||||||
if f_name in t_match_func.keys() else default_match_func( f_name )
|
if f_name in match_func_.keys() else default_match_func( f_name )
|
||||||
|
|
||||||
update_on = t_update_on[f_name] if f_name in t_update_on.keys() else []
|
update_on = update_on_[f_name] if f_name in update_on_.keys() else []
|
||||||
|
|
||||||
js_content = (
|
js_content = (
|
||||||
'var choices_{f_name} = {choices};'
|
'var choices_{f_name} = {choices};'
|
|
@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|
||||||
{% load bootstrap3 %}
|
{% load bootstrap3 %}
|
||||||
{% load bootstrap_form_typeahead %}
|
{% load massive_bootstrap_form %}
|
||||||
|
|
||||||
{% block title %}Création et modification d'un switch{% endblock %}
|
{% block title %}Création et modification d'un switch{% endblock %}
|
||||||
|
|
||||||
|
@ -47,16 +47,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<form class="form" method="post">
|
<form class="form" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% if topoform %}
|
{% if topoform %}
|
||||||
{% bootstrap_form_typeahead topoform 'switch_interface' %}
|
{% massive_bootstrap_form topoform 'switch_interface' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if machineform %}
|
{% if machineform %}
|
||||||
{% bootstrap_form_typeahead machineform 'user' %}
|
{% massive_bootstrap_form machineform 'user' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if interfaceform %}
|
{% if interfaceform %}
|
||||||
{% if i_bft_param %}
|
{% if i_bft_param %}
|
||||||
{% bootstrap_form_typeahead interfaceform 'ipv4,machine' bft_param=i_bft_param %}
|
{% massive_bootstrap_form interfaceform 'ipv4,machine' mbf_param=i_bft_param %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% bootstrap_form_typeahead interfaceform 'ipv4,machine' %}
|
{% massive_bootstrap_form interfaceform 'ipv4,machine' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if domainform %}
|
{% if domainform %}
|
||||||
|
|
|
@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|
||||||
{% load bootstrap3 %}
|
{% load bootstrap3 %}
|
||||||
{% load bootstrap_form_typeahead %}
|
{% load massive_bootstrap_form %}
|
||||||
|
|
||||||
{% block title %}Création et modificationd 'utilisateur{% endblock %}
|
{% block title %}Création et modificationd 'utilisateur{% endblock %}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
|
||||||
<form class="form" method="post">
|
<form class="form" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% bootstrap_form_typeahead topoform 'room,related,machine_interface' %}
|
{% massive_bootstrap_form topoform 'room,related,machine_interface' %}
|
||||||
{%bootstrap_button "Créer ou modifier" button_type="submit" icon="ok" %}
|
{%bootstrap_button "Créer ou modifier" button_type="submit" icon="ok" %}
|
||||||
</form>
|
</form>
|
||||||
<br />
|
<br />
|
||||||
|
|
|
@ -51,7 +51,7 @@ from topologie.forms import AddPortForm, EditRoomForm, StackForm
|
||||||
from users.views import form
|
from users.views import form
|
||||||
|
|
||||||
from machines.forms import AliasForm, NewMachineForm, EditMachineForm, EditInterfaceForm, AddInterfaceForm
|
from machines.forms import AliasForm, NewMachineForm, EditMachineForm, EditInterfaceForm, AddInterfaceForm
|
||||||
from machines.views import generate_ipv4_bft_param
|
from machines.views import generate_ipv4_mbf_param
|
||||||
from preferences.models import AssoOption, GeneralOption
|
from preferences.models import AssoOption, GeneralOption
|
||||||
|
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ def new_switch(request):
|
||||||
reversion.set_comment("Création")
|
reversion.set_comment("Création")
|
||||||
messages.success(request, "Le switch a été créé")
|
messages.success(request, "Le switch a été créé")
|
||||||
return redirect("/topologie/")
|
return redirect("/topologie/")
|
||||||
i_bft_param = generate_ipv4_bft_param( interface, False )
|
i_bft_param = generate_ipv4_mbf_param( interface, False )
|
||||||
return form({'topoform':switch, 'machineform': machine, 'interfaceform': interface, 'domainform': domain, 'i_bft_param': i_bft_param}, 'topologie/switch.html', request)
|
return form({'topoform':switch, 'machineform': machine, 'interfaceform': interface, 'domainform': domain, 'i_bft_param': i_bft_param}, 'topologie/switch.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -442,7 +442,7 @@ def edit_switch(request, switch_id):
|
||||||
)
|
)
|
||||||
messages.success(request, "Le switch a bien été modifié")
|
messages.success(request, "Le switch a bien été modifié")
|
||||||
return redirect("/topologie/")
|
return redirect("/topologie/")
|
||||||
i_bft_param = generate_ipv4_bft_param( interface_form, False )
|
i_bft_param = generate_ipv4_mbf_param( interface_form, False )
|
||||||
return form({'topoform':switch_form, 'machineform': machine_form, 'interfaceform': interface_form, 'domainform': domain_form, 'i_bft_param': i_bft_param}, 'topologie/switch.html', request)
|
return form({'topoform':switch_form, 'machineform': machine_form, 'interfaceform': interface_form, 'domainform': domain_form, 'i_bft_param': i_bft_param}, 'topologie/switch.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
|
|
@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|
||||||
{% load bootstrap3 %}
|
{% load bootstrap3 %}
|
||||||
{% load bootstrap_form_typeahead %}
|
{% load massive_bootstrap_form %}
|
||||||
|
|
||||||
{% block title %}Création et modification d'utilisateur{% endblock %}
|
{% block title %}Création et modification d'utilisateur{% endblock %}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
|
||||||
<form class="form" method="post">
|
<form class="form" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% bootstrap_form_typeahead userform 'room' %}
|
{% massive_bootstrap_form userform 'room' %}
|
||||||
{% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %}
|
{% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %}
|
||||||
</form>
|
</form>
|
||||||
<br />
|
<br />
|
||||||
|
|
Loading…
Reference in a new issue