mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-25 22:22:26 +00:00
Simplified Room model
This commit is contained in:
parent
984435aee8
commit
6e811ca387
4 changed files with 60 additions and 11 deletions
|
@ -10,7 +10,7 @@ class PortAdmin(admin.ModelAdmin):
|
||||||
list_display = ('switch', 'port','room','details')
|
list_display = ('switch', 'port','room','details')
|
||||||
|
|
||||||
class RoomAdmin(admin.ModelAdmin):
|
class RoomAdmin(admin.ModelAdmin):
|
||||||
list_display = ('building','room','number','details')
|
list_display = ('name',)
|
||||||
|
|
||||||
admin.site.register(Port, PortAdmin)
|
admin.site.register(Port, PortAdmin)
|
||||||
admin.site.register(Room, RoomAdmin)
|
admin.site.register(Room, RoomAdmin)
|
||||||
|
|
35
topologie/migrations/0010_auto_20160704_2148.py
Normal file
35
topologie/migrations/0010_auto_20160704_2148.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('topologie', '0009_auto_20160703_1200'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='room',
|
||||||
|
old_name='building',
|
||||||
|
new_name='name',
|
||||||
|
),
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name='room',
|
||||||
|
unique_together=set([]),
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='room',
|
||||||
|
name='details',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='room',
|
||||||
|
name='number',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='room',
|
||||||
|
name='room',
|
||||||
|
),
|
||||||
|
]
|
19
topologie/migrations/0011_auto_20160704_2153.py
Normal file
19
topologie/migrations/0011_auto_20160704_2153.py
Normal 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', '0010_auto_20160704_2148'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='room',
|
||||||
|
name='name',
|
||||||
|
field=models.CharField(max_length=255, unique=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -19,6 +19,7 @@ class Port(models.Model):
|
||||||
port = models.IntegerField()
|
port = models.IntegerField()
|
||||||
details = models.CharField(max_length=255, blank=True)
|
details = models.CharField(max_length=255, blank=True)
|
||||||
room = models.ForeignKey('Room', on_delete=models.PROTECT, blank=True, null=True)
|
room = models.ForeignKey('Room', on_delete=models.PROTECT, blank=True, null=True)
|
||||||
|
# machine_interface = models.OneToOneField('machines.Interface', on_delete=models.PROTECT, blank=True, null=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ('_content_type', '_object_id')
|
unique_together = ('_content_type', '_object_id')
|
||||||
|
@ -40,14 +41,8 @@ class Port(models.Model):
|
||||||
return str(self.switch) + " - " + str(self.port)
|
return str(self.switch) + " - " + str(self.port)
|
||||||
|
|
||||||
class Room(models.Model):
|
class Room(models.Model):
|
||||||
details = models.CharField(max_length=255, blank=True)
|
name = models.CharField(max_length=255, unique=True)
|
||||||
building = models.CharField(max_length=255)
|
|
||||||
room = models.IntegerField()
|
|
||||||
number = models.IntegerField(blank=True, null=True)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
unique_together = ('building', 'room', 'number')
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.building) + str(self.room) + '-' + str(self.number)
|
return str(self.name)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue