8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-23 03:43:12 +00:00

Renome enregistrement Text en enregistrement Txt

Parce que ça s'appelle comme ça
Faudra aussi bouger dans la bdd mais là c'est plus délicat (migrations)
This commit is contained in:
Maël Kervella 2017-10-11 21:33:21 +00:00
parent ee1dab9642
commit 5eaaa41bc4
5 changed files with 42 additions and 42 deletions

View file

@ -210,17 +210,17 @@ class NsForm(ModelForm):
class DelNsForm(Form): class DelNsForm(Form):
ns = forms.ModelMultipleChoiceField(queryset=Ns.objects.all(), label="Enregistrements NS actuels", widget=forms.CheckboxSelectMultiple) ns = forms.ModelMultipleChoiceField(queryset=Ns.objects.all(), label="Enregistrements NS actuels", widget=forms.CheckboxSelectMultiple)
class TextForm(ModelForm): class TxtForm(ModelForm):
class Meta: class Meta:
model = Text model = Text
fields = '__all__' fields = '__all__'
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
prefix = kwargs.pop('prefix', self.Meta.model.__name__) 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): class DelTxtForm(Form):
text = forms.ModelMultipleChoiceField(queryset=Text.objects.all(), label="Enregistrements Text actuels", widget=forms.CheckboxSelectMultiple) txt = forms.ModelMultipleChoiceField(queryset=Text.objects.all(), label="Enregistrements Txt actuels", widget=forms.CheckboxSelectMultiple)
class NasForm(ModelForm): class NasForm(ModelForm):
class Meta: class Meta:

View file

@ -31,15 +31,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
{% for text in text_list %} {% for txt in txt_list %}
<tr> <tr>
<td>{{ text.zone }}</td> <td>{{ txt.zone }}</td>
<td>{{ text.dns_entry }}</td> <td>{{ txt.dns_entry }}</td>
<td class="text-right"> <td class="text-right">
{% if is_infra %} {% 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 %} {% 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 %}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}

View file

@ -47,12 +47,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-ns' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un enregistrement NS</a> <a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-ns' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un enregistrement NS</a>
{% endif %} {% endif %}
{% include "machines/aff_ns.html" with ns_list=ns_list %} {% include "machines/aff_ns.html" with ns_list=ns_list %}
<h2>Liste des enregistrements Text</h2> <h2>Liste des enregistrements TXT</h2>
{% if is_infra %} {% if is_infra %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-text' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un enregistrement TXT</a> <a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-txt' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un enregistrement TXT</a>
<a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-text' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un enregistrement TXT</a> <a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-txt' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un enregistrement TXT</a>
{% endif %} {% endif %}
{% include "machines/aff_text.html" with text_list=text_list %} {% include "machines/aff_txt.html" with txt_list=txt_list %}
<br /> <br />
<br /> <br />
<br /> <br />

View file

@ -47,9 +47,9 @@ urlpatterns = [
url(r'^add_mx/$', views.add_mx, name='add-mx'), url(r'^add_mx/$', views.add_mx, name='add-mx'),
url(r'^edit_mx/(?P<mxid>[0-9]+)$', views.edit_mx, name='edit-mx'), url(r'^edit_mx/(?P<mxid>[0-9]+)$', views.edit_mx, name='edit-mx'),
url(r'^del_mx/$', views.del_mx, name='del-mx'), url(r'^del_mx/$', views.del_mx, name='del-mx'),
url(r'^add_text/$', views.add_text, name='add-text'), url(r'^add_txt/$', views.add_txt, name='add-txt'),
url(r'^edit_text/(?P<textid>[0-9]+)$', views.edit_text, name='edit-text'), url(r'^edit_txt/(?P<textid>[0-9]+)$', views.edit_txt, name='edit-txt'),
url(r'^del_text/$', views.del_text, name='del-text'), url(r'^del_txt/$', views.del_txt, name='del-txt'),
url(r'^add_ns/$', views.add_ns, name='add-ns'), url(r'^add_ns/$', views.add_ns, name='add-ns'),
url(r'^edit_ns/(?P<nsid>[0-9]+)$', views.edit_ns, name='edit-ns'), url(r'^edit_ns/(?P<nsid>[0-9]+)$', views.edit_ns, name='edit-ns'),
url(r'^del_ns/$', views.del_ns, name='del-ns'), url(r'^del_ns/$', views.del_ns, name='del-ns'),
@ -76,7 +76,7 @@ urlpatterns = [
url(r'^history/(?P<object>extension)/(?P<id>[0-9]+)$', views.history, name='history'), url(r'^history/(?P<object>extension)/(?P<id>[0-9]+)$', views.history, name='history'),
url(r'^history/(?P<object>mx)/(?P<id>[0-9]+)$', views.history, name='history'), url(r'^history/(?P<object>mx)/(?P<id>[0-9]+)$', views.history, name='history'),
url(r'^history/(?P<object>ns)/(?P<id>[0-9]+)$', views.history, name='history'), url(r'^history/(?P<object>ns)/(?P<id>[0-9]+)$', views.history, name='history'),
url(r'^history/(?P<object>text)/(?P<id>[0-9]+)$', views.history, name='history'), url(r'^history/(?P<object>txt)/(?P<id>[0-9]+)$', views.history, name='history'),
url(r'^history/(?P<object>iptype)/(?P<id>[0-9]+)$', views.history, name='history'), url(r'^history/(?P<object>iptype)/(?P<id>[0-9]+)$', views.history, name='history'),
url(r'^history/(?P<object>alias)/(?P<id>[0-9]+)$', views.history, name='history'), url(r'^history/(?P<object>alias)/(?P<id>[0-9]+)$', views.history, name='history'),
url(r'^history/(?P<object>vlan)/(?P<id>[0-9]+)$', views.history, name='history'), url(r'^history/(?P<object>vlan)/(?P<id>[0-9]+)$', views.history, name='history'),

View file

@ -49,7 +49,7 @@ from reversion.models import Version
import re import re
from .forms import NewMachineForm, EditMachineForm, EditInterfaceForm, AddInterfaceForm, MachineTypeForm, DelMachineTypeForm, ExtensionForm, DelExtensionForm, BaseEditInterfaceForm, BaseEditMachineForm 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 .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 .models import IpType, Machine, Interface, IpList, MachineType, Extension, Mx, Ns, Domain, Service, Service_link, Vlan, Nas, Text, OuverturePortList, OuverturePort
from users.models import User from users.models import User
@ -573,11 +573,11 @@ def del_ns(request):
@login_required @login_required
@permission_required('infra') @permission_required('infra')
def add_text(request): def add_txt(request):
text = TextForm(request.POST or None) txt = TxtForm(request.POST or None)
if text.is_valid(): if txt.is_valid():
with transaction.atomic(), reversion.create_revision(): with transaction.atomic(), reversion.create_revision():
text.save() txt.save()
reversion.set_user(request.user) reversion.set_user(request.user)
reversion.set_comment("Création") reversion.set_comment("Création")
messages.success(request, "Cet enregistrement text a été ajouté") messages.success(request, "Cet enregistrement text a été ajouté")
@ -586,36 +586,36 @@ def add_text(request):
@login_required @login_required
@permission_required('infra') @permission_required('infra')
def edit_text(request, textid): def edit_txt(request, txtid):
try: try:
text_instance = Text.objects.get(pk=textid) txt_instance = Text.objects.get(pk=txtid)
except Text.DoesNotExist: except Text.DoesNotExist:
messages.error(request, u"Entrée inexistante" ) messages.error(request, u"Entrée inexistante" )
return redirect("/machines/index_extension/") return redirect("/machines/index_extension/")
text = TextForm(request.POST or None, instance=text_instance) txt = TxtForm(request.POST or None, instance=txt_instance)
if text.is_valid(): if txt.is_valid():
with transaction.atomic(), reversion.create_revision(): with transaction.atomic(), reversion.create_revision():
text.save() txt.save()
reversion.set_user(request.user) reversion.set_user(request.user)
reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in text.changed_data)) reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in txt.changed_data))
messages.success(request, "Text modifié") messages.success(request, "Txt modifié")
return redirect("/machines/index_extension/") return redirect("/machines/index_extension/")
return form({'machineform': text}, 'machines/machine.html', request) return form({'machineform': text}, 'machines/machine.html', request)
@login_required @login_required
@permission_required('infra') @permission_required('infra')
def del_text(request): def del_txt(request):
text = DelTextForm(request.POST or None) txt = DelTxtForm(request.POST or None)
if text.is_valid(): if txt.is_valid():
text_dels = text.cleaned_data['text'] txt_dels = txt.cleaned_data['txt']
for text_del in text_dels: for txt_del in txt_dels:
try: try:
with transaction.atomic(), reversion.create_revision(): with transaction.atomic(), reversion.create_revision():
text_del.delete() txt_del.delete()
reversion.set_user(request.user) reversion.set_user(request.user)
messages.success(request, "Le text a été supprimé") messages.success(request, "Le txt a été supprimé")
except ProtectedError: 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 redirect("/machines/index_extension")
return form({'machineform': text, 'interfaceform': None}, 'machines/machine.html', request) return form({'machineform': text, 'interfaceform': None}, 'machines/machine.html', request)
@ -960,11 +960,11 @@ def history(request, object, id):
except Mx.DoesNotExist: except Mx.DoesNotExist:
messages.error(request, "Mx inexistant") messages.error(request, "Mx inexistant")
return redirect("/machines/") return redirect("/machines/")
elif object == 'text' and request.user.has_perms(('cableur',)): elif object == 'txt' and request.user.has_perms(('cableur',)):
try: try:
object_instance = Text.objects.get(pk=id) object_instance = Text.objects.get(pk=id)
except Text.DoesNotExist: except Text.DoesNotExist:
messages.error(request, "Text inexistant") messages.error(request, "Txt inexistant")
return redirect("/machines/") return redirect("/machines/")
elif object == 'ns' and request.user.has_perms(('cableur',)): elif object == 'ns' and request.user.has_perms(('cableur',)):
try: try: