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