# HG changeset patch # User Branko Majic # Date 2013-06-30 20:18:36 # Node ID a5941ab6ea3bfb817f4eb2a9a08a15d18213efd6 # Parent 9996f5fcde31063208e5a70853f635f78dfb6d62 Style fixes (PEP8). diff --git a/conntrackt/models.py b/conntrackt/models.py --- a/conntrackt/models.py +++ b/conntrackt/models.py @@ -265,4 +265,3 @@ class Communication(models.Model): """ return "Edit" - diff --git a/conntrackt/templatetags/conntrackt_tags.py b/conntrackt/templatetags/conntrackt_tags.py --- a/conntrackt/templatetags/conntrackt_tags.py +++ b/conntrackt/templatetags/conntrackt_tags.py @@ -47,7 +47,7 @@ def html_link(text, view, *args, **kwarg if key in ("class", "title", "id", "get"): context[key] = value else: - raise template.TemplateSyntaxError("Unknown argument for 'advhtml_link' tag: %r" % key ) + raise template.TemplateSyntaxError("Unknown argument for 'advhtml_link' tag: %r" % key) return context @@ -89,8 +89,8 @@ def active_link(context, url_name, retur matches = current_url_equals(context, url_name, **kwargs) return return_value if matches else '' - - + + def current_url_equals(context, url_name, **kwargs): """ Helper function for checking if the specified URL corresponds to the current @@ -124,4 +124,3 @@ def current_url_equals(context, url_name return False return matches - diff --git a/conntrackt/tests/test_models.py b/conntrackt/tests/test_models.py --- a/conntrackt/tests/test_models.py +++ b/conntrackt/tests/test_models.py @@ -140,4 +140,3 @@ class CommunicationTest(TestCase): expected = "Test Entity 2 -> Test Entity 1 (TCP:22)" self.assertEqual(expected, str(comm)) - diff --git a/conntrackt/tests/test_utils.py b/conntrackt/tests/test_utils.py --- a/conntrackt/tests/test_utils.py +++ b/conntrackt/tests/test_utils.py @@ -47,4 +47,3 @@ COMMIT COMMIT """ self.assertEqual(generated, expected) - diff --git a/conntrackt/tests/test_views.py b/conntrackt/tests/test_views.py --- a/conntrackt/tests/test_views.py +++ b/conntrackt/tests/test_views.py @@ -75,7 +75,7 @@ class IndexViewTest(ViewTest): self.client.login(username="fullperms", password="fullperms") response = self.client.get(reverse("index")) - + self.assertQuerysetEqual(response.context["projects"], ["", ""]) self.assertContains(response, "Test Project 1") self.assertContains(response, "Test Project 2") @@ -131,7 +131,7 @@ class ProjectViewTest(ViewTest): class EntityView(ViewTest): - + def test_permission_denied(self): """ Tests if permission will be denied for client without sufficient privileges. @@ -239,7 +239,7 @@ class EntityIptablesTest(ViewTest): self.assertContains(response, ":INPUT") self.assertContains(response, ":OUTPUT") self.assertContains(response, ":FORWARD") - + class ProjectIptablesTest(ViewTest): @@ -275,10 +275,9 @@ class ProjectIptablesTest(ViewTest): response = self.client.get(reverse("project_iptables", args=(200,))) self.assertEqual(response.status_code, 404) - response = self.client.get(reverse("project_location_iptables", args=(200,1))) + response = self.client.get(reverse("project_location_iptables", args=(200, 1))) self.assertEqual(response.status_code, 404) - def test_invalid_location(self): """ Tests if a 404 is returned if invalid location is specified. @@ -286,7 +285,7 @@ class ProjectIptablesTest(ViewTest): self.client.login(username="fullperms", password="fullperms") - response = self.client.get(reverse("project_location_iptables", args=(1,200))) + response = self.client.get(reverse("project_location_iptables", args=(1, 200))) self.assertEqual(response.status_code, 404) def test_content_type(self): @@ -310,7 +309,7 @@ class ProjectIptablesTest(ViewTest): response = self.client.get(reverse("project_iptables", args=(1,))) self.assertEqual(response['Content-Disposition'], 'attachment; filename="test_project_1-iptables.zip"') - response = self.client.get(reverse("project_location_iptables", args=(1,1))) + response = self.client.get(reverse("project_location_iptables", args=(1, 1))) self.assertEqual(response['Content-Disposition'], 'attachment; filename="test_project_1-test_location_1-iptables.zip"') def test_project_entities_show(self): @@ -328,7 +327,7 @@ class ProjectIptablesTest(ViewTest): expected_zip_files = ["test_entity_1-iptables.conf", "test_entity_2-iptables.conf", "test_entity_3-iptables.conf", - "test_subnet-iptables.conf" ] + "test_subnet-iptables.conf"] self.assertEqual(len(zipped_iptables.namelist()), 4) self.assertEqual(zipped_iptables.namelist(), expected_zip_files) @@ -348,7 +347,7 @@ class ProjectIptablesTest(ViewTest): self.client.login(username="fullperms", password="fullperms") - response = self.client.get(reverse("project_location_iptables", args=(1,1))) + response = self.client.get(reverse("project_location_iptables", args=(1, 1))) buff = StringIO(response.content) @@ -366,4 +365,3 @@ class ProjectIptablesTest(ViewTest): self.assertIn(":FORWARD", iptables_file) zipped_iptables.close() - diff --git a/conntrackt/urls.py b/conntrackt/urls.py --- a/conntrackt/urls.py +++ b/conntrackt/urls.py @@ -26,4 +26,3 @@ urlpatterns = patterns( url(r'^login/$', login, {'template_name': 'conntrackt/login.html'}, name="login"), url(r'^logout/$', logout, name="logout"), ) - diff --git a/conntrackt/utils.py b/conntrackt/utils.py --- a/conntrackt/utils.py +++ b/conntrackt/utils.py @@ -52,4 +52,3 @@ def generate_entity_iptables(entity): content = "%s%s" % (filter, nat) return content - diff --git a/conntrackt/views.py b/conntrackt/views.py --- a/conntrackt/views.py +++ b/conntrackt/views.py @@ -15,6 +15,7 @@ from braces.views import MultiplePermiss from .models import Project, Entity, Location from .utils import generate_entity_iptables + class IndexView(MultiplePermissionsRequiredMixin, TemplateView): """ Custom view used for rendering the index page. @@ -128,7 +129,7 @@ class EntityView(MultiplePermissionsRequ return context -@permission_required("conntrackt.view", raise_exception = True) +@permission_required("conntrackt.view", raise_exception=True) def entity_iptables(request, pk): """ Custom view that returns response containing iptables rules generated for an @@ -153,15 +154,15 @@ def entity_iptables(request, pk): entity = get_object_or_404(Entity, pk=pk) content = generate_entity_iptables(entity) response = HttpResponse(content, mimetype='text/plain') - + # Add the Content-Disposition information for the browser, telling the # browser to download the file with suggested filename. - response['Content-Disposition']="attachment; filename=%s-iptables.conf" % entity.name.lower().replace(" ", "_") + response['Content-Disposition'] = "attachment; filename=%s-iptables.conf" % entity.name.lower().replace(" ", "_") return response -@permission_required("conntrackt.view", raise_exception = True) +@permission_required("conntrackt.view", raise_exception=True) def project_iptables(request, project_id, location_id=None): """ Custom view for obtaining iptables for all entities of a project or project @@ -228,4 +229,3 @@ def project_iptables(request, project_id # Finally return the response object. return response -