Enhance session admin to show room names
This commit is contained in:
parent
30e65e65a6
commit
8da6d18098
2 changed files with 14 additions and 2 deletions
2
vendor/symposion/schedule/admin.py
vendored
2
vendor/symposion/schedule/admin.py
vendored
|
@ -62,6 +62,8 @@ class TrackAdmin(admin.ModelAdmin):
|
|||
class SessionAdmin(admin.ModelAdmin):
|
||||
model = Session,
|
||||
filter_vertical=["slots"]
|
||||
list_display=("day","start","end","room_names")
|
||||
list__filter=("slot__slotroom__room","day")
|
||||
|
||||
admin.site.register(Day)
|
||||
admin.site.register(
|
||||
|
|
14
vendor/symposion/schedule/models.py
vendored
14
vendor/symposion/schedule/models.py
vendored
|
@ -267,14 +267,24 @@ class Session(models.Model):
|
|||
return role
|
||||
return None
|
||||
|
||||
@property
|
||||
def rooms(self):
|
||||
return Room.objects.filter(slotroom__slot__in=self.slots.all()).distinct()
|
||||
|
||||
@property
|
||||
def room_names(self):
|
||||
return ', '.join(room.name for room in self.rooms)
|
||||
|
||||
def __str__(self):
|
||||
start = self.start()
|
||||
end = self.end()
|
||||
rooms = ', '.join(room.name for room in self.rooms)
|
||||
if start and end:
|
||||
return "%s: %s - %s" % (
|
||||
return "%s: %s - %s in %s" % (
|
||||
self.day.date.strftime("%a"),
|
||||
start.strftime("%X"),
|
||||
end.strftime("%X")
|
||||
end.strftime("%X"),
|
||||
rooms
|
||||
)
|
||||
return ""
|
||||
|
||||
|
|
Loading…
Reference in a new issue