diff --git a/machines/models.py b/machines/models.py index d93324dd..49b794ed 100644 --- a/machines/models.py +++ b/machines/models.py @@ -14,3 +14,6 @@ class MachineType(models.Model): def __str__(self): return self.type + + + diff --git a/topologie/__init__.py b/topologie/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/topologie/__pycache__/__init__.cpython-34.pyc b/topologie/__pycache__/__init__.cpython-34.pyc new file mode 100644 index 00000000..74baff21 Binary files /dev/null and b/topologie/__pycache__/__init__.cpython-34.pyc differ diff --git a/topologie/__pycache__/admin.cpython-34.pyc b/topologie/__pycache__/admin.cpython-34.pyc new file mode 100644 index 00000000..6966844f Binary files /dev/null and b/topologie/__pycache__/admin.cpython-34.pyc differ diff --git a/topologie/__pycache__/models.cpython-34.pyc b/topologie/__pycache__/models.cpython-34.pyc new file mode 100644 index 00000000..ebba5e08 Binary files /dev/null and b/topologie/__pycache__/models.cpython-34.pyc differ diff --git a/topologie/admin.py b/topologie/admin.py new file mode 100644 index 00000000..4a0c1b67 --- /dev/null +++ b/topologie/admin.py @@ -0,0 +1,20 @@ + +from django.contrib import admin + +from .models import Port, Room, Link + +class PortAdmin(admin.ModelAdmin): + list_display = ('building','switch', 'port','details') + +class RoomAdmin(admin.ModelAdmin): + list_display = ('room','details') + +class RoomAdmin(admin.ModelAdmin): + list_display = ('room','details') + +class LinkAdmin(admin.ModelAdmin): + list_display = ('port', 'room','details') + +admin.site.register(Port, PortAdmin) +admin.site.register(Room, RoomAdmin) +admin.site.register(Link, LinkAdmin) diff --git a/topologie/migrations/0001_initial.py b/topologie/migrations/0001_initial.py new file mode 100644 index 00000000..3f8163b9 --- /dev/null +++ b/topologie/migrations/0001_initial.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Port', + fields=[ + ('id', models.AutoField(serialize=False, primary_key=True, auto_created=True, verbose_name='ID')), + ('building', models.CharField(max_length=10)), + ('switch', models.IntegerField()), + ('port', models.IntegerField()), + ('details', models.CharField(blank=True, max_length=255)), + ], + ), + migrations.CreateModel( + name='Room', + fields=[ + ('id', models.AutoField(serialize=False, primary_key=True, auto_created=True, verbose_name='ID')), + ('details', models.CharField(blank=True, max_length=255)), + ('room', models.CharField(max_length=255)), + ], + ), + migrations.AlterUniqueTogether( + name='port', + unique_together=set([('building', 'switch', 'port')]), + ), + ] diff --git a/topologie/migrations/0002_auto_20160703_0103.py b/topologie/migrations/0002_auto_20160703_0103.py new file mode 100644 index 00000000..83a290ac --- /dev/null +++ b/topologie/migrations/0002_auto_20160703_0103.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('topologie', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='room', + name='room', + field=models.CharField(unique=True, max_length=255), + ), + ] diff --git a/topologie/migrations/0003_link.py b/topologie/migrations/0003_link.py new file mode 100644 index 00000000..49574716 --- /dev/null +++ b/topologie/migrations/0003_link.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('topologie', '0002_auto_20160703_0103'), + ] + + operations = [ + migrations.CreateModel( + name='Link', + fields=[ + ('id', models.AutoField(verbose_name='ID', auto_created=True, serialize=False, primary_key=True)), + ('details', models.CharField(blank=True, max_length=255)), + ('port', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='topologie.Port')), + ('room', models.ForeignKey(to='topologie.Room', on_delete=django.db.models.deletion.PROTECT, blank=True)), + ], + ), + ] diff --git a/topologie/migrations/__init__.py b/topologie/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/topologie/migrations/__pycache__/0001_initial.cpython-34.pyc b/topologie/migrations/__pycache__/0001_initial.cpython-34.pyc new file mode 100644 index 00000000..ee411822 Binary files /dev/null and b/topologie/migrations/__pycache__/0001_initial.cpython-34.pyc differ diff --git a/topologie/migrations/__pycache__/0002_auto_20160703_0103.cpython-34.pyc b/topologie/migrations/__pycache__/0002_auto_20160703_0103.cpython-34.pyc new file mode 100644 index 00000000..d397a436 Binary files /dev/null and b/topologie/migrations/__pycache__/0002_auto_20160703_0103.cpython-34.pyc differ diff --git a/topologie/migrations/__pycache__/0003_link.cpython-34.pyc b/topologie/migrations/__pycache__/0003_link.cpython-34.pyc new file mode 100644 index 00000000..763b79d8 Binary files /dev/null and b/topologie/migrations/__pycache__/0003_link.cpython-34.pyc differ diff --git a/topologie/migrations/__pycache__/__init__.cpython-34.pyc b/topologie/migrations/__pycache__/__init__.cpython-34.pyc new file mode 100644 index 00000000..b9761cda Binary files /dev/null and b/topologie/migrations/__pycache__/__init__.cpython-34.pyc differ diff --git a/topologie/models.py b/topologie/models.py new file mode 100644 index 00000000..60060c83 --- /dev/null +++ b/topologie/models.py @@ -0,0 +1,29 @@ +from django.db import models + +class Port(models.Model): + building = models.CharField(max_length=10) + switch = models.IntegerField() + port = models.IntegerField() + details = models.CharField(max_length=255, blank=True) + + class Meta: + unique_together = ("building", "switch", "port") + + def __str__(self): + return str(self.building) + " - " + str(self.switch) + " - " + str(self.port) + +class Room(models.Model): + details = models.CharField(max_length=255, blank=True) + room = models.CharField(max_length=255, unique=True) + + def __str__(self): + return str(self.room) + +class Link(models.Model): + port = models.ForeignKey('Port', on_delete=models.PROTECT) + details = models.CharField(max_length=255, blank=True) + #port_linked = models.ForeignKey('Port', on_delete=models.PROTECT, blank=True) + room = models.ForeignKey('Room', on_delete=models.PROTECT, blank=True) + + def __str__(self): + return str(self.port) diff --git a/topologie/tests.py b/topologie/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/topologie/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/topologie/views.py b/topologie/views.py new file mode 100644 index 00000000..91ea44a2 --- /dev/null +++ b/topologie/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here.