Changeset - 265b2706e075
[Not reviewed]
default
0 38 0
Branko Majic (branko) - 12 years ago 2013-10-11 20:01:48
branko@majic.rs
CONNT-22: Added licensing information to Python files. Added licensing information to documentation files.
38 files changed with 756 insertions and 0 deletions:
0 comments (0 inline, 0 general)
conntrackt/__init__.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
conntrackt/admin.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django.contrib import admin
 
from django.core.urlresolvers import resolve
 

	
 
# Application imports.
 
from .models import Project, Location, Entity, Interface, Communication
 

	
 

	
 
class InterfaceInline(admin.StackedInline):
 
    """
 
    This class implements the inline admin view of the Interface instances. This
 
    is used when adding the entities (since it's easier to specify interface for
 
    an entity right away).
 

	
 
    Properties:
 

	
 
      - model - Model that this admin class refers to.
 
      - extra - Number of interfaces that should be show inline for
 
        adding/editing.
 
    """
 

	
 
    model = Interface
 
    extra = 1
 

	
conntrackt/forms.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django.forms import ModelForm
 

	
 
# Application imports.
 
from .models import Project, Location, Entity, Interface, Communication
 

	
 

	
 
class WidgetCSSClassFormMixin(object):
 
    """
 
    Helper form mixin that can be used for applying additional custom CSS
 
    classes to form field widgets.
 

	
 
    The mixin accepts the following class options:
 

	
 
        widget_css_classes - Dictionary describing which additional CSS classes
 
        should be applied to which form widget. Dictinoary keys should be equal
 
        to form widget names, while the value should be a string containing the
 
        extra CSS classes that should be applied to it. In order to apply the
 
        CSS classes to every widget of the form, use the key "ALL"
 
    """
 

	
 
    def __init__(self, *args, **kwargs):
 
        """
 
        Assigns the custom CSS classes form widgets, as configured by the
conntrackt/iptables.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Python imports.
 
from operator import attrgetter
 

	
 

	
 
class Rule(object):
 
    """
 
    Class representing a single iptables rule. The representation does not
 
    include the chain to which it is applied, or how it is applied (append vs
 
    insert).
 

	
 
    The instances of this class can be used for easily outputting a single rule.
 
    """
 
    def __init__(self, source, destination, protocol, port, description=""):
 
        """
 
        Initialises a rule instance. Sets-up the necessary information passed
 
        with arguments.
 

	
 
        Arguments:
 

	
 
        source - Source of communication, in format IP/NETMASK.
 

	
 
        destination - Destination of communication, in format IP/NETMASK.
 

	
 
        protocol - Protocol used by the rule. Currently supported values are
conntrackt/migrations/0001_initial.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# -*- coding: utf-8 -*-
 
import datetime
 
from south.db import db
 
from south.v2 import SchemaMigration
 
from django.db import models
 

	
 

	
 
class Migration(SchemaMigration):
 

	
 
    def forwards(self, orm):
 
        # Adding model 'Project'
 
        db.create_table('conntrackt_project', (
 
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
 
            ('name', self.gf('django.db.models.fields.CharField')(max_length=100)),
 
            ('description', self.gf('django.db.models.fields.TextField')(blank=True)),
 
        ))
 
        db.send_create_signal('conntrackt', ['Project'])
 

	
 
        # Adding model 'Location'
 
        db.create_table('conntrackt_location', (
 
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
 
            ('name', self.gf('django.db.models.fields.CharField')(max_length=100)),
 
            ('description', self.gf('django.db.models.fields.TextField')(blank=True)),
 
        ))
conntrackt/migrations/0002_auto__add_unique_communication_source_destination_protocol_port.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# -*- coding: utf-8 -*-
 
import datetime
 
from south.db import db
 
from south.v2 import SchemaMigration
 
from django.db import models
 

	
 

	
 
class Migration(SchemaMigration):
 

	
 
    def forwards(self, orm):
 
        # Adding unique constraint on 'Communication', fields ['source', 'destination', 'protocol', 'port']
 
        db.create_unique(u'conntrackt_communication', ['source_id', 'destination_id', 'protocol', 'port'])
 

	
 

	
 
    def backwards(self, orm):
 
        # Removing unique constraint on 'Communication', fields ['source', 'destination', 'protocol', 'port']
 
        db.delete_unique(u'conntrackt_communication', ['source_id', 'destination_id', 'protocol', 'port'])
 

	
 

	
 
    models = {
 
        u'conntrackt.communication': {
 
            'Meta': {'unique_together': "(('source', 'destination', 'protocol', 'port'),)", 'object_name': 'Communication'},
 
            'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
 
            'destination': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'destination_set'", 'to': u"orm['conntrackt.Interface']"}),
conntrackt/migrations/0003_auto__add_unique_entity_project_name__add_unique_location_name__add_un.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# -*- coding: utf-8 -*-
 
import datetime
 
from south.db import db
 
from south.v2 import SchemaMigration
 
from django.db import models
 

	
 

	
 
class Migration(SchemaMigration):
 

	
 
    def forwards(self, orm):
 
        # Adding unique constraint on 'Entity', fields ['project', 'name']
 
        db.create_unique(u'conntrackt_entity', ['project_id', 'name'])
 

	
 
        # Adding unique constraint on 'Location', fields ['name']
 
        db.create_unique(u'conntrackt_location', ['name'])
 

	
 
        # Adding unique constraint on 'Interface', fields ['name', 'entity']
 
        db.create_unique(u'conntrackt_interface', ['name', 'entity_id'])
 

	
 
        # Adding unique constraint on 'Project', fields ['name']
 
        db.create_unique(u'conntrackt_project', ['name'])
 

	
 

	
 
    def backwards(self, orm):
conntrackt/migrations/0004_auto__add_unique_interface_netmask_address_entity.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# -*- coding: utf-8 -*-
 
import datetime
 
from south.db import db
 
from south.v2 import SchemaMigration
 
from django.db import models
 

	
 

	
 
class Migration(SchemaMigration):
 

	
 
    def forwards(self, orm):
 
        # Adding unique constraint on 'Interface', fields ['netmask', 'address', 'entity']
 
        db.create_unique(u'conntrackt_interface', ['netmask', 'address', 'entity_id'])
 

	
 

	
 
    def backwards(self, orm):
 
        # Removing unique constraint on 'Interface', fields ['netmask', 'address', 'entity']
 
        db.delete_unique(u'conntrackt_interface', ['netmask', 'address', 'entity_id'])
 

	
 

	
 
    models = {
 
        u'conntrackt.communication': {
 
            'Meta': {'unique_together': "(('source', 'destination', 'protocol', 'port'),)", 'object_name': 'Communication'},
 
            'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
 
            'destination': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'destination_set'", 'to': u"orm['conntrackt.Interface']"}),
conntrackt/migrations/__init__.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
conntrackt/models.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django.core.exceptions import ValidationError
 
from django.core.urlresolvers import reverse
 
from django.db import models
 

	
 

	
 
class Project(models.Model):
 
    """
 
    Implements a model with information about a project. A project has some
 
    basic settings, and mainly serves the purpose of grouping entities for
 
    easier handling and administration.
 

	
 
    Fields:
 

	
 
      name - String denoting the project name.
 
      description - Free-form description of the project.
 
    """
 

	
 
    name = models.CharField(max_length=100, unique=True)
 
    description = models.TextField(blank=True)
 

	
 
    class Meta:
 
        permissions = (("view", "Can view information"),)
 

	
conntrackt/templatetags/__init__.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
conntrackt/templatetags/conntrackt_tags.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django import template
 
from django.core import urlresolvers
 

	
 

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

	
 

	
 
@register.simple_tag(takes_context=False)
 
def html_link(text, view, *args, **kwargs):
 
    """
 
    A small wrapper for showing HTML links.
 

	
 
    Positional arguments:
 

	
 
        text - Text that should be used as a link.
 

	
 
        view - View name for which the URL should be shown
 

	
 
        args - Additional positional arguments that will be passed to resolver
 
        for creating the URL.
 

	
 
    Keyword arguments:
conntrackt/tests/__init__.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
conntrackt/tests/factories.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Third-party application imports.
 
import factory
 

	
 
# Application imports.
 
from conntrackt.models import Project, Location, Entity, Interface, Communication
 

	
 

	
 
class ProjectFactory(factory.django.DjangoModelFactory):
 
    """
 
    Factory for producing projects where name is set to "Test Project N", and N
 
    is an increasing sequence. Description is based on name.
 
    """
 

	
 
    FACTORY_FOR = Project
 

	
 
    @factory.sequence
 
    def name(n):
 
        return "Test Project %d" % n
 

	
 
    description = factory.LazyAttribute(lambda d: "This is %s." % d.name)
 

	
 

	
 
class LocationFactory(factory.django.DjangoModelFactory):
 
    """
conntrackt/tests/forms.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports
 
from django import forms
 

	
 
# Application imports.
 
from conntrackt.forms import WidgetCSSClassFormMixin, PlaceholderFormMixin
 

	
 

	
 
class FormWithWidgetCSSClassFormMixin(WidgetCSSClassFormMixin, forms.Form):
 
    """
 
    Helper form for testing the WidgetCSSClassFormMixin.
 
    """
 

	
 
    field1 = forms.CharField()
 
    field2 = forms.CharField()
 

	
 

	
 
class FormWithPlaceholderFormMixin(PlaceholderFormMixin, forms.Form):
 

	
 
    field1 = forms.CharField()
 
    field2 = forms.CharField()
conntrackt/tests/helpers.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Python standard library imports.
 
from types import FunctionType
 

	
 
# Python third-party library imports.
 
import mock
 

	
 
# Django imports.
 
from django.core.exceptions import PermissionDenied
 
from django.contrib.auth.models import User, Permission
 
from django.test import RequestFactory
 

	
 

	
 
def create_get_request(url="/fake-path/", user=None):
 
    """
 
    Helper function for generating a GET request that can be passed on to a
 
    view.
 

	
 
    Arguments:
 

	
 
        url - URL that should be used for the request. Default is "/fake-path/".
 

	
 
        user - Django user to be passed on into the request. Default is
 
        mock.Mock().
 
    """
conntrackt/tests/test_forms.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django.test import TestCase
 

	
 
# Python third-party library imports.
 
import mock
 

	
 
# Application imports.
 
from conntrackt.forms import WidgetCSSClassFormMixin, PlaceholderFormMixin
 
from conntrackt.forms import EntityForm, InterfaceForm, CommunicationForm
 

	
 
# Test imports.
 
from .forms import FormWithWidgetCSSClassFormMixin, FormWithPlaceholderFormMixin
 

	
 

	
 
class WidgetCSSClassFormMixinTest(TestCase):
 
    """
 
    Tests the form mixin.
 
    """
 

	
 
    def test_apply_to_all(self):
 
        """
 
        Test if CSS class is appled to all form field widgets.
 
        """
 

	
conntrackt/tests/test_iptables.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django.test import TestCase
 

	
 
# Application imports.
 
from conntrackt import iptables
 

	
 

	
 
class RuleTest(TestCase):
 
    def test_output_case(self):
 
        """
 
        Test that protocol name is lower-cased during rule generation.
 
        """
 

	
 
        rule = iptables.Rule("192.168.1.1/255.255.255.255", "192.168.1.2/255.255.255.255", "tCp", "80", description="Web server.")
 
        self.assertEqual(str(rule), "-s 192.168.1.1/255.255.255.255 -d 192.168.1.2/255.255.255.255 -p tcp -m tcp --dport 80 -j ACCEPT")
 

	
 
    def test_output_tcp(self):
 
        """
 
        Tests that a TCP rule is generated properly.
 
        """
 

	
 
        rule = iptables.Rule("192.168.1.1/255.255.255.255", "192.168.1.2/255.255.255.255", "TCP", "80", description="Web server.")
 
        self.assertEqual(str(rule), "-s 192.168.1.1/255.255.255.255 -d 192.168.1.2/255.255.255.255 -p tcp -m tcp --dport 80 -j ACCEPT")
 

	
conntrackt/tests/test_models.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django.core.exceptions import ValidationError
 
from django.db import IntegrityError
 
from django.test import TestCase
 

	
 
# Application imports.
 
from conntrackt.models import Project, Location, Entity, Interface, Communication
 

	
 
# Test imports.
 
from .factories import ProjectFactory, LocationFactory
 
from .factories import ServerEntityFactory, ServerInterfaceFactory
 
from .factories import SubnetEntityFactory, SubnetInterfaceFactory
 
from .factories import CommunicationFactory
 
from .factories import setup_test_data
 

	
 

	
 
class ProjectTest(TestCase):
 

	
 
    def test_unique_name(self):
 
        """
 
        Test if unique project name is enforced.
 
        """
 

	
 
        project = ProjectFactory()
conntrackt/tests/test_utils.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django.test import TestCase
 

	
 
# Third-party Python library imports.
 
import palette
 
import pydot
 

	
 
# Application imports.
 
from conntrackt.models import Entity, Project, Communication
 
from conntrackt import utils
 
from .factories import setup_test_data
 

	
 

	
 
class GenerateEntityIptablesTest(TestCase):
 

	
 
    def setUp(self):
 
        """
 
        Set-up some test data.
 
        """
 

	
 
        setup_test_data()
 

	
 
    def test_generated_iptables(self):
 
        """
conntrackt/tests/test_views.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Standard library imports.
 
from StringIO import StringIO
 
from zipfile import ZipFile, ZIP_DEFLATED
 

	
 
# Python third-party library imports.
 
import mock
 

	
 
# Django imports.
 
from django.core.urlresolvers import reverse
 
from django.http import Http404
 
from django.test import RequestFactory
 
from django.test import TestCase
 

	
 
# Application imports
 
from conntrackt.models import Project, Location, Entity, Interface, Communication
 

	
 
from conntrackt.views import IndexView
 
from conntrackt.views import entity_iptables, project_iptables, project_diagram
 

	
 
from conntrackt.views import ProjectView, ProjectCreateView, ProjectUpdateView, ProjectDeleteView
 
from conntrackt.views import LocationCreateView, LocationUpdateView, LocationDeleteView
 
from conntrackt.views import EntityView, EntityCreateView, EntityUpdateView, EntityDeleteView
 
from conntrackt.views import InterfaceCreateView, InterfaceUpdateView, InterfaceDeleteView
 
from conntrackt.views import CommunicationCreateView, CommunicationUpdateView, CommunicationDeleteView
conntrackt/tests/views.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Application imports.
 
from conntrackt.views import RedirectToNextMixin
 

	
 

	
 
class StaticSuccessUrlFakeMixin(object):
 
    """
 
    Helper view for testing the RedirectToNextMixinView mixin.
 
    """
 

	
 
    def get_success_url(self):
 
        return self.success_url
 

	
 

	
 
class RedirectToNextMixinView(RedirectToNextMixin, StaticSuccessUrlFakeMixin):
 
    """
 
    Helper view for testing the RedirectToNextMixinView mixin. StaticSuccessUrl
 
    is there just to provide default for get_success_url().
 
    """
 

	
 
    success_url = "/STATIC"
 

	
 
    def __init__(self, request):
 
        """
 
        Initialise the request to provided value.
conntrackt/urls.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django.conf.urls import patterns, url
 
from django.contrib.auth.views import login, logout
 

	
 
# Application imports.
 
from .views import IndexView, EntityView, entity_iptables, project_iptables, project_diagram
 
from .views import ProjectView, ProjectCreateView, ProjectUpdateView, ProjectDeleteView
 
from .views import LocationCreateView, LocationUpdateView, LocationDeleteView
 
from .views import EntityCreateView, EntityUpdateView, EntityDeleteView
 
from .views import InterfaceCreateView, InterfaceUpdateView, InterfaceDeleteView
 
from .views import CommunicationCreateView, CommunicationUpdateView, CommunicationDeleteView
 

	
 

	
 
urlpatterns = patterns(
 
    'conntrackt.views',
 
    # Homepage/index view.
 
    url(r'^$', IndexView.as_view(), name="index"),
 

	
 
    # View for showing information about a project.
 
    url(r'^project/(?P<pk>\d+)/$', ProjectView.as_view(),
 
        name='project'),
 
    # View for creating a new project.
 
    url(r'^project/add/$', ProjectCreateView.as_view(), name="project_create"),
 
    # View for updating an existing project.
conntrackt/utils.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Standard library imports.
 
import re
 
import itertools
 

	
 
# Third-party Python library imports.
 
import palette
 
import pydot
 

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

	
 
# Application imports.
 
import iptables
 
from .models import Communication
 

	
 

	
 
def generate_entity_iptables(entity):
 
    """
 
    Generates full iptables rules for the supplied entity. The generated rules
 
    can be fed directly to the iptables-restore utility.
 

	
 
    Arguments:
 

	
 
        entity - An Entity instance for which the iptables rules should be
conntrackt/views.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Standard library imports.
 
from StringIO import StringIO
 
from zipfile import ZipFile, ZIP_DEFLATED
 

	
 
# Django imports.
 
from django.contrib.auth.decorators import permission_required
 
from django.contrib import messages
 
from django.core.urlresolvers import reverse, reverse_lazy
 
from django.http import HttpResponse
 
from django.shortcuts import render_to_response, get_object_or_404
 
from django.views.generic import TemplateView, DetailView, CreateView, UpdateView, DeleteView
 

	
 
# Third-party application imports.
 
from braces.views import MultiplePermissionsRequiredMixin, SetHeadlineMixin
 

	
 
# Application imports.
 
from .forms import ProjectForm, LocationForm, EntityForm, InterfaceForm, CommunicationForm
 
from .models import Project, Entity, Location, Interface, Communication
 
from .utils import generate_entity_iptables, generate_project_diagram
 

	
 

	
 
class RedirectToNextMixin(object):
 
    """
 
    View mixin that can be used for redirecting the user to URL defined through
docs/about.rst
Show inline comments
 
.. Copyright (C) 2013 Branko Majic
 

	
 
   This file is part of Django Conntrackt documentation.
 

	
 
   This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
 
   Unported License. To view a copy of this license, visit
 
   http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
 
   Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
 

	
 
About Django Conntrackt
 
=======================
 

	
 
Django Conntrackt is a simple application intended to provide system
 
administrators and integrators that deploy servers at client's premises to
 
easily keep track of required networ communications between different servers,
 
routers, client workstations, and even whole networks/sub-networks.
 

	
 

	
 
Why was this application created?
 
---------------------------------
 

	
 
The application was created in order to alleviate painful and error prone
 
tracking of IP addresses and network communications inside of spread-sheet
 
files. Another reason was the need to create simple iptables rules based on this
 
information with as little hassle as possible.
 

	
 
The *iptables* generation requirements for Django Conntrackt were farily simple,
 
and do not include any complex functionality. It all boils down to rejecting all
 
communication except for explicitly defined links.
 

	
 

	
 
Features
 
--------
docs/conf.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django Conntrackt documentation build configuration file, created by
 
# sphinx-quickstart on Sun Apr 14 21:47:09 2013.
 
#
 
# This file is execfile()d with the current directory set to its containing dir.
 
#
 
# Note that not all possible configuration values are present in this
 
# autogenerated file.
 
#
 
# All configuration values have a default; values that are commented out
 
# serve to show the default.
 

	
 
import sys
 
import os
 

	
 
# If extensions (or modules to document with autodoc) are in another directory,
 
# add these directories to sys.path here. If the directory is relative to the
 
# documentation root, use os.path.abspath to make it absolute, like shown here.
 
#sys.path.insert(0, os.path.abspath('.'))
 

	
 
# -- General configuration -----------------------------------------------------
 

	
 
# If your documentation needs a minimal Sphinx version, state it here.
 
#needs_sphinx = '1.0'
 

	
docs/index.rst
Show inline comments
 
.. Copyright (C) 2013 Branko Majic
 

	
 
   This file is part of Django Conntrackt documentation.
 

	
 
   This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
 
   Unported License. To view a copy of this license, visit
 
   http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
 
   Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
 

	
 
Django Conntrackt documentation
 
===============================
 

	
 
Django Conntrackt is a simple application intended to provide system
 
administrators and integrators that deploy servers at client's premises to
 
easily keep track of required networ communications between different servers,
 
routers, client workstations, and even whole networks/sub-networks.
 

	
 

	
 
Support
 
-------
 

	
 
In case of problems with the application, please do not hesitate to contact the
 
author at **django.conntrackt (at) majic.rs**. Known issues and planned features
 
are tracked on website:
 

	
 
* https://projects.majic.rs/conntrackt/
 

	
 

	
 
Contents
 
--------
 

	
 
.. toctree::
 
   :maxdepth: 2
docs/installation.rst
Show inline comments
 
.. Copyright (C) 2013 Branko Majic
 

	
 
   This file is part of Django Conntrackt documentation.
 

	
 
   This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
 
   Unported License. To view a copy of this license, visit
 
   http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
 
   Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
 

	
 
Installation
 
============
 

	
 
Django Conntrackt can be installed through one of the following methods:
 

	
 
* Using *pip*, which is the recommended way for production
 
  websites.
 

	
 

	
 
Using pip
 
---------
 

	
 
In order to install latest stable release of Django Conntrackt using *pip*, use
 
the following command::
 

	
 
  pip install conntrackt
 

	
 
In order to install the latest development version of Django Conntrackt from
 
Mercurial repository, use the following command::
 

	
 
 pip install -e hg+http://code.majic.rs/conntrackt#egg=conntrackt
 

	
 
.. warning::
 

	
docs/quickstart.rst
Show inline comments
 
.. Copyright (C) 2013 Branko Majic
 

	
 
   This file is part of Django Conntrackt documentation.
 

	
 
   This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
 
   Unported License. To view a copy of this license, visit
 
   http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
 
   Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
 

	
 
Quick-start guide
 
=================
 

	
 
This chapter provides quick-start instructions in order to allow you to quickly deploy and test Django Conntrackt application.
 

	
 

	
 
Debian/Ubuntu
 
-------------
 

	
 
Install the *pip* utility::
 

	
 
  sudo apt-get install pip
 

	
 
Install the *virtualenv* and *virtualenvwrapper*::
 

	
 
  sudo apt-get install python-virtualenv virtualenvwrapper
 

	
 
Create the virtual environment for testing Django Conntrackt::
 

	
 
  mkvirtualenv conntrackt
 

	
 
Install Django Conntrackt with its requirements::
 

	
 
  workon conntrackt
docs/releasenotes.rst
Show inline comments
 
.. Copyright (C) 2013 Branko Majic
 

	
 
   This file is part of Django Conntrackt documentation.
 

	
 
   This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
 
   Unported License. To view a copy of this license, visit
 
   http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
 
   Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
 

	
 
Release Notes
 
=============
 

	
 
0.1
 
---
 

	
 
Initial relase of Django Conntrackt. Contains full support for:
 

	
 
* Managing application data.
 
* Generation of iptables rules.
 
* Generation of communication diagram.
 
* Full user documentation.
docs/usage.rst
Show inline comments
 
.. Copyright (C) 2013 Branko Majic
 

	
 
   This file is part of Django Conntrackt documentation.
 

	
 
   This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
 
   Unported License. To view a copy of this license, visit
 
   http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
 
   Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
 

	
 
.. _usage:
 

	
 
Usage
 
=====
 

	
 
Django Conntrackt provides a very simple interface for reading and editing the
 
information about network connections across projects, as well as for obtaining
 
*iptables* rules.
 

	
 
Key concepts
 
------------
 

	
 
There is a couple of key concepts to be aware of throughout the documentation:
 

	
 
Project
 
    A project is used to group the related entities. Project usually maps to
 
    business projects being worked on by the organisation members.
 

	
 
Location
 
    Location is used to group the related entities within a project. Locations
 
    can be abstract, like *primary site*, *secondary site*, or *disaster
 
    site*. They can also be more specific, like *Belgrade*, or *Stockholm*. The
 
    layout of locations is completely up to the user of Conntrackt.
 

	
projtest/manage.py
Show inline comments
 
#!/usr/bin/env python
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
import os
 
import sys
 

	
 
if __name__ == "__main__":
 
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "projtest.settings")
 

	
 
    from django.core.management import execute_from_command_line
 

	
 
    execute_from_command_line(sys.argv)
projtest/projtest/__init__.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
projtest/projtest/settings.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django settings for projtest project.
 
DEBUG = True
 
TEMPLATE_DEBUG = DEBUG
 

	
 
ADMINS = (
 
    ('Branko Majic', 'branko@majic.rs'),
 
)
 

	
 
MANAGERS = ADMINS
 

	
 
DATABASES = {
 
    'default': {
 
        'ENGINE': 'django.db.backends.sqlite3',  # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
 
        'NAME': 'projtest.db',                      # Or path to database file if using sqlite3.
 
        'USER': '',                      # Not used with sqlite3.
 
        'PASSWORD': '',                  # Not used with sqlite3.
 
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
 
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
 
    }
 
}
 

	
 
# Local time zone for this installation. Choices can be found here:
 
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
 
# although not all choices may be available on all operating systems.
projtest/projtest/urls.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports
 
from django.conf.urls import patterns, include, url
 
from django.contrib import admin
 
from django.http import HttpResponseRedirect
 

	
 

	
 
# Auto-discover admin interface.
 
admin.autodiscover()
 

	
 

	
 
urlpatterns = patterns(
 
    '',
 
    # Examples:
 
    # url(r'^$', 'projtest.views.home', name='home'),
 
    # url(r'^projtest/', include('projtest.foo.urls')),
 
    url(r'^$', lambda r: HttpResponseRedirect('conntrackt/')),
 
    url(r'^conntrackt/', include('conntrackt.urls')),
 

	
 

	
 
    # Uncomment the admin/doc line below to enable admin documentation:
 
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
 

	
 
    # Uncomment the next line to enable the admin:
 
    url(r'^admin/', include(admin.site.urls)),
projtest/projtest/wsgi.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
"""
 
WSGI config for projtest project.
 

	
 
This module contains the WSGI application used by Django's development server
 
and any production WSGI deployments. It should expose a module-level variable
 
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
 
this application via the ``WSGI_APPLICATION`` setting.
 

	
 
Usually you will have the standard Django WSGI application here, but it also
 
might make sense to replace the whole Django WSGI application with a custom one
 
that later delegates to the Django one. For example, you could introduce WSGI
 
middleware here, or combine a Django application with an application of another
 
framework.
 

	
 
"""
 
import os
 

	
 
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "projtest.settings")
 

	
 
# This application object is used by any WSGI server configured to use this
 
# file. This includes Django's development server, if the WSGI_APPLICATION
 
# setting points here.
 
from django.core.wsgi import get_wsgi_application
 
application = get_wsgi_application()
setup.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
import os
 
from setuptools import setup, find_packages
 
from pip.req import parse_requirements
 

	
 
README = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()
 
INSTALL_REQUIREMENTS = [str(r.req) for r in parse_requirements("requirements/production.txt")]
 
TEST_REQUIREMENTS = [str(r.req) for r in parse_requirements("requirements/test.txt")]
 

	
 
# allow setup.py to be run from any path
 
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
 

	
 
setup(
 
    name='django-conntrackt',
 
    version='0.1',
 
    packages=find_packages(exclude=["projtest", "projtest.*"]),
 
    include_package_data=True,
 
    license='GPLv3+',
 
    description='A simple application for tracking connection requirements between different entities in a network.',
 
    long_description=README,
 
    url='http://projects.majic.rs/conntrackt',
 
    author='Branko Majic',
 
    author_email='branko@majic.rs',
 
    install_requires=INSTALL_REQUIREMENTS,
 
    tests_require=TEST_REQUIREMENTS,
0 comments (0 inline, 0 general)