mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-23 11:53:12 +00:00
Fix room_name problem with building
This commit is contained in:
parent
8d799ed92d
commit
87730a3ad2
3 changed files with 14 additions and 5 deletions
|
@ -39,6 +39,7 @@ from .models import (
|
|||
AccessPoint,
|
||||
SwitchBay,
|
||||
Building,
|
||||
Dormitory,
|
||||
PortProfile,
|
||||
)
|
||||
|
||||
|
@ -87,6 +88,12 @@ class BuildingAdmin(VersionAdmin):
|
|||
"""Administration d'un batiment"""
|
||||
pass
|
||||
|
||||
|
||||
class DormitoryAdmin(VersionAdmin):
|
||||
"""Administration d'une residence"""
|
||||
pass
|
||||
|
||||
|
||||
class PortProfileAdmin(VersionAdmin):
|
||||
"""Administration of a port profile"""
|
||||
pass
|
||||
|
@ -99,5 +106,6 @@ admin.site.register(Stack, StackAdmin)
|
|||
admin.site.register(ModelSwitch, ModelSwitchAdmin)
|
||||
admin.site.register(ConstructorSwitch, ConstructorSwitchAdmin)
|
||||
admin.site.register(Building, BuildingAdmin)
|
||||
admin.site.register(Dormitory, DormitoryAdmin)
|
||||
admin.site.register(SwitchBay, SwitchBayAdmin)
|
||||
admin.site.register(PortProfile, PortProfileAdmin)
|
||||
|
|
|
@ -558,6 +558,10 @@ class Building(AclMixin, RevMixin, models.Model):
|
|||
"""Returns all ap of the building"""
|
||||
return AccessPoint.all_ap_in(self)
|
||||
|
||||
@cached_property
|
||||
def cached_name(self):
|
||||
return self.__str__()
|
||||
|
||||
def __str__(self):
|
||||
if Dormitory.objects.count() > 1:
|
||||
return self.dormitory.name + " : " + self.name
|
||||
|
@ -749,10 +753,7 @@ class Room(AclMixin, RevMixin, models.Model):
|
|||
unique_together = ('name', 'building')
|
||||
|
||||
def __str__(self):
|
||||
if Dormitory.objects.count() > 1:
|
||||
return self.building.dormitory.name + " : " + self.building.name + self.name
|
||||
else:
|
||||
return self.building.name + self.name
|
||||
return self.building.cached_name + self.name
|
||||
|
||||
|
||||
class PortProfile(AclMixin, RevMixin, models.Model):
|
||||
|
|
|
@ -42,7 +42,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
{% for dormitory in dormitory_list %}
|
||||
<tr>
|
||||
<td>{{ dormitory.name }}</td>
|
||||
<td>{% for building in dormitory.building_set.all %} {{ building }} {% endfor %}</td>
|
||||
<td>{% for building in dormitory.building_set.all %} {{ building.name }} {% endfor %}</td>
|
||||
<td class="text-right">
|
||||
{% can_edit dormitory %}
|
||||
{% include 'buttons/edit.html' with href='topologie:edit-dormitory' id=dormitory.id %}
|
||||
|
|
Loading…
Reference in a new issue