8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-22 19:33:11 +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 6bd33bf415
commit a31f0b0785
5 changed files with 42 additions and 42 deletions

View file

@ -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:

View file

@ -25,21 +25,21 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<table class="table table-striped">
<thead>
<tr>
<th>Zone concernée</th>
<th>Enregistrement</th>
<th></th>
<th>Zone concernée</th>
<th>Enregistrement</th>
<th></th>
<th></th>
</tr>
</thead>
{% for text in text_list %}
{% for txt in txt_list %}
<tr>
<td>{{ text.zone }}</td>
<td>{{ text.dns_entry }}</td>
<td>{{ txt.zone }}</td>
<td>{{ txt.dns_entry }}</td>
<td class="text-right">
{% 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 %}
</td>
</tr>
{% 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>
{% endif %}
{% 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 %}
<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-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-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-txt' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un enregistrement TXT</a>
{% endif %}
{% include "machines/aff_text.html" with text_list=text_list %}
{% include "machines/aff_txt.html" with txt_list=txt_list %}
<br />
<br />
<br />

View file

@ -47,9 +47,9 @@ urlpatterns = [
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'^del_mx/$', views.del_mx, name='del-mx'),
url(r'^add_text/$', views.add_text, name='add-text'),
url(r'^edit_text/(?P<textid>[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<textid>[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<nsid>[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/(?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>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>alias)/(?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
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: