From 5eaaa41bc49bad66a50fb3f297982e0a071d87d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Wed, 11 Oct 2017 21:33:21 +0000 Subject: [PATCH 1/6] Renome enregistrement Text en enregistrement Txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Parce que ça s'appelle comme ça Faudra aussi bouger dans la bdd mais là c'est plus délicat (migrations) --- machines/forms.py | 8 ++-- .../machines/{aff_text.html => aff_txt.html} | 16 +++---- .../templates/machines/index_extension.html | 8 ++-- machines/urls.py | 8 ++-- machines/views.py | 44 +++++++++---------- 5 files changed, 42 insertions(+), 42 deletions(-) rename machines/templates/machines/{aff_text.html => aff_txt.html} (84%) diff --git a/machines/forms.py b/machines/forms.py index 7ff85695..6112a182 100644 --- a/machines/forms.py +++ b/machines/forms.py @@ -210,17 +210,17 @@ class NsForm(ModelForm): class DelNsForm(Form): ns = forms.ModelMultipleChoiceField(queryset=Ns.objects.all(), label="Enregistrements NS actuels", widget=forms.CheckboxSelectMultiple) -class TextForm(ModelForm): +class TxtForm(ModelForm): class Meta: model = Text fields = '__all__' def __init__(self, *args, **kwargs): prefix = kwargs.pop('prefix', self.Meta.model.__name__) - super(TextForm, self).__init__(*args, prefix=prefix, **kwargs) + super(TxtForm, self).__init__(*args, prefix=prefix, **kwargs) -class DelTextForm(Form): - text = forms.ModelMultipleChoiceField(queryset=Text.objects.all(), label="Enregistrements Text actuels", widget=forms.CheckboxSelectMultiple) +class DelTxtForm(Form): + txt = forms.ModelMultipleChoiceField(queryset=Text.objects.all(), label="Enregistrements Txt actuels", widget=forms.CheckboxSelectMultiple) class NasForm(ModelForm): class Meta: diff --git a/machines/templates/machines/aff_text.html b/machines/templates/machines/aff_txt.html similarity index 84% rename from machines/templates/machines/aff_text.html rename to machines/templates/machines/aff_txt.html index f3ada132..fd7c5ee6 100644 --- a/machines/templates/machines/aff_text.html +++ b/machines/templates/machines/aff_txt.html @@ -25,21 +25,21 @@ with this program; if not, write to the Free Software Foundation, Inc., - - - + + + - {% for text in text_list %} + {% for txt in txt_list %} - - + + {% endfor %} diff --git a/machines/templates/machines/index_extension.html b/machines/templates/machines/index_extension.html index 20587d85..88eb5411 100644 --- a/machines/templates/machines/index_extension.html +++ b/machines/templates/machines/index_extension.html @@ -47,12 +47,12 @@ with this program; if not, write to the Free Software Foundation, Inc., Supprimer un enregistrement NS {% endif %} {% include "machines/aff_ns.html" with ns_list=ns_list %} -

Liste des enregistrements Text

+

Liste des enregistrements TXT

{% if is_infra %} - Ajouter un enregistrement TXT - Supprimer un enregistrement TXT + Ajouter un enregistrement TXT + Supprimer un enregistrement TXT {% endif %} - {% include "machines/aff_text.html" with text_list=text_list %} + {% include "machines/aff_txt.html" with txt_list=txt_list %}


diff --git a/machines/urls.py b/machines/urls.py index 886c7c0a..1ce5db7d 100644 --- a/machines/urls.py +++ b/machines/urls.py @@ -47,9 +47,9 @@ urlpatterns = [ url(r'^add_mx/$', views.add_mx, name='add-mx'), url(r'^edit_mx/(?P[0-9]+)$', views.edit_mx, name='edit-mx'), url(r'^del_mx/$', views.del_mx, name='del-mx'), - url(r'^add_text/$', views.add_text, name='add-text'), - url(r'^edit_text/(?P[0-9]+)$', views.edit_text, name='edit-text'), - url(r'^del_text/$', views.del_text, name='del-text'), + url(r'^add_txt/$', views.add_txt, name='add-txt'), + url(r'^edit_txt/(?P[0-9]+)$', views.edit_txt, name='edit-txt'), + url(r'^del_txt/$', views.del_txt, name='del-txt'), url(r'^add_ns/$', views.add_ns, name='add-ns'), url(r'^edit_ns/(?P[0-9]+)$', views.edit_ns, name='edit-ns'), url(r'^del_ns/$', views.del_ns, name='del-ns'), @@ -76,7 +76,7 @@ urlpatterns = [ url(r'^history/(?Pextension)/(?P[0-9]+)$', views.history, name='history'), url(r'^history/(?Pmx)/(?P[0-9]+)$', views.history, name='history'), url(r'^history/(?Pns)/(?P[0-9]+)$', views.history, name='history'), - url(r'^history/(?Ptext)/(?P[0-9]+)$', views.history, name='history'), + url(r'^history/(?Ptxt)/(?P[0-9]+)$', views.history, name='history'), url(r'^history/(?Piptype)/(?P[0-9]+)$', views.history, name='history'), url(r'^history/(?Palias)/(?P[0-9]+)$', views.history, name='history'), url(r'^history/(?Pvlan)/(?P[0-9]+)$', views.history, name='history'), diff --git a/machines/views.py b/machines/views.py index a0bc92cf..06843a76 100644 --- a/machines/views.py +++ b/machines/views.py @@ -49,7 +49,7 @@ from reversion.models import Version import re from .forms import NewMachineForm, EditMachineForm, EditInterfaceForm, AddInterfaceForm, MachineTypeForm, DelMachineTypeForm, ExtensionForm, DelExtensionForm, BaseEditInterfaceForm, BaseEditMachineForm -from .forms import EditIpTypeForm, IpTypeForm, DelIpTypeForm, DomainForm, AliasForm, DelAliasForm, NsForm, DelNsForm, TextForm, DelTextForm, MxForm, DelMxForm, VlanForm, DelVlanForm, ServiceForm, DelServiceForm, NasForm, DelNasForm +from .forms import EditIpTypeForm, IpTypeForm, DelIpTypeForm, DomainForm, AliasForm, DelAliasForm, NsForm, DelNsForm, TxtForm, DelTxtForm, MxForm, DelMxForm, VlanForm, DelVlanForm, ServiceForm, DelServiceForm, NasForm, DelNasForm from .forms import EditOuverturePortListForm, EditOuverturePortConfigForm from .models import IpType, Machine, Interface, IpList, MachineType, Extension, Mx, Ns, Domain, Service, Service_link, Vlan, Nas, Text, OuverturePortList, OuverturePort from users.models import User @@ -573,11 +573,11 @@ def del_ns(request): @login_required @permission_required('infra') -def add_text(request): - text = TextForm(request.POST or None) - if text.is_valid(): +def add_txt(request): + txt = TxtForm(request.POST or None) + if txt.is_valid(): with transaction.atomic(), reversion.create_revision(): - text.save() + txt.save() reversion.set_user(request.user) reversion.set_comment("Création") messages.success(request, "Cet enregistrement text a été ajouté") @@ -586,36 +586,36 @@ def add_text(request): @login_required @permission_required('infra') -def edit_text(request, textid): +def edit_txt(request, txtid): try: - text_instance = Text.objects.get(pk=textid) + txt_instance = Text.objects.get(pk=txtid) except Text.DoesNotExist: messages.error(request, u"Entrée inexistante" ) return redirect("/machines/index_extension/") - text = TextForm(request.POST or None, instance=text_instance) - if text.is_valid(): + txt = TxtForm(request.POST or None, instance=txt_instance) + if txt.is_valid(): with transaction.atomic(), reversion.create_revision(): - text.save() + txt.save() reversion.set_user(request.user) - reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in text.changed_data)) - messages.success(request, "Text modifié") + reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in txt.changed_data)) + messages.success(request, "Txt modifié") return redirect("/machines/index_extension/") return form({'machineform': text}, 'machines/machine.html', request) @login_required @permission_required('infra') -def del_text(request): - text = DelTextForm(request.POST or None) - if text.is_valid(): - text_dels = text.cleaned_data['text'] - for text_del in text_dels: +def del_txt(request): + txt = DelTxtForm(request.POST or None) + if txt.is_valid(): + txt_dels = txt.cleaned_data['txt'] + for txt_del in txt_dels: try: with transaction.atomic(), reversion.create_revision(): - text_del.delete() + txt_del.delete() reversion.set_user(request.user) - messages.success(request, "Le text a été supprimé") + messages.success(request, "Le txt a été supprimé") except ProtectedError: - messages.error(request, "Erreur le Text suivant %s ne peut être supprimé" % text_del) + messages.error(request, "Erreur le Txt suivant %s ne peut être supprimé" % txt_del) return redirect("/machines/index_extension") return form({'machineform': text, 'interfaceform': None}, 'machines/machine.html', request) @@ -960,11 +960,11 @@ def history(request, object, id): except Mx.DoesNotExist: messages.error(request, "Mx inexistant") return redirect("/machines/") - elif object == 'text' and request.user.has_perms(('cableur',)): + elif object == 'txt' and request.user.has_perms(('cableur',)): try: object_instance = Text.objects.get(pk=id) except Text.DoesNotExist: - messages.error(request, "Text inexistant") + messages.error(request, "Txt inexistant") return redirect("/machines/") elif object == 'ns' and request.user.has_perms(('cableur',)): try: From 946694b87962ce757cd0ee1ef190d5258bd59eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Wed, 11 Oct 2017 21:36:14 +0000 Subject: [PATCH 2/6] =?UTF-8?q?D=C3=A9place=20le=20BFT=20tag=20dans=20l'ap?= =?UTF-8?q?p=20Re2o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plus générique que dans une app spécifique donc plus adapté pour utiliser le tag dans d'autre apps que machine --- machines/views.py | 2 +- {machines => re2o}/templatetags/__init__.py | 0 {machines => re2o}/templatetags/bootstrap_form_typeahead.py | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename {machines => re2o}/templatetags/__init__.py (100%) rename {machines => re2o}/templatetags/bootstrap_form_typeahead.py (100%) diff --git a/machines/views.py b/machines/views.py index 06843a76..06b151f0 100644 --- a/machines/views.py +++ b/machines/views.py @@ -55,7 +55,7 @@ from .models import IpType, Machine, Interface, IpList, MachineType, Extension, from users.models import User from users.models import all_has_access from preferences.models import GeneralOption, OptionalMachine -from .templatetags.bootstrap_form_typeahead import hidden_id, input_id +from re2o.templatetags.bootstrap_form_typeahead import hidden_id, input_id def all_active_interfaces(): """Renvoie l'ensemble des machines autorisées à sortir sur internet """ diff --git a/machines/templatetags/__init__.py b/re2o/templatetags/__init__.py similarity index 100% rename from machines/templatetags/__init__.py rename to re2o/templatetags/__init__.py diff --git a/machines/templatetags/bootstrap_form_typeahead.py b/re2o/templatetags/bootstrap_form_typeahead.py similarity index 100% rename from machines/templatetags/bootstrap_form_typeahead.py rename to re2o/templatetags/bootstrap_form_typeahead.py From c8ae698bbf29b4601abe76ae8d7507245543ebc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Thu, 12 Oct 2017 09:53:11 +0000 Subject: [PATCH 3/6] Prise en compte du prefix dans le bft tag --- re2o/templatetags/bootstrap_form_typeahead.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/re2o/templatetags/bootstrap_form_typeahead.py b/re2o/templatetags/bootstrap_form_typeahead.py index 7ccab390..4c665361 100644 --- a/re2o/templatetags/bootstrap_form_typeahead.py +++ b/re2o/templatetags/bootstrap_form_typeahead.py @@ -209,7 +209,7 @@ def hidden_tag( f_bound, f_name ): 'input', attrs={ 'id': hidden_id( f_bound ), - 'name': f_name, + 'name': f_bound.html_name, 'type': 'hidden', 'value': f_bound.value() or "" } From 4aa67bf4d9c776511783f8dc00e737a3fcb3a408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Thu, 12 Oct 2017 09:57:16 +0000 Subject: [PATCH 4/6] Utilisation massive du bft tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le BFT tag est utilisé sur tous les champs qui ont pas mal de résultats (user, machines, ip, chambre, ...). Normalement tous les select à choix uniques concerné ont été modifiés. Je pense en avoir oublié aucun. --- .../templates/cotisations/edit_facture.html | 3 +- machines/templates/machines/machine.html | 78 +++++++++++++++++-- machines/views.py | 60 +++++++------- .../preferences/edit_preferences.html | 3 +- static/js/sapphire.js | 61 ++++++++++----- topologie/templates/topologie/switch.html | 11 ++- topologie/views.py | 9 ++- users/templates/users/user.html | 3 +- 8 files changed, 160 insertions(+), 68 deletions(-) diff --git a/cotisations/templates/cotisations/edit_facture.html b/cotisations/templates/cotisations/edit_facture.html index 2d6663f7..11e454f5 100644 --- a/cotisations/templates/cotisations/edit_facture.html +++ b/cotisations/templates/cotisations/edit_facture.html @@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% load bootstrap3 %} {% load staticfiles%} +{% load bootstrap_form_typeahead %} {% block title %}Création et modification de factures{% endblock %} @@ -34,7 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% csrf_token %}

Editer la facture

- {% bootstrap_form factureform %} + {% bootstrap_form_typeahead factureform 'user' %} {{ venteform.management_form }}

Articles de la facture

Zone concernéeEnregistrementZone concernéeEnregistrement
{{ text.zone }}{{ text.dns_entry }}{{ txt.zone }}{{ txt.dns_entry }} {% if is_infra %} - {% include 'buttons/edit.html' with href='machines:edit-text' id=text.id %} + {% include 'buttons/edit.html' with href='machines:edit-txt' id=txt.id %} {% endif %} - {% include 'buttons/history.html' with href='machines:history' name='text' id=text.id %} + {% include 'buttons/history.html' with href='machines:history' name='txt' id=txt.id %}
diff --git a/machines/templates/machines/machine.html b/machines/templates/machines/machine.html index d34dccb9..4f68b6ee 100644 --- a/machines/templates/machines/machine.html +++ b/machines/templates/machines/machine.html @@ -39,6 +39,36 @@ with this program; if not, write to the Free Software Foundation, Inc., {% if domainform %} {% bootstrap_form_errors domainform %} {% endif %} +{% if iptypeform %} +{% bootstrap_form_errors iptypeform %} +{% endif %} +{% if machinetypeform %} +{% bootstrap_form_errors machinetypeform %} +{% endif %} +{% if extensionform %} +{% bootstrap_form_errors extensionform %} +{% endif %} +{% if mxform %} +{% bootstrap_form_errors mxform %} +{% endif %} +{% if nsform %} +{% bootstrap_form_errors nsform %} +{% endif %} +{% if txtform %} +{% bootstrap_form_errors txtform %} +{% endif %} +{% if aliasform %} +{% bootstrap_form_errors aliasform %} +{% endif %} +{% if serviceform %} +{% bootstrap_form_errors serviceform %} +{% endif %} +{% if vlanform %} +{% bootstrap_form_errors vlanform %} +{% endif %} +{% if nasform %} +{% bootstrap_form_errors nasform %} +{% endif %} {% csrf_token %} @@ -49,23 +79,55 @@ 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 %}

Domaine

{% bootstrap_form domainform %} {% endif %} + {% if iptypeform %} +

Type d'IP

+ {% bootstrap_form iptypeform %} + {% endif %} + {% if machinetypeform %} +

Type de machine

+ {% bootstrap_form machinetypeform %} + {% endif %} + {% if extensionform %} +

Extension

+ {% bootstrap_form_typeahead extensionform 'origin' %} + {% endif %} + {% if mxform %} +

Enregistrement MX

+ {% bootstrap_form_typeahead mxform 'name' %} + {% endif %} + {% if nsform %} +

Enregistrement NS

+ {% bootstrap_form_typeahead nsform 'ns' %} + {% endif %} + {% if txtform %} +

Enregistrement TXT

+ {% bootstrap_form txtform %} + {% endif %} + {% if aliasform %} +

Alias

+ {% bootstrap_form aliasform %} + {% endif %} + {% if serviceform %} +

Service

+ {% bootstrap_form serviceform %} + {% endif %} + {% if vlanform %} +

Vlan

+ {% bootstrap_form vlanform %} + {% endif %} + {% if nasform %} +

NAS

+ {% bootstrap_form nasform %} + {% endif %} {% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %}
diff --git a/machines/views.py b/machines/views.py index 06b151f0..0e00dc67 100644 --- a/machines/views.py +++ b/machines/views.py @@ -340,7 +340,7 @@ def add_iptype(request): reversion.set_comment("Création") messages.success(request, "Ce type d'ip a été ajouté") return redirect("/machines/index_iptype") - return form({'machineform': iptype, 'interfaceform': None}, 'machines/machine.html', request) + return form({'iptypeform': iptype}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -359,7 +359,7 @@ def edit_iptype(request, iptypeid): reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in iptype.changed_data)) messages.success(request, "Type d'ip modifié") return redirect("/machines/index_iptype/") - return form({'machineform': iptype}, 'machines/machine.html', request) + return form({'iptypeform': iptype}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -377,7 +377,7 @@ def del_iptype(request): except ProtectedError: messages.error(request, "Le type d'ip %s est affectée à au moins une machine, vous ne pouvez pas le supprimer" % iptype_del) return redirect("/machines/index_iptype") - return form({'machineform': iptype, 'interfaceform': None}, 'machines/machine.html', request) + return form({'iptypeform': iptype}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -390,7 +390,7 @@ def add_machinetype(request): reversion.set_comment("Création") messages.success(request, "Ce type de machine a été ajouté") return redirect("/machines/index_machinetype") - return form({'machineform': machinetype, 'interfaceform': None}, 'machines/machine.html', request) + return form({'machinetypeform': machinetype}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -408,7 +408,7 @@ def edit_machinetype(request, machinetypeid): reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in machinetype.changed_data)) messages.success(request, "Type de machine modifié") return redirect("/machines/index_machinetype/") - return form({'machineform': machinetype}, 'machines/machine.html', request) + return form({'machinetypeform': machinetype}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -425,7 +425,7 @@ def del_machinetype(request): except ProtectedError: messages.error(request, "Le type de machine %s est affectée à au moins une machine, vous ne pouvez pas le supprimer" % machinetype_del) return redirect("/machines/index_machinetype") - return form({'machineform': machinetype, 'interfaceform': None}, 'machines/machine.html', request) + return form({'machinetypeform': machinetype}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -438,7 +438,7 @@ def add_extension(request): reversion.set_comment("Création") messages.success(request, "Cette extension a été ajoutée") return redirect("/machines/index_extension") - return form({'machineform': extension, 'interfaceform': None}, 'machines/machine.html', request) + return form({'extensionform': extension}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -456,7 +456,7 @@ def edit_extension(request, extensionid): reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in extension.changed_data)) messages.success(request, "Extension modifiée") return redirect("/machines/index_extension/") - return form({'machineform': extension}, 'machines/machine.html', request) + return form({'extensionform': extension}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -473,7 +473,7 @@ def del_extension(request): except ProtectedError: messages.error(request, "L'extension %s est affectée à au moins un type de machine, vous ne pouvez pas la supprimer" % extension_del) return redirect("/machines/index_extension") - return form({'machineform': extension, 'interfaceform': None}, 'machines/machine.html', request) + return form({'extensionform': extension}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -486,7 +486,7 @@ def add_mx(request): reversion.set_comment("Création") messages.success(request, "Cet enregistrement mx a été ajouté") return redirect("/machines/index_extension") - return form({'machineform': mx, 'interfaceform': None}, 'machines/machine.html', request) + return form({'mxform': mx}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -504,7 +504,7 @@ def edit_mx(request, mxid): reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in mx.changed_data)) messages.success(request, "Mx modifié") return redirect("/machines/index_extension/") - return form({'machineform': mx}, 'machines/machine.html', request) + return form({'mxform': mx}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -521,7 +521,7 @@ def del_mx(request): except ProtectedError: messages.error(request, "Erreur le Mx suivant %s ne peut être supprimé" % mx_del) return redirect("/machines/index_extension") - return form({'machineform': mx, 'interfaceform': None}, 'machines/machine.html', request) + return form({'mxform': mx}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -534,7 +534,7 @@ def add_ns(request): reversion.set_comment("Création") messages.success(request, "Cet enregistrement ns a été ajouté") return redirect("/machines/index_extension") - return form({'machineform': ns, 'interfaceform': None}, 'machines/machine.html', request) + return form({'nsform': ns}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -552,7 +552,7 @@ def edit_ns(request, nsid): reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in ns.changed_data)) messages.success(request, "Ns modifié") return redirect("/machines/index_extension/") - return form({'machineform': ns}, 'machines/machine.html', request) + return form({'nsform': ns}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -569,7 +569,7 @@ def del_ns(request): except ProtectedError: messages.error(request, "Erreur le Ns suivant %s ne peut être supprimé" % ns_del) return redirect("/machines/index_extension") - return form({'machineform': ns, 'interfaceform': None}, 'machines/machine.html', request) + return form({'nsform': ns}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -582,7 +582,7 @@ def add_txt(request): reversion.set_comment("Création") messages.success(request, "Cet enregistrement text a été ajouté") return redirect("/machines/index_extension") - return form({'machineform': text, 'interfaceform': None}, 'machines/machine.html', request) + return form({'txtform': txt}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -600,7 +600,7 @@ def edit_txt(request, txtid): reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in txt.changed_data)) messages.success(request, "Txt modifié") return redirect("/machines/index_extension/") - return form({'machineform': text}, 'machines/machine.html', request) + return form({'txtform': txt}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -617,7 +617,7 @@ def del_txt(request): except ProtectedError: messages.error(request, "Erreur le Txt suivant %s ne peut être supprimé" % txt_del) return redirect("/machines/index_extension") - return form({'machineform': text, 'interfaceform': None}, 'machines/machine.html', request) + return form({'txtform': txt}, 'machines/machine.html', request) @login_required def add_alias(request, interfaceid): @@ -645,7 +645,7 @@ def add_alias(request, interfaceid): reversion.set_comment("Création") messages.success(request, "Cet alias a été ajouté") return redirect("/machines/index_alias/" + str(interfaceid)) - return form({'machineform': alias, 'interfaceform': None}, 'machines/machine.html', request) + return form({'aliasform': alias}, 'machines/machine.html', request) @login_required def edit_alias(request, aliasid): @@ -665,7 +665,7 @@ def edit_alias(request, aliasid): reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in alias.changed_data)) messages.success(request, "Alias modifié") return redirect("/machines/index_alias/" + str(alias_instance.cname.interface_parent.id)) - return form({'machineform': alias}, 'machines/machine.html', request) + return form({'aliasform': alias}, 'machines/machine.html', request) @login_required def del_alias(request, interfaceid): @@ -689,7 +689,7 @@ def del_alias(request, interfaceid): except ProtectedError: messages.error(request, "Erreur l'alias suivant %s ne peut être supprimé" % alias_del) return redirect("/machines/index_alias/" + str(interfaceid)) - return form({'machineform': alias, 'interfaceform': None}, 'machines/machine.html', request) + return form({'aliasform': alias}, 'machines/machine.html', request) @login_required @@ -703,7 +703,7 @@ def add_service(request): reversion.set_comment("Création") messages.success(request, "Cet enregistrement service a été ajouté") return redirect("/machines/index_service") - return form({'machineform': service}, 'machines/machine.html', request) + return form({'serviceform': service}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -721,7 +721,7 @@ def edit_service(request, serviceid): reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in service.changed_data)) messages.success(request, "Service modifié") return redirect("/machines/index_service/") - return form({'machineform': service}, 'machines/machine.html', request) + return form({'serviceform': service}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -738,7 +738,7 @@ def del_service(request): except ProtectedError: messages.error(request, "Erreur le service suivant %s ne peut être supprimé" % service_del) return redirect("/machines/index_service") - return form({'machineform': service}, 'machines/machine.html', request) + return form({'serviceform': service}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -751,7 +751,7 @@ def add_vlan(request): reversion.set_comment("Création") messages.success(request, "Cet enregistrement vlan a été ajouté") return redirect("/machines/index_vlan") - return form({'machineform': vlan, 'interfaceform': None}, 'machines/machine.html', request) + return form({'vlanform': vlan}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -769,7 +769,7 @@ def edit_vlan(request, vlanid): reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in vlan.changed_data)) messages.success(request, "Vlan modifié") return redirect("/machines/index_vlan/") - return form({'machineform': vlan}, 'machines/machine.html', request) + return form({'vlanform': vlan}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -786,7 +786,7 @@ def del_vlan(request): except ProtectedError: messages.error(request, "Erreur le Vlan suivant %s ne peut être supprimé" % vlan_del) return redirect("/machines/index_vlan") - return form({'machineform': vlan, 'interfaceform': None}, 'machines/machine.html', request) + return form({'vlanform': vlan}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -799,7 +799,7 @@ def add_nas(request): reversion.set_comment("Création") messages.success(request, "Cet enregistrement nas a été ajouté") return redirect("/machines/index_nas") - return form({'machineform': nas, 'interfaceform': None}, 'machines/machine.html', request) + return form({'nasform': nas}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -817,7 +817,7 @@ def edit_nas(request, nasid): reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in nas.changed_data)) messages.success(request, "Nas modifié") return redirect("/machines/index_nas/") - return form({'machineform': nas}, 'machines/machine.html', request) + return form({'nasform': nas}, 'machines/machine.html', request) @login_required @permission_required('infra') @@ -834,7 +834,7 @@ def del_nas(request): except ProtectedError: messages.error(request, "Erreur le Nas suivant %s ne peut être supprimé" % nas_del) return redirect("/machines/index_nas") - return form({'machineform': nas, 'interfaceform': None}, 'machines/machine.html', request) + return form({'nasform': nas}, 'machines/machine.html', request) @login_required @permission_required('cableur') diff --git a/preferences/templates/preferences/edit_preferences.html b/preferences/templates/preferences/edit_preferences.html index 25fa4c02..610889dd 100644 --- a/preferences/templates/preferences/edit_preferences.html +++ b/preferences/templates/preferences/edit_preferences.html @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load bootstrap3 %} +{% load bootstrap_form_typeahead %} {% block title %}Création et modification des préférences{% endblock %} @@ -34,7 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% csrf_token %} -{% bootstrap_form options %} +{% bootstrap_form_typeahead options 'utilisateur_asso' %} {% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %}
diff --git a/static/js/sapphire.js b/static/js/sapphire.js index d5e0f897..db65fdd1 100644 --- a/static/js/sapphire.js +++ b/static/js/sapphire.js @@ -207,6 +207,9 @@ var Sapphire = function () { } }, + columns: undefined, + alpha: undefined, + drops: undefined, canvas: undefined, init: function() { @@ -214,44 +217,56 @@ var Sapphire = function () { for (var e in sapphire.elts) { sapphire.elts[e].get(main); } }, + resize: function() { + var ctx = sapphire.canvas.getContext("2d"); + var img = ctx.getImageData( 0, 0, sapphire.canvas.width, sapphire.canvas.height ); + sapphire.canvas.width = window.innerWidth; + sapphire.canvas.height = window.innerHeight; + ctx.fillStyle = "rgba(0, 0, 0, 1)"; + ctx.fillRect(0, 0, sapphire.canvas.width, sapphire.canvas.height); + ctx.putImageData( img, 0, 0 ); + sapphire.columns = sapphire.canvas.width/FONT_SIZE; + sapphire.alpha = Math.max( 0, Math.min( 1, TRAIL_TIME / ( sapphire.canvas.height/FONT_SIZE ) ) ); + var newDrops = []; + for(var x = 0; x < sapphire.columns; x++) { + if ( sapphire.drops && sapphire.drops[x] ) { newDrops[x] = sapphire.drops[x] } + else { + newDrops[x] = []; + var nb = Math.floor(Math.random()*MAX_CHAR); + for (var y = 0; y < nb; y++) + newDrops[x][y] = 0; + } + } + sapphire.drops = newDrops; + }, + run: function() { sapphire.canvas = document.createElement("canvas"); document.body.appendChild(sapphire.canvas); - sapphire.canvas.width = window.innerWidth; - sapphire.canvas.height = window.innerHeight; sapphire.canvas.style.position = "fixed"; sapphire.canvas.style.zIndex = -1; sapphire.canvas.style.left = 0; sapphire.canvas.style.top = 0; var ctx = sapphire.canvas.getContext("2d"); - - var columns = sapphire.canvas.width/FONT_SIZE; - var alpha = Math.max( 0, Math.min( 1, TRAIL_TIME / ( sapphire.canvas.height/FONT_SIZE ) ) ); - var drops = []; - for(var x = 0; x < columns; x++) - { - drops[x] = []; - var nb = Math.floor(Math.random()*MAX_CHAR); - for (var y = 0; y < nb; y++) - drops[x][y] = 1; - } + ctx.fillStyle = "rgba(0, 0, 0, 1)"; + ctx.fillRect(0, 0, sapphire.canvas.width, sapphire.canvas.height); function attenuateBackground() { - ctx.fillStyle = "rgba(0, 0, 0, "+alpha+")"; + ctx.fillStyle = "rgba(0, 0, 0, "+sapphire.alpha+")"; ctx.fillRect(0, 0, sapphire.canvas.width, sapphire.canvas.height); } function drawMatrixRainDrop() { ctx.fillStyle = RAIN_COLOR; ctx.font = FONT_SIZE + "px arial"; - for(var i = 0; i < drops.length; i++) { - for (var j = 0; j < drops[i].length; j++) { + for(var i = 0; i < sapphire.drops.length; i++) { + for (var j = 0; j < sapphire.drops[i].length; j++) { var text = CHARACTERS[Math.floor(Math.random()*CHARACTERS.length)]; - ctx.fillText(text, i*FONT_SIZE, drops[i][j]*FONT_SIZE); - if(drops[i][j]*FONT_SIZE > sapphire.canvas.height && Math.random() > 0.975) - drops[i][j] = 0; - drops[i][j]++; + ctx.fillText(text, i*FONT_SIZE, sapphire.drops[i][j]*FONT_SIZE); + if(sapphire.drops[i][j]*FONT_SIZE > sapphire.canvas.height && Math.random() > 0.975) + sapphire.drops[i][j] = 0; + sapphire.drops[i][j]++; } } } @@ -261,11 +276,15 @@ var Sapphire = function () { drawMatrixRainDrop(); } + sapphire.resize(); + window.addEventListener('resize', sapphire.resize); sapphire.triggerHandle = setInterval(drawEverything, 1000/FPS); }, + stop: function() { - sapphire.canvas.parentNode.removeChild(sapphire.canvas); + window.removeEventListener('resize', sapphire.resize); clearInterval(sapphire.triggerHandle); + sapphire.canvas.parentNode.removeChild(sapphire.canvas); }, alterElts: function() { for (var e in sapphire.elts) { sapphire.elts[e].alter(main); } }, diff --git a/topologie/templates/topologie/switch.html b/topologie/templates/topologie/switch.html index 51cec7f6..cb84e846 100644 --- a/topologie/templates/topologie/switch.html +++ b/topologie/templates/topologie/switch.html @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load bootstrap3 %} +{% load bootstrap_form_typeahead %} {% block title %}Création et modification d'un switch{% endblock %} @@ -46,13 +47,17 @@ with this program; if not, write to the Free Software Foundation, Inc., {% csrf_token %} {% if topoform %} - {% bootstrap_form topoform %} + {% bootstrap_form_typeahead topoform 'switch_interface' %} {% endif %} {% if machineform %} - {% bootstrap_form machineform %} + {% bootstrap_form_typeahead machineform 'user' %} {% endif %} {% if interfaceform %} - {% bootstrap_form interfaceform %} + {% if i_bft_param %} + {% bootstrap_form_typeahead interfaceform 'ipv4,machine' bft_param=i_bft_param %} + {% else %} + {% bootstrap_form_typeahead interfaceform 'ipv4,machine' %} + {% endif %} {% endif %} {% if domainform %} {% bootstrap_form domainform %} diff --git a/topologie/views.py b/topologie/views.py index 42cd09e7..f3dedff8 100644 --- a/topologie/views.py +++ b/topologie/views.py @@ -38,6 +38,7 @@ from users.views import form from users.models import User from machines.forms import AliasForm, NewMachineForm, EditMachineForm, EditInterfaceForm, AddInterfaceForm +from machines.views import generate_ipv4_bft_param from preferences.models import AssoOption, GeneralOption @@ -307,9 +308,10 @@ def new_switch(request): new_switch.save() reversion.set_user(request.user) reversion.set_comment("Création") - messages.success(request, "Le switch a été crée") + messages.success(request, "Le switch a été créé") return redirect("/topologie/") - return form({'topoform':switch, 'machineform': machine, 'interfaceform': interface, 'domainform': domain}, 'topologie/switch.html', request) + i_bft_param = generate_ipv4_bft_param( interface, False ) + return form({'topoform':switch, 'machineform': machine, 'interfaceform': interface, 'domainform': domain, 'i_bft_param': i_bft_param}, 'topologie/switch.html', request) @login_required @permission_required('infra') @@ -348,7 +350,8 @@ def edit_switch(request, switch_id): reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in switch_form.changed_data)) messages.success(request, "Le switch a bien été modifié") return redirect("/topologie/") - return form({'topoform':switch_form, 'machineform': machine_form, 'interfaceform': interface_form, 'domainform': domain_form}, 'topologie/switch.html', request) + i_bft_param = generate_ipv4_bft_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) @login_required @permission_required('infra') diff --git a/users/templates/users/user.html b/users/templates/users/user.html index bbdc7fc5..62d05146 100644 --- a/users/templates/users/user.html +++ b/users/templates/users/user.html @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load bootstrap3 %} +{% load bootstrap_form_typeahead %} {% block title %}Création et modification d'utilisateur{% endblock %} @@ -32,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% csrf_token %} - {% bootstrap_form userform %} + {% bootstrap_form_typeahead userform 'room' %} {% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %}
From e619e5a31cf19e7e8d8caa95ec1767d579b30428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Fri, 13 Oct 2017 23:04:05 +0000 Subject: [PATCH 5/6] Ajout du bft tag sur le form d'edit/ajout de port sur un switch --- topologie/templates/topologie/topo.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/topologie/templates/topologie/topo.html b/topologie/templates/topologie/topo.html index fea858e4..bd07c2db 100644 --- a/topologie/templates/topologie/topo.html +++ b/topologie/templates/topologie/topo.html @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load bootstrap3 %} +{% load bootstrap_form_typeahead %} {% block title %}Création et modificationd 'utilisateur{% endblock %} @@ -32,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% csrf_token %} - {% bootstrap_form topoform %} + {% bootstrap_form_typeahead topoform 'room,related,machine_interface' %} {%bootstrap_button "Créer ou modifier" button_type="submit" icon="ok" %}
From 95c32b464e58262034d40410ffb12cf659784f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Fri, 13 Oct 2017 23:36:04 +0000 Subject: [PATCH 6/6] Fix form topologie (new stack + affichage stack) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La création réussie d'une stack redirect sur la liste des stack et ne renvoie pas sur le formulaire de création La stack s'affichae même si il n'y a aucune interface liée --- topologie/templates/topologie/aff_stacks.html | 77 ++++++++++++------- topologie/views.py | 2 + 2 files changed, 51 insertions(+), 28 deletions(-) diff --git a/topologie/templates/topologie/aff_stacks.html b/topologie/templates/topologie/aff_stacks.html index 34e7b959..586fd90a 100644 --- a/topologie/templates/topologie/aff_stacks.html +++ b/topologie/templates/topologie/aff_stacks.html @@ -30,32 +30,53 @@ with this program; if not, write to the Free Software Foundation, Inc.,
- - {% for stack in stack_list %} - {% for switch in stack.switch_set.all %} - - {% if forloop.first %} - - - - {% endif %} - - {% if forloop.first %} - - {% endif %} - - {% endfor %} - {% endfor %} + + {% for stack in stack_list %} + {% for switch in stack.switch_set.all %} + + + {% if forloop.first %} + + + + {% endif %} + + {% if forloop.first %} + + {% endif %} + + {% empty %} + + + + + + + {% endfor %} + + {% endfor %}
Details Membres
{{stack.name}}{{stack.stack_id}}{{stack.details}}{{switch}} - - - - {% if is_infra %} - - - - - - - {% endif %} -
{{stack.name}}{{stack.stack_id}}{{stack.details}}{{switch}} + + + + {% if is_infra %} + + + + + + + {% endif %} +
{{stack.name}}{{stack.stack_id}}{{stack.details}}Aucun + + + + {% if is_infra %} + + + + + + + {% endif %} +
diff --git a/topologie/views.py b/topologie/views.py index f3dedff8..9fe37d6f 100644 --- a/topologie/views.py +++ b/topologie/views.py @@ -211,6 +211,8 @@ def new_stack(request): messages.success(request, "Stack crée") except: messages.error(request, "Cette stack existe déjà") + else: + return redirect('/topologie/index_stack') return form({'topoform':stack}, 'topologie/topo.html', request)