Verified Commit 3799b044 authored by erdnaxe's avatar erdnaxe 🎇

Remove repetition in topologie models.py

parent 05b9cce6
Pipeline #1121 passed with stage
in 2 minutes and 55 seconds
......@@ -12,21 +12,12 @@ from django.contrib import admin
from reversion.admin import VersionAdmin
from .models import (
Room,
Building,
Dormitory,
Room,
)
@admin.register(Room)
class RoomAdmin(VersionAdmin):
"""Register Room object in admin"""
list_display = ('name', 'building', 'details')
list_filter = ('building', 'building__dormitory')
search_fields = ('name', 'building__name', 'building__dormitory__name',
'details')
@admin.register(Building)
class BuildingAdmin(VersionAdmin):
"""Register Dormitory object in admin"""
......@@ -40,3 +31,12 @@ class DormitoryAdmin(VersionAdmin):
"""Register Dormitory object in admin"""
list_display = ('name',)
search_fields = ('name',)
@admin.register(Room)
class RoomAdmin(VersionAdmin):
"""Register Room object in admin"""
list_display = ('name', 'building', 'details')
list_filter = ('building', 'building__dormitory')
search_fields = ('name', 'building__name', 'building__dormitory__name',
'details')
......@@ -416,7 +416,6 @@ class ModuleSwitch(AclMixin, RevMixin, models.Model):
verbose_name = _("switch module")
verbose_name_plural = _("switch modules")
def __str__(self):
return str(self.reference)
......@@ -447,7 +446,7 @@ class ConstructorSwitch(AclMixin, RevMixin, models.Model):
class Meta:
verbose_name = _("switch constructor")
verbose_name_plural = ("switch constructors")
verbose_name_plural = _("switch constructors")
def __str__(self):
return self.name
......@@ -871,40 +870,12 @@ def stack_post_delete(**_kwargs):
@receiver(post_save, sender=Port)
def port_post_save(**_kwargs):
regen("graph_topo")
@receiver(post_delete, sender=Port)
def port_post_delete(**_kwargs):
regen("graph_topo")
@receiver(post_save, sender=ModelSwitch)
def modelswitch_post_save(**_kwargs):
regen("graph_topo")
@receiver(post_delete, sender=ModelSwitch)
def modelswitch_post_delete(**_kwargs):
regen("graph_topo")
@receiver(post_save, sender=Building)
def building_post_save(**_kwargs):
regen("graph_topo")
@receiver(post_delete, sender=Building)
def building_post_delete(**_kwargs):
regen("graph_topo")
@receiver(post_save, sender=Switch)
def switch_post_save(**_kwargs):
regen("graph_topo")
@receiver(post_delete, sender=Switch)
def switch_post_delete(**_kwargs):
regen("graph_topo")
......
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