def __init__(self): for session in Talk.get_talk_sessions(): room_dict = {} for room in Room.get_rooms(): room_dict[room.name] = None self.grid[session]= dict(room_dict) for talk in Talk.all().fetch(1000): if talk.session: self.add_talk(talk)
def test_get_rows_for_template(self): self.talk.room = self.room2 timetable = Timetable() timetable.add_talk(self.talk) number_of_sessions = len(Talk.get_talk_sessions()) self.assertEquals(number_of_sessions, len(timetable.get_rows_for_template())) for row in timetable.get_rows_for_template(): self.assertEquals(2, len(row.talks_by_room())) if row.session == 1: self.assertEquals(row.talks_by_room()[0], None) self.assertEquals(row.talks_by_room()[1], self.talk)
def get_rows_for_template(self): session_rows = [] contador = 0 for session in Talk.get_talk_sessions(): row = SessionRow(session) for room in Room.get_rooms(): if self.grid[session][room.name]: self.grid[session][room.name].contador = contador row.add_talk(self.grid[session][room.name]) contador = contador + 1 session_rows.append(row) return session_rows
def show_timetable(request): user = request.session.get('user') timetable = Timetable() rooms = Room.get_rooms() sessions = Talk.get_talk_sessions() return render_to_response('timetable_app.html', {'user': user, 'rooms': rooms, 'sessions': sessions, 'rows': timetable.get_rows_for_template()})
def test_empty_schedule_grid(self): grid = Timetable().get_grid() for session in Talk.get_talk_sessions(): for room in Room.get_rooms(): self.assertFalse(grid[session][room.name])