Allow day_id to be NULL, since breakfast time is stored that way.

Expand the sessions() helper function in MeetingTime to iterate over
the sessions and set the room_id helper attribute to the correct room.
This means that for the list returned by sessions(), s.room_id is the
correct room for this time.  It also changes the return value from
a QuerySet to a list, so you can't filter it further like a QuerySet -
but I don't think anything is using this functionality.

I didn't do the same for combined_sessions because I don't actually
know what that's used for - if it should be part of sessions, or
if it's even used.
 - Legacy-Id: 157
This commit is contained in:
Bill Fenner 2007-05-23 17:22:16 +00:00
parent 5528a04cd9
commit 2d3bbede29

View file

@ -90,7 +90,7 @@ class NonSessionRef(models.Model):
class NonSession(models.Model): class NonSession(models.Model):
non_session_id = models.AutoField(primary_key=True) non_session_id = models.AutoField(primary_key=True)
day_id = models.IntegerField() day_id = models.IntegerField(blank=True, null=True)
non_session_ref = models.ForeignKey(NonSessionRef) non_session_ref = models.ForeignKey(NonSessionRef)
meeting = models.ForeignKey(Meeting, db_column='meeting_num') meeting = models.ForeignKey(Meeting, db_column='meeting_num')
time_desc = models.CharField(blank=True, maxlength=75) time_desc = models.CharField(blank=True, maxlength=75)
@ -152,10 +152,20 @@ class MeetingTime(models.Model):
""" """
Get all sessions that are scheduled at this time. Get all sessions that are scheduled at this time.
""" """
return WgMeetingSession.objects.filter( sessions = WgMeetingSession.objects.filter(
models.Q(sched_time_id1=self.time_id) | models.Q(sched_time_id1=self.time_id) |
models.Q(sched_time_id2=self.time_id) | models.Q(sched_time_id2=self.time_id) |
models.Q(sched_time_id3=self.time_id)) models.Q(sched_time_id3=self.time_id))
for s in sessions:
if s.sched_time_id1_id == self.time_id:
s.room_id = s.sched_room_id1
elif s.sched_time_id2_id == self.time_id:
s.room_id = s.sched_room_id2
elif s.sched_time_id3_id == self.time_id:
s.room_id = s.sched_room_id3
else:
s.room_id = 0
return sessions
def combined_sessions(self): def combined_sessions(self):
""" """
Get all sessions that have a combined_time at this Get all sessions that have a combined_time at this