Commit 857adf1e authored by chirac's avatar chirac

Crée l'application topologie

parent 152224ae
......@@ -14,3 +14,6 @@ class MachineType(models.Model):
def __str__(self):
return self.type
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)
# -*- 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')]),
),
]
# -*- 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),
),
]
# -*- 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)),
],
),
]
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)
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment