Commit 224cf27c by Barnabás Czémán

fix flake8 warnings

parent 0f41633d
Pipeline #641 failed with stage
in 0 seconds
......@@ -65,6 +65,7 @@ class GroupSerializer(serializers.HyperlinkedModelSerializer):
return ''
return obj.owner.get_full_name()
class HostSerializer(serializers.HyperlinkedModelSerializer):
owner_name = serializers.SerializerMethodField()
vlan_name = serializers.SerializerMethodField()
......@@ -123,7 +124,10 @@ class SwitchPortSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.SwitchPort
fields = ("url", "untagged_vlan", "tagged_vlans", "description", "untagged_vlan_info", "tagged_vlans_name")
fields = (
"url", "untagged_vlan", "tagged_vlans", "description",
"untagged_vlan_info", "tagged_vlans_name"
)
def get_untagged_vlan_info(self, obj):
return '{}'.format(obj.untagged_vlan)
......@@ -131,6 +135,7 @@ class SwitchPortSerializer(serializers.HyperlinkedModelSerializer):
def get_tagged_vlans_name(self, obj):
return obj.tagged_vlans.name
class VlanSerializer(serializers.HyperlinkedModelSerializer):
domain_name = serializers.SerializerMethodField()
......@@ -150,6 +155,7 @@ class VlanSerializer(serializers.HyperlinkedModelSerializer):
class VlanGroupSerializer(serializers.HyperlinkedModelSerializer):
owner_name = serializers.SerializerMethodField()
class Meta:
model = models.VlanGroup
fields = ("url", "name", "vlans", "description", "owner", "owner_name")
......
......@@ -61,14 +61,17 @@ urlpatterns = [
url('^groups/$', views.GroupList.as_view(), name='network.group_list'),
url('^groups/create$', views.GroupCreate.as_view(),
name='network.group_create'),
url('^groups/(?P<pk>\d+)/$', views.GroupDetail.as_view(), name='network.group'),
url('^groups/(?P<pk>\d+)/$', views.GroupDetail.as_view(),
name='network.group'),
url('^groups/delete/(?P<pk>\d+)/$', views.GroupDelete.as_view(),
name="network.group_delete"),
# host
url('^hosts/$', views.HostList.as_view(), name='network.host_list'),
url('^hosts/create$', views.HostCreate.as_view(), name='network.host_create'),
url('^hosts/(?P<pk>\d+)/$', views.HostDetail.as_view(), name='network.host'),
url('^hosts/create$', views.HostCreate.as_view(),
name='network.host_create'),
url('^hosts/(?P<pk>\d+)/$', views.HostDetail.as_view(),
name='network.host'),
url('^hosts/delete/(?P<pk>\d+)/$', views.HostDelete.as_view(),
name="network.host_delete"),
......@@ -83,7 +86,8 @@ urlpatterns = [
# rule
url('^rules/$', views.RuleList.as_view(), name='network.rule_list'),
url('^rules/create$', views.RuleCreate.as_view(), name='network.rule_create'),
url('^rules/create$', views.RuleCreate.as_view(),
name='network.rule_create'),
url('^rules/(?P<pk>\d+)/$', views.RuleDetail.as_view(),
name='network.rule'),
......@@ -99,8 +103,10 @@ urlpatterns = [
# vlan
url('^vlans/$', views.VlanList.as_view(), name='network.vlan_list'),
url('^vlans/create$', views.VlanCreate.as_view(), name='network.vlan_create'),
url('^vlans/(?P<vid>\d+)/$', views.VlanDetail.as_view(), name='network.vlan'),
url('^vlans/create$', views.VlanCreate.as_view(),
name='network.vlan_create'),
url('^vlans/(?P<vid>\d+)/$', views.VlanDetail.as_view(),
name='network.vlan'),
url('^vlans/(?P<pk>\d+)/acl/$', views.VlanAclUpdateView.as_view(),
name='network.vlan-acl'),
url('^vlans/delete/(?P<vid>\d+)/$', views.VlanDelete.as_view(),
......@@ -119,12 +125,14 @@ urlpatterns = [
name="network.rule_delete"),
# non class based views
url('^hosts/(?P<pk>\d+)/remove/(?P<group_pk>\d+)/$', views.remove_host_group,
url('^hosts/(?P<pk>\d+)/remove/(?P<group_pk>\d+)/$',
views.remove_host_group,
name='network.remove_host_group'),
url('^hosts/(?P<pk>\d+)/add/$', views.add_host_group,
name='network.add_host_group'),
url('^switchports/(?P<pk>\d+)/remove/(?P<device_pk>\d+)/$',
views.remove_switch_port_device, name='network.remove_switch_port_device'),
views.remove_switch_port_device,
name='network.remove_switch_port_device'),
url('^switchports/(?P<pk>\d+)/add/$', views.add_switch_port_device,
name='network.add_switch_port_device'),
]
......@@ -119,7 +119,11 @@ class BlacklistList(LoginRequiredMixin, SuperuserRequiredMixin,
data = self.model.objects.all()
search = self.request.GET.get("s")
if search:
data = data.filter(Q(host__hostname__icontains=search) | Q(ipv4__icontains=search) | Q(reason__icontains=search))
data = data.filter(
Q(host__hostname__icontains=search) |
Q(ipv4__icontains=search) |
Q(reason__icontains=search)
)
return data
......@@ -452,8 +456,10 @@ class HostList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
search = self.request.GET.get("s")
if search:
data = data.filter(Q(hostname__icontains=search) |
Q(ipv4=search)) # ipv4 does not work TODO
data = data.filter(
Q(hostname__icontains=search) |
Q(ipv4__icontains=search)
)
return data
......@@ -613,7 +619,10 @@ class RecordList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
search = self.request.GET.get("s")
if search:
data = data.filter(Q(host__hostname__icontains=search) | Q(domain__name__icontains=search))
data = data.filter(
Q(host__hostname__icontains=search) |
Q(domain__name__icontains=search)
)
return data
......@@ -932,7 +941,10 @@ class VlanGroupList(LoginRequiredMixin, SuperuserRequiredMixin,
data = self.model.objects.all()
search = self.request.GET.get("s")
if search:
data = data.filter(Q(name__icontains=search) | Q(description__icontains=search))
data = data.filter(
Q(name__icontains=search) |
Q(description__icontains=search)
)
return data
......
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 sign in to comment