8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-04 17:06:27 +00:00

Crée l'application topologie

This commit is contained in:
chirac 2016-07-03 03:12:41 +02:00
parent 152224ae7d
commit 857adf1eb0
17 changed files with 136 additions and 0 deletions

View file

@ -14,3 +14,6 @@ class MachineType(models.Model):
def __str__(self):
return self.type

0
topologie/__init__.py Normal file
View file

Binary file not shown.

Binary file not shown.

Binary file not shown.

20
topologie/admin.py Normal file
View file

@ -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)

View file

@ -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')]),
),
]

View file

@ -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),
),
]

View file

@ -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)),
],
),
]

View file

29
topologie/models.py Normal file
View file

@ -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)

3
topologie/tests.py Normal file
View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
topologie/views.py Normal file
View file

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.