Changeset - a5941ab6ea3b
[Not reviewed]
default
0 8 0
Branko Majic (branko) - 11 years ago 2013-06-30 20:18:36
branko@majic.rs
Style fixes (PEP8).
8 files changed with 16 insertions and 24 deletions:
0 comments (0 inline, 0 general)
conntrackt/models.py
Show inline comments
 
@@ -265,4 +265,3 @@ class Communication(models.Model):
 
        """
 

	
 
        return "Edit"
 

	
conntrackt/templatetags/conntrackt_tags.py
Show inline comments
 
@@ -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
 

	
conntrackt/tests/test_models.py
Show inline comments
 
@@ -140,4 +140,3 @@ class CommunicationTest(TestCase):
 
        expected = "Test Entity 2 -> Test Entity 1 (TCP:22)"
 

	
 
        self.assertEqual(expected, str(comm))
 

	
conntrackt/tests/test_utils.py
Show inline comments
 
@@ -47,4 +47,3 @@ COMMIT
 
COMMIT
 
"""
 
        self.assertEqual(generated, expected)
 

	
conntrackt/tests/test_views.py
Show inline comments
 
@@ -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"], ["<Project: Test Project 1>", "<Project: Test Project 2>"])
 
        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()
 

	
conntrackt/urls.py
Show inline comments
 
@@ -26,4 +26,3 @@ urlpatterns = patterns(
 
    url(r'^login/$', login, {'template_name': 'conntrackt/login.html'}, name="login"),
 
    url(r'^logout/$', logout, name="logout"),
 
)
 

	
conntrackt/utils.py
Show inline comments
 
@@ -52,4 +52,3 @@ def generate_entity_iptables(entity):
 
    content = "%s%s" % (filter, nat)
 

	
 
    return content
 

	
conntrackt/views.py
Show inline comments
 
@@ -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
 

	
0 comments (0 inline, 0 general)