Changeset - f397b9db8183
[Not reviewed]
default
0 6 0
Branko Majic (branko) - 11 years ago 2013-04-14 11:37:14
branko@majic.rs
Styling updates to reflect 2SoD recommendations.
6 files changed with 24 insertions and 19 deletions:
0 comments (0 inline, 0 general)
conntrackt/admin.py
Show inline comments
 
# Import all the models from the application.
 
from conntrackt.models import *
 

	
 
# Import the administrator application.
 
# Django imports.
 
from django.contrib import admin
 
from django.core.urlresolvers import resolve
 

	
 
# Import resolver used for figuring-out the view being called in custom query
 
# calls.
 
from django.core.urlresolvers import resolve
 
# Application imports.
 
from .models import Project, Location, Entity, Interface, Communication
 

	
 

	
 
class InterfaceInline(admin.StackedInline):
 
    """
 
@@ -24,6 +22,7 @@ class InterfaceInline(admin.StackedInlin
 
    model = Interface
 
    extra = 1
 

	
 

	
 
class CommunicationAdmin(admin.ModelAdmin):
 
    """
 
    Modifies the default admin class for the Communication class. The
 
@@ -81,6 +80,7 @@ class CommunicationAdmin(admin.ModelAdmi
 
        # Call the parent's method so it would do any of its magic.
 
        return super(CommunicationAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
 

	
 

	
 
class EntityAdmin(admin.ModelAdmin):
 
    """
 
    This class implements the admin view of the entity instances. It adds some
 
@@ -97,6 +97,7 @@ class EntityAdmin(admin.ModelAdmin):
 
    # Enable filtering based on project and location.
 
    list_filter = ['project', 'location']
 

	
 

	
 
class InterfaceAdmin(admin.ModelAdmin):
 
    """
 
    This class implements the admin view of the interface instances. It allows
 
@@ -112,6 +113,7 @@ class InterfaceAdmin(admin.ModelAdmin):
 
    # Enable filtering based on project and location.
 
    list_filter = ['entity__project', 'entity__location']
 

	
 

	
 
# Register our admin classes.
 
admin.site.register(Project)
 
admin.site.register(Location)
conntrackt/models.py
Show inline comments
 
# Django-specific imports
 
# Django imports.
 
from django.core.exceptions import ValidationError
 
from django.db import models
 

	
 
# Create your models here.
 

	
 
class Project(models.Model):
 
    """
 
    Implements a model with information about a project. A project has some
 
@@ -26,6 +26,7 @@ class Project(models.Model):
 

	
 
        return self.name
 

	
 

	
 
class Location(models.Model):
 
    """
 
    Implements a model with information about location. Locations can further be
 
@@ -61,6 +62,7 @@ class Location(models.Model):
 

	
 
        return self.name
 

	
 

	
 
class Entity(models.Model):
 
    """
 
    Models an entity in a project. An entity can be a server, router, or any
 
@@ -106,6 +108,7 @@ class Entity(models.Model):
 

	
 
        return "%s (%s - %s)" % (self.name, self.project, self.location)
 

	
 

	
 
class Interface(models.Model):
 
    """
 
    Models a representation of an interface on an entity. It can be used for
 
@@ -145,6 +148,7 @@ class Interface(models.Model):
 
        else:
 
            return '%s (%s/%s)' % (self.entity.name, self.address, self.netmask)
 

	
 

	
 
class Communication(models.Model):
 
    """
 
    Models a representation of allowed network communication. This lets the user
conntrackt/templatetags/conntrackt_tags.py
Show inline comments
 
# Import Django's template library.
 
# Django imports.
 
from django import template
 
# Import for determining the active URL.
 
from django.core import urlresolvers
 

	
 

	
 
# Get an instance of Django's template library.
 
register = template.Library()
 

	
conntrackt/urls.py
Show inline comments
 
# Import basic functions for URL pattern processing.
 
# Django imports.
 
from django.conf.urls import patterns, url
 

	
 
# For logging-in the users
 
from django.contrib.auth.views import login, logout
 

	
 
# Import some app-specific views.
 
# Application imports.
 
from .views import IndexView, ProjectView, EntityView, entity_iptables, project_iptables
 

	
 

	
 
urlpatterns = patterns(
 
    'conntrackt.views',
 
    # Homepage/index view.
conntrackt/utils.py
Show inline comments
 
# Standard library imports.
 
import re
 

	
 
# Django-specific imports.
 
# Django imports.
 
from django.template import Context, loader
 

	
 

	
conntrackt/views.py
Show inline comments
 
# For generating ZIP files.
 
# Standard library imports.
 
from StringIO import StringIO
 
from zipfile import ZipFile, ZIP_DEFLATED
 

	
 
# Django-specific imports.
 
# Django imports.
 
from django.http import HttpResponse
 
from django.shortcuts import render_to_response, get_object_or_404
 
from django.views.generic import TemplateView, DetailView
 

	
 
# Application-specific imports.
 
# Application imports.
 
from .models import Project, Entity, Location
 
from .utils import generate_entity_iptables
 

	
0 comments (0 inline, 0 general)