Verified Commit f666aec2 authored by erdnaxe's avatar erdnaxe 🎇

Remove IpType edit

parent 3e7bfcb7
Pipeline #1114 passed with stage
in 2 minutes and 57 seconds
......@@ -50,6 +50,7 @@ class IpTypeAdmin(VersionAdmin):
'name', 'extension', 'need_infra', 'prefix_v6', 'vlan',
'ouverture_ports')
list_filter = ('need_infra',)
# TODO(erdnaxe): block range edit after creation
@admin.register(MachineType)
......
......@@ -159,48 +159,6 @@ class DelAliasForm(FormRevMixin, Form):
)
class IpTypeForm(FormRevMixin, ModelForm):
"""Formulaire d'ajout d'un iptype. Pas d'edition de l'ip de start et de
stop après creation"""
class Meta:
model = IpType
fields = '__all__'
def __init__(self, *args, **kwargs):
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
super(IpTypeForm, self).__init__(*args, prefix=prefix, **kwargs)
self.fields['name'].label = _("IP type to add")
class EditIpTypeForm(IpTypeForm):
"""Edition d'un iptype. Pas d'edition du rangev4 possible, car il faudrait
synchroniser les objets iplist"""
class Meta(IpTypeForm.Meta):
fields = ['extension', 'name', 'need_infra', 'domaine_ip_network', 'domaine_ip_netmask',
'prefix_v6', 'prefix_v6_length',
'vlan', 'reverse_v4', 'reverse_v6',
'ouverture_ports']
class DelIpTypeForm(FormRevMixin, Form):
"""Suppression d'un ou plusieurs iptype"""
iptypes = forms.ModelMultipleChoiceField(
queryset=IpType.objects.none(),
label=_("Current IP types"),
widget=forms.CheckboxSelectMultiple
)
def __init__(self, *args, **kwargs):
instances = kwargs.pop('instances', None)
super(DelIpTypeForm, self).__init__(*args, **kwargs)
if instances:
self.fields['iptypes'].queryset = instances
else:
self.fields['iptypes'].queryset = IpType.objects.all()
class Ipv6ListForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
"""Gestion des ipv6 d'une machine"""
......
......@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 2.5\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-04-13 08:16+0200\n"
"POT-Creation-Date: 2019-04-13 08:40+0200\n"
"PO-Revision-Date: 2018-06-23 16:35+0200\n"
"Last-Translator: Laouen Fernet <laouen.fernet@supelec.fr>\n"
"Language-Team: \n"
......@@ -43,15 +43,7 @@ msgstr "Assignation automatique IPv4"
msgid "Current aliases"
msgstr "Alias actuels"
#: machines/forms.py:173
msgid "IP type to add"
msgstr "Type d'IP à ajouter"
#: machines/forms.py:191
msgid "Current IP types"
msgstr "Types d'IP actuels"
#: machines/forms.py:245
#: machines/forms.py:203
msgid "Current services"
msgstr "Services actuels"
......@@ -959,7 +951,7 @@ msgstr "Voir le profil"
msgid "Deactivated"
msgstr "Désactivée"
#: machines/templates/machines/aff_machines.html:67 machines/views.py:325
#: machines/templates/machines/aff_machines.html:67 machines/views.py:322
msgid "Create an interface"
msgstr "Créer une interface"
......@@ -1083,14 +1075,6 @@ msgstr " Supprimer un ou plusieurs alias"
msgid "List of IP types"
msgstr "Liste des types d'IP"
#: machines/templates/machines/index_iptype.html:36
msgid " Add an IP type"
msgstr " Ajouter un type d'IP"
#: machines/templates/machines/index_iptype.html:40
msgid " Delete one or several IP types"
msgstr " Supprimer un ou plusieurs types d'IP"
#: machines/templates/machines/index_ipv6.html:33
msgid "List of the IPv6 addresses of the interface"
msgstr "Liste des adresses IPv6 de l'interface"
......@@ -1183,152 +1167,128 @@ msgstr "Services (DHCP, DNS, ...)"
msgid "Ports openings"
msgstr "Ouvertures de ports"
#: machines/views.py:106
#: machines/views.py:103
msgid "Select a machine type first."
msgstr "Sélectionnez un type de machine d'abord."
#: machines/views.py:208
#: machines/views.py:205
msgid "The machine was created."
msgstr "La machine a été créée."
#: machines/views.py:220
#: machines/views.py:217
msgid "Create a machine"
msgstr "Créer une machine"
#: machines/views.py:260
#: machines/views.py:257
msgid "The machine was edited."
msgstr "La machine a été modifiée."
#: machines/views.py:272 machines/views.py:396 machines/views.py:462
#: machines/views.py:518 machines/views.py:591 machines/views.py:654
#: machines/views.py:269 machines/views.py:393 machines/views.py:459
#: machines/views.py:526 machines/views.py:589
msgid "Edit"
msgstr "Modifier"
#: machines/views.py:285
#: machines/views.py:282
msgid "The machine was deleted."
msgstr "La machine a été supprimée."
#: machines/views.py:314
#: machines/views.py:311
msgid "The interface was created."
msgstr "L'interface a été créée."
#: machines/views.py:341
#: machines/views.py:338
msgid "The interface was deleted."
msgstr "L'interface a été supprimée."
#: machines/views.py:366
#: machines/views.py:363
msgid "The IPv6 addresses list was created."
msgstr "La liste d'adresses IPv6 a été créée."
#: machines/views.py:372
#: machines/views.py:369
msgid "Create an IPv6 addresses list"
msgstr "Créer une liste d'adresses IPv6"
#: machines/views.py:390
#: machines/views.py:387
msgid "The IPv6 addresses list was edited."
msgstr "La liste d'adresses IPv6 a été modifiée."
#: machines/views.py:409
#: machines/views.py:406
msgid "The IPv6 addresses list was deleted."
msgstr "La liste d'adresses IPv6 a été supprimée."
#: machines/views.py:433
#: machines/views.py:430
msgid "The SSHFP record was created."
msgstr "L'enregistrement SSHFP a été créé."
#: machines/views.py:439
#: machines/views.py:436
msgid "Create a SSHFP record"
msgstr "Créer un enregistrement SSHFP"
#: machines/views.py:456
#: machines/views.py:453
msgid "The SSHFP record was edited."
msgstr "L'enregistrement SSHFP a été modifié."
#: machines/views.py:475
#: machines/views.py:472
msgid "The SSHFP record was deleted."
msgstr "L'enregistrement SSHFP a été supprimé."
#: machines/views.py:496
msgid "The IP type was created."
msgstr "Le type d'IP a été créé."
#: machines/views.py:499
msgid "Create an IP type"
msgstr "Créer un type d'IP"
#: machines/views.py:515
msgid "The IP type was edited."
msgstr "Le type d'IP a été modifié."
#: machines/views.py:534
msgid "The IP type was deleted."
msgstr "Le type d'IP a été supprimé."
#: machines/views.py:538
#, python-format
msgid ""
"The IP type %s is assigned to at least one machine, you can't delete it."
msgstr ""
"Le type d'IP %s est assigné à au moins une machine, vous ne pouvez pas le "
"supprimer."
#: machines/views.py:543 machines/views.py:621 machines/views.py:678
msgid "Delete"
msgstr "Supprimer"
#: machines/views.py:559
#: machines/views.py:494
msgid "The alias was created."
msgstr "L'alias a été créé."
#: machines/views.py:565
#: machines/views.py:500
msgid "Create an alias"
msgstr "Créer un alias"
#: machines/views.py:583
#: machines/views.py:518
msgid "The alias was edited."
msgstr "L'alias a été modifié."
#: machines/views.py:609
#: machines/views.py:544
#, python-format
msgid "The alias %s was deleted."
msgstr "L'alias %s a été supprimé."
#: machines/views.py:614
#: machines/views.py:549
#, python-format
msgid "Error: the alias %s can't be deleted."
msgstr "Erreur : l'alias %s ne peut pas être supprimé."
#: machines/views.py:634
#: machines/views.py:556 machines/views.py:613
msgid "Delete"
msgstr "Supprimer"
#: machines/views.py:569
msgid "The service was created."
msgstr "Le service a été créé."
#: machines/views.py:637
#: machines/views.py:572
msgid "Create a service"
msgstr "Créer un service"
#: machines/views.py:651
#: machines/views.py:586
msgid "The service was edited."
msgstr "Le service a été modifié."
#: machines/views.py:670
#: machines/views.py:605
msgid "The service was deleted."
msgstr "Le service a été supprimé."
#: machines/views.py:674
#: machines/views.py:609
#, python-format
msgid "Error: the service %s can't be deleted."
msgstr "Erreur : le service %s ne peut pas être supprimé."
#: machines/views.py:825
#: machines/views.py:760
msgid "Warning: the IPv4 isn't public, the opening won't have effect in v4."
msgstr ""
"Attention : l'adresse IPv4 n'est pas publique, l'ouverture n'aura pas "
"d'effet en v4."
#: machines/views.py:835
#: machines/views.py:770
msgid "The ports configuration was edited."
msgstr "La configuration de ports a été modifiée."
#: machines/views.py:838
#: machines/views.py:773
msgid "Edit the configuration"
msgstr "Modifier la configuration"
......@@ -40,7 +40,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<th>{% trans "DNSSEC reverse v4/v6" %}</th>
<th>{% trans "On VLAN(s)" %}</th>
<th>{% trans "Default ports opening" %}</th>
<th></th>
</tr>
</thead>
{% for type in iptype_list %}
......@@ -54,12 +53,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ type.reverse_v4|tick }}/{{ type.reverse_v6|tick }}</td>
<td>{{ type.vlan }}</td>
<td>{{ type.ouverture_ports }}</td>
<td class="text-right">
{% can_edit type %}
{% include 'buttons/edit.html' with href='machines:edit-iptype' id=type.id %}
{% acl_end %}
{% history_button type %}
</td>
</tr>
{% endfor %}
</table>
......
......@@ -31,13 +31,5 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% block content %}
<h2>{% trans "List of IP types" %}</h2>
{% can_create IpType %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-iptype' %}">
<i class="fa fa-plus"></i>{% trans " Add an IP type" %}
</a>
{% acl_end %}
<a class="btn btn-danger btn-sm" role="button" href="{% url 'machines:del-iptype' %}">
<i class="fa fa-trash"></i>{% trans " Delete one or several IP types" %}
</a>
{% include 'machines/aff_iptype.html' with iptype_list=iptype_list %}
{% endblock %}
......@@ -31,11 +31,6 @@ urlpatterns = [
url(r'^del_interface/(?P<interfaceid>[0-9]+)$',
views.del_interface,
name='del-interface'),
url(r'^add_iptype/$', views.add_iptype, name='add-iptype'),
url(r'^edit_iptype/(?P<iptypeid>[0-9]+)$',
views.edit_iptype,
name='edit-iptype'),
url(r'^del_iptype/$', views.del_iptype, name='del-iptype'),
url(r'^index_iptype/$', views.index_iptype, name='index-iptype'),
url(r'^new_sshfp/(?P<machineid>[0-9]+)$',
views.new_sshfp,
......
......@@ -47,9 +47,6 @@ from .forms import (
EditMachineForm,
EditInterfaceForm,
AddInterfaceForm,
EditIpTypeForm,
IpTypeForm,
DelIpTypeForm,
DomainForm,
AliasForm,
DelAliasForm,
......@@ -484,68 +481,6 @@ def del_sshfp(request, sshfp, **_kwargs):
)
@login_required
@can_create(IpType)
def add_iptype(request):
""" Ajoute un range d'ip. Intelligence dans le models, fonction views
minimaliste"""
iptype = IpTypeForm(request.POST or None)
if iptype.is_valid():
iptype.save()
messages.success(request, _("The IP type was created."))
return redirect(reverse('machines:index-iptype'))
return form(
{'iptypeform': iptype, 'action_name': _("Create an IP type")},
'machines/machine.html',
request
)
@login_required
@can_edit(IpType)
def edit_iptype(request, iptype_instance, **_kwargs):
""" Edition d'un range. Ne permet pas de le redimensionner pour éviter
l'incohérence"""
iptype = EditIpTypeForm(request.POST or None, instance=iptype_instance)
if iptype.is_valid():
if iptype.changed_data:
iptype.save()
messages.success(request, _("The IP type was edited."))
return redirect(reverse('machines:index-iptype'))
return form(
{'iptypeform': iptype, 'action_name': _("Edit")},
'machines/machine.html',
request
)
@login_required
@can_delete_set(IpType)
def del_iptype(request, instances):
""" Suppression d'un range ip. Supprime les objets ip associés"""
iptype = DelIpTypeForm(request.POST or None, instances=instances)
if iptype.is_valid():
iptype_dels = iptype.cleaned_data['iptypes']
for iptype_del in iptype_dels:
try:
iptype_del.delete()
messages.success(request, _("The IP type was deleted."))
except ProtectedError:
messages.error(
request,
(_("The IP type %s is assigned to at least one machine,"
" you can't delete it.") % iptype_del)
)
return redirect(reverse('machines:index-iptype'))
return form(
{'iptypeform': iptype, 'action_name': _("Delete")},
'machines/machine.html',
request
)
@login_required
@can_create(Domain)
@can_edit(Interface)
......
......@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 2.5\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-04-12 19:09+0200\n"
"POT-Creation-Date: 2019-04-13 08:40+0200\n"
"PO-Revision-Date: 2018-03-31 16:09+0002\n"
"Last-Translator: Laouen Fernet <laouen.fernet@supelec.fr>\n"
"Language-Team: \n"
......@@ -57,11 +57,11 @@ msgid ""
"\">this form</a>."
msgstr ""
#: templates/admin/base_site.html:63 templates/base.html:275
#: templates/admin/base_site.html:64 templates/base.html:269
msgid "powered by"
msgstr "propulsé par"
#: templates/admin/base_site.html:65 templates/base.html:283
#: templates/admin/base_site.html:68 templates/base.html:273
msgid ""
"This software is under the terms of the <a href=\"http://www.gnu.org/"
"licenses/gpl-2.0.txt\" target=\"_blank\" rel=\"nofollow\">GPLv2</a> License."
......@@ -197,71 +197,59 @@ msgstr "Mon profil"
msgid "Log out"
msgstr "Se déconnecter"
#: templates/base.html:208
#: templates/base.html:205
msgid "Username"
msgstr "Pseudo"
#: templates/base.html:212
#: templates/base.html:209
msgid "Room"
msgstr "Chambre"
#: templates/base.html:216
#: templates/base.html:213
msgid "Internet access"
msgstr "Accès Internet"
#: templates/base.html:219
#: templates/base.html:216
#, python-format
msgid "Until %(end_access_date)s"
msgstr "Jusqu'au %(end_access_date)s"
#: templates/base.html:221
#: templates/base.html:218
msgid "Disabled"
msgstr "Désactivé"
#: templates/base.html:226
#: templates/base.html:223
msgid "Membership"
msgstr "Adhésion"
#: templates/base.html:229
#: templates/base.html:226
#, python-format
msgid "Until %(end_adhesion_date)s"
msgstr "Jusqu'au %(end_adhesion_date)s"
#: templates/base.html:231
#: templates/base.html:228
msgid "Non member"
msgstr "Non adhérent"
#: templates/base.html:239
#: templates/base.html:236
msgid "View my profile"
msgstr "Voir mon profil"
#: templates/base.html:244
#: templates/base.html:241
msgid "You are not logged in."
msgstr "Vous n'êtes pas connecté."
#: templates/base.html:251
#: templates/base.html:248
#, python-format
msgid "%(nb)s active machine"
msgid_plural "%(nb)s active machines"
msgstr[0] "%(nb)s machine active"
msgstr[1] "%(nb)s machines actives"
#: templates/base.html:260
#: templates/base.html:257
msgid "View my machines"
msgstr "Voir mes machines"
#: templates/base.html:273
msgid "Back to top"
msgstr "Retour en haut"
#: templates/base.html:277
msgid "Brought to you with <i class=\"fa fa-heart text-danger\"></i>."
msgstr "Codé avec <i class=\"fa fa-heart text-danger\"></i>."
#: templates/base.html:280
msgid "About this website"
msgstr "À propos de ce site"
#: templates/buttons/add.html:27
msgid "Add"
msgstr "Ajouter"
......@@ -274,10 +262,6 @@ msgstr "Modifier"
msgid "History"
msgstr "Historique"
#: templates/buttons/setlang.html:34
msgid "Translation in development"
msgstr "Traduction en développement"
#: templates/buttons/sort.html:35
msgid "Ascending sort"
msgstr "Tri croissant"
......@@ -450,3 +434,15 @@ msgstr ""
#, python-format
msgid "The %(site_name)s team"
msgstr ""
#~ msgid "Back to top"
#~ msgstr "Retour en haut"
#~ msgid "Brought to you with <i class=\"fa fa-heart text-danger\"></i>."
#~ msgstr "Codé avec <i class=\"fa fa-heart text-danger\"></i>."
#~ msgid "About this website"
#~ msgstr "À propos de ce site"
#~ msgid "Translation in development"
#~ msgstr "Traduction en développement"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment