Commit 287ce23d authored by Maël Kervella's avatar Maël Kervella

Pep8 compliance on machines

parent 0c8bb615
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
Here are defined some functions to check acl on the application. Here are defined some functions to check acl on the application.
""" """
def can_view(user): def can_view(user):
"""Check if an user can view the application. """Check if an user can view the application.
......
...@@ -104,7 +104,7 @@ class OuverturePortListAdmin(VersionAdmin): ...@@ -104,7 +104,7 @@ class OuverturePortListAdmin(VersionAdmin):
class InterfaceAdmin(VersionAdmin): class InterfaceAdmin(VersionAdmin):
list_display = ('machine','type','mac_address','ipv4','details') list_display = ('machine', 'type', 'mac_address', 'ipv4', 'details')
class DomainAdmin(VersionAdmin): class DomainAdmin(VersionAdmin):
...@@ -133,5 +133,3 @@ admin.site.register(Ipv6List, Ipv6ListAdmin) ...@@ -133,5 +133,3 @@ admin.site.register(Ipv6List, Ipv6ListAdmin)
admin.site.register(Nas, NasAdmin) admin.site.register(Nas, NasAdmin)
admin.site.register(OuverturePort, OuverturePortAdmin) admin.site.register(OuverturePort, OuverturePortAdmin)
admin.site.register(OuverturePortList, OuverturePortListAdmin) admin.site.register(OuverturePortList, OuverturePortListAdmin)
...@@ -94,7 +94,8 @@ class EditInterfaceForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): ...@@ -94,7 +94,8 @@ class EditInterfaceForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
self.fields['type'].label = 'Type de machine' self.fields['type'].label = 'Type de machine'
self.fields['type'].empty_label = "Séléctionner un type de machine" self.fields['type'].empty_label = "Séléctionner un type de machine"
if "ipv4" in self.fields: if "ipv4" in self.fields:
self.fields['ipv4'].empty_label = "Assignation automatique de l'ipv4" self.fields['ipv4'].empty_label = ("Assignation automatique de "
"l'ipv4")
self.fields['ipv4'].queryset = IpList.objects.filter( self.fields['ipv4'].queryset = IpList.objects.filter(
interface__isnull=True interface__isnull=True
) )
...@@ -328,6 +329,7 @@ class MxForm(FormRevMixin, ModelForm): ...@@ -328,6 +329,7 @@ class MxForm(FormRevMixin, ModelForm):
interface_parent=None interface_parent=None
).select_related('extension') ).select_related('extension')
class DelMxForm(FormRevMixin, Form): class DelMxForm(FormRevMixin, Form):
"""Suppression d'un ou plusieurs MX""" """Suppression d'un ou plusieurs MX"""
mx = forms.ModelMultipleChoiceField( mx = forms.ModelMultipleChoiceField(
...@@ -472,8 +474,10 @@ class ServiceForm(FormRevMixin, ModelForm): ...@@ -472,8 +474,10 @@ class ServiceForm(FormRevMixin, ModelForm):
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(ServiceForm, self).__init__(*args, prefix=prefix, **kwargs) super(ServiceForm, self).__init__(*args, prefix=prefix, **kwargs)
self.fields['servers'].queryset = Interface.objects.all()\ self.fields['servers'].queryset = (Interface.objects.all()
.select_related('domain__extension') .select_related(
'domain__extension'
))
def save(self, commit=True): def save(self, commit=True):
instance = super(ServiceForm, self).save(commit=False) instance = super(ServiceForm, self).save(commit=False)
......
This diff is collapsed.
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
# with this program; if not, write to the Free Software Foundation, Inc., # with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#Augustin Lemesle # Augustin Lemesle
from rest_framework import serializers from rest_framework import serializers
from machines.models import ( from machines.models import (
...@@ -181,7 +181,7 @@ class ExtensionSerializer(serializers.ModelSerializer): ...@@ -181,7 +181,7 @@ class ExtensionSerializer(serializers.ModelSerializer):
return str(obj.dns_entry) return str(obj.dns_entry)
def get_soa_data(self, obj): def get_soa_data(self, obj):
return { 'mail': obj.soa.dns_soa_mail, 'param': obj.soa.dns_soa_param } return {'mail': obj.soa.dns_soa_mail, 'param': obj.soa.dns_soa_param}
class MxSerializer(serializers.ModelSerializer): class MxSerializer(serializers.ModelSerializer):
...@@ -316,23 +316,23 @@ class OuverturePortsSerializer(serializers.Serializer): ...@@ -316,23 +316,23 @@ class OuverturePortsSerializer(serializers.Serializer):
ipv6 = serializers.SerializerMethodField() ipv6 = serializers.SerializerMethodField()
def get_ipv4(): def get_ipv4():
return {i.ipv4.ipv4: return {
{ i.ipv4.ipv4: {
"tcp_in":[j.tcp_ports_in() for j in i.port_lists.all()], "tcp_in": [j.tcp_ports_in() for j in i.port_lists.all()],
"tcp_out":[j.tcp_ports_out()for j in i.port_lists.all()], "tcp_out": [j.tcp_ports_out()for j in i.port_lists.all()],
"udp_in":[j.udp_ports_in() for j in i.port_lists.all()], "udp_in": [j.udp_ports_in() for j in i.port_lists.all()],
"udp_out":[j.udp_ports_out() for j in i.port_lists.all()], "udp_out": [j.udp_ports_out() for j in i.port_lists.all()],
} }
for i in Interface.objects.all() if i.ipv4 for i in Interface.objects.all() if i.ipv4
} }
def get_ipv6(): def get_ipv6():
return {i.ipv6: return {
{ i.ipv6: {
"tcp_in":[j.tcp_ports_in() for j in i.port_lists.all()], "tcp_in": [j.tcp_ports_in() for j in i.port_lists.all()],
"tcp_out":[j.tcp_ports_out()for j in i.port_lists.all()], "tcp_out": [j.tcp_ports_out()for j in i.port_lists.all()],
"udp_in":[j.udp_ports_in() for j in i.port_lists.all()], "udp_in": [j.udp_ports_in() for j in i.port_lists.all()],
"udp_out":[j.udp_ports_out() for j in i.port_lists.all()], "udp_out": [j.udp_ports_out() for j in i.port_lists.all()],
} }
for i in Interface.objects.all() if i.ipv6 for i in Interface.objects.all() if i.ipv6
} }
...@@ -28,21 +28,39 @@ import re2o ...@@ -28,21 +28,39 @@ import re2o
from . import views from . import views
urlpatterns = [ urlpatterns = [
url(r'^new_machine/(?P<userid>[0-9]+)$', views.new_machine, name='new-machine'), url(r'^new_machine/(?P<userid>[0-9]+)$',
url(r'^edit_interface/(?P<interfaceid>[0-9]+)$', views.edit_interface, name='edit-interface'), views.new_machine,
url(r'^del_machine/(?P<machineid>[0-9]+)$', views.del_machine, name='del-machine'), name='new-machine'),
url(r'^new_interface/(?P<machineid>[0-9]+)$', views.new_interface, name='new-interface'), url(r'^edit_interface/(?P<interfaceid>[0-9]+)$',
url(r'^del_interface/(?P<interfaceid>[0-9]+)$', views.del_interface, name='del-interface'), views.edit_interface,
name='edit-interface'),
url(r'^del_machine/(?P<machineid>[0-9]+)$',
views.del_machine,
name='del-machine'),
url(r'^new_interface/(?P<machineid>[0-9]+)$',
views.new_interface,
name='new-interface'),
url(r'^del_interface/(?P<interfaceid>[0-9]+)$',
views.del_interface,
name='del-interface'),
url(r'^add_machinetype/$', views.add_machinetype, name='add-machinetype'), url(r'^add_machinetype/$', views.add_machinetype, name='add-machinetype'),
url(r'^edit_machinetype/(?P<machinetypeid>[0-9]+)$', views.edit_machinetype, name='edit-machinetype'), url(r'^edit_machinetype/(?P<machinetypeid>[0-9]+)$',
views.edit_machinetype,
name='edit-machinetype'),
url(r'^del_machinetype/$', views.del_machinetype, name='del-machinetype'), url(r'^del_machinetype/$', views.del_machinetype, name='del-machinetype'),
url(r'^index_machinetype/$', views.index_machinetype, name='index-machinetype'), url(r'^index_machinetype/$',
views.index_machinetype,
name='index-machinetype'),
url(r'^add_iptype/$', views.add_iptype, name='add-iptype'), 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'^edit_iptype/(?P<iptypeid>[0-9]+)$',
views.edit_iptype,
name='edit-iptype'),
url(r'^del_iptype/$', views.del_iptype, name='del-iptype'), url(r'^del_iptype/$', views.del_iptype, name='del-iptype'),
url(r'^index_iptype/$', views.index_iptype, name='index-iptype'), url(r'^index_iptype/$', views.index_iptype, name='index-iptype'),
url(r'^add_extension/$', views.add_extension, name='add-extension'), url(r'^add_extension/$', views.add_extension, name='add-extension'),
url(r'^edit_extension/(?P<extensionid>[0-9]+)$', views.edit_extension, name='edit-extension'), url(r'^edit_extension/(?P<extensionid>[0-9]+)$',
views.edit_extension,
name='edit-extension'),
url(r'^del_extension/$', views.del_extension, name='del-extension'), url(r'^del_extension/$', views.del_extension, name='del-extension'),
url(r'^add_soa/$', views.add_soa, name='add-soa'), url(r'^add_soa/$', views.add_soa, name='add-soa'),
url(r'^edit_soa/(?P<soaid>[0-9]+)$', views.edit_soa, name='edit-soa'), url(r'^edit_soa/(?P<soaid>[0-9]+)$', views.edit_soa, name='edit-soa'),
...@@ -60,16 +78,34 @@ urlpatterns = [ ...@@ -60,16 +78,34 @@ urlpatterns = [
url(r'^edit_srv/(?P<srvid>[0-9]+)$', views.edit_srv, name='edit-srv'), url(r'^edit_srv/(?P<srvid>[0-9]+)$', views.edit_srv, name='edit-srv'),
url(r'^del_srv/$', views.del_srv, name='del-srv'), url(r'^del_srv/$', views.del_srv, name='del-srv'),
url(r'^index_extension/$', views.index_extension, name='index-extension'), url(r'^index_extension/$', views.index_extension, name='index-extension'),
url(r'^add_alias/(?P<interfaceid>[0-9]+)$', views.add_alias, name='add-alias'), url(r'^add_alias/(?P<interfaceid>[0-9]+)$',
url(r'^edit_alias/(?P<domainid>[0-9]+)$', views.edit_alias, name='edit-alias'), views.add_alias,
url(r'^del_alias/(?P<interfaceid>[0-9]+)$', views.del_alias, name='del-alias'), name='add-alias'),
url(r'^index_alias/(?P<interfaceid>[0-9]+)$', views.index_alias, name='index-alias'), url(r'^edit_alias/(?P<domainid>[0-9]+)$',
url(r'^new_ipv6list/(?P<interfaceid>[0-9]+)$', views.new_ipv6list, name='new-ipv6list'), views.edit_alias,
url(r'^edit_ipv6list/(?P<ipv6listid>[0-9]+)$', views.edit_ipv6list, name='edit-ipv6list'), name='edit-alias'),
url(r'^del_ipv6list/(?P<ipv6listid>[0-9]+)$', views.del_ipv6list, name='del-ipv6list'), url(r'^del_alias/(?P<interfaceid>[0-9]+)$',
url(r'^index_ipv6/(?P<interfaceid>[0-9]+)$', views.index_ipv6, name='index-ipv6'), views.del_alias,
name='del-alias'),
url(r'^index_alias/(?P<interfaceid>[0-9]+)$',
views.index_alias,
name='index-alias'),
url(r'^new_ipv6list/(?P<interfaceid>[0-9]+)$',
views.new_ipv6list,
name='new-ipv6list'),
url(r'^edit_ipv6list/(?P<ipv6listid>[0-9]+)$',
views.edit_ipv6list,
name='edit-ipv6list'),
url(r'^del_ipv6list/(?P<ipv6listid>[0-9]+)$',
views.del_ipv6list,
name='del-ipv6list'),
url(r'^index_ipv6/(?P<interfaceid>[0-9]+)$',
views.index_ipv6,
name='index-ipv6'),
url(r'^add_service/$', views.add_service, name='add-service'), url(r'^add_service/$', views.add_service, name='add-service'),
url(r'^edit_service/(?P<serviceid>[0-9]+)$', views.edit_service, name='edit-service'), url(r'^edit_service/(?P<serviceid>[0-9]+)$',
views.edit_service,
name='edit-service'),
url(r'^del_service/$', views.del_service, name='del-service'), url(r'^del_service/$', views.del_service, name='del-service'),
url(r'^index_service/$', views.index_service, name='index-service'), url(r'^index_service/$', views.index_service, name='index-service'),
url(r'^add_vlan/$', views.add_vlan, name='add-vlan'), url(r'^add_vlan/$', views.add_vlan, name='add-vlan'),
...@@ -80,15 +116,15 @@ urlpatterns = [ ...@@ -80,15 +116,15 @@ urlpatterns = [
url(r'^edit_nas/(?P<nasid>[0-9]+)$', views.edit_nas, name='edit-nas'), url(r'^edit_nas/(?P<nasid>[0-9]+)$', views.edit_nas, name='edit-nas'),
url(r'^del_nas/$', views.del_nas, name='del-nas'), url(r'^del_nas/$', views.del_nas, name='del-nas'),
url(r'^index_nas/$', views.index_nas, name='index-nas'), url(r'^index_nas/$', views.index_nas, name='index-nas'),
url( url(r'history/(?P<object_name>\w+)/(?P<object_id>[0-9]+)$',
r'history/(?P<object_name>\w+)/(?P<object_id>[0-9]+)$',
re2o.views.history, re2o.views.history,
name='history', name='history',
kwargs={'application':'machines'}, kwargs={'application': 'machines'}),
),
url(r'^$', views.index, name='index'), url(r'^$', views.index, name='index'),
url(r'^rest/mac-ip/$', views.mac_ip, name='mac-ip'), url(r'^rest/mac-ip/$', views.mac_ip, name='mac-ip'),
url(r'^rest/regen-achieved/$', views.regen_achieved, name='regen-achieved'), url(r'^rest/regen-achieved/$',
views.regen_achieved,
name='regen-achieved'),
url(r'^rest/mac-ip-dns/$', views.mac_ip_dns, name='mac-ip-dns'), url(r'^rest/mac-ip-dns/$', views.mac_ip_dns, name='mac-ip-dns'),
url(r'^rest/alias/$', views.alias, name='alias'), url(r'^rest/alias/$', views.alias, name='alias'),
url(r'^rest/corresp/$', views.corresp, name='corresp'), url(r'^rest/corresp/$', views.corresp, name='corresp'),
...@@ -97,12 +133,21 @@ urlpatterns = [ ...@@ -97,12 +133,21 @@ urlpatterns = [
url(r'^rest/txt/$', views.txt, name='txt'), url(r'^rest/txt/$', views.txt, name='txt'),
url(r'^rest/srv/$', views.srv, name='srv'), url(r'^rest/srv/$', views.srv, name='srv'),
url(r'^rest/zones/$', views.zones, name='zones'), url(r'^rest/zones/$', views.zones, name='zones'),
url(r'^rest/service_servers/$', views.service_servers, name='service-servers'), url(r'^rest/service_servers/$',
url(r'^rest/ouverture_ports/$', views.ouverture_ports, name='ouverture-ports'), views.service_servers,
name='service-servers'),
url(r'^rest/ouverture_ports/$',
views.ouverture_ports,
name='ouverture-ports'),
url(r'index_portlist/$', views.index_portlist, name='index-portlist'), url(r'index_portlist/$', views.index_portlist, name='index-portlist'),
url(r'^edit_portlist/(?P<ouvertureportlistid>[0-9]+)$', views.edit_portlist, name='edit-portlist'), url(r'^edit_portlist/(?P<ouvertureportlistid>[0-9]+)$',
url(r'^del_portlist/(?P<ouvertureportlistid>[0-9]+)$', views.del_portlist, name='del-portlist'), views.edit_portlist,
name='edit-portlist'),
url(r'^del_portlist/(?P<ouvertureportlistid>[0-9]+)$',
views.del_portlist,
name='del-portlist'),
url(r'^add_portlist/$', views.add_portlist, name='add-portlist'), url(r'^add_portlist/$', views.add_portlist, name='add-portlist'),
url(r'^port_config/(?P<interfaceid>[0-9]+)$', views.configure_ports, name='port-config'), url(r'^port_config/(?P<interfaceid>[0-9]+)$',
views.configure_ports,
] name='port-config'),
]
This diff is collapsed.
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