From 8da6d180980554c3aca1fd1efc99fe205260b0ce Mon Sep 17 00:00:00 2001 From: James Polley Date: Mon, 15 Jan 2018 03:41:50 +1100 Subject: [PATCH] Enhance session admin to show room names --- vendor/symposion/schedule/admin.py | 2 ++ vendor/symposion/schedule/models.py | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/vendor/symposion/schedule/admin.py b/vendor/symposion/schedule/admin.py index edd4ae3e..34305cd2 100644 --- a/vendor/symposion/schedule/admin.py +++ b/vendor/symposion/schedule/admin.py @@ -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( diff --git a/vendor/symposion/schedule/models.py b/vendor/symposion/schedule/models.py index 295092fe..892de069 100644 --- a/vendor/symposion/schedule/models.py +++ b/vendor/symposion/schedule/models.py @@ -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 ""