def List(module_id): """ Lists all sessions for given module. """ # Verify user access if not Authorization.canAccess(session.get('user'), ('scheduling_admin')): return render_template('error/no_access.html') # Get module object module = ModuleModel.findById(module_id) if not module: return render_template('error/resource_not_found.html') # Get list of module sessions for given module sessions = ModuleSession.findBy('module', module_id) # Get a list of all teachers teachers = TeacherModel.all() # Get a list of all module session types session_types = ModuleSessionTypeModel.all() return render_template('session_list.html', data={ 'module': module, 'sessions': sessions, 'teachers': teachers, 'session_types': session_types })
def View(id): """ Gets information for given module. """ # Verify user access if not Authorization.canAccess(session.get('user'), ('scheduling_admin')): return render_template('error/no_access.html') # Get module object module = ModuleModel.findById(id) if not module: return render_template('error/resource_not_found.html') # Get leader (teacher) object leader = TeacherModel.findById(module.getLeader()) if not module: return render_template('error/server_error.html') # Get teachers object teachers = TeacherModel.all() # Get enrolled students students = [] enrolments = StudentModuleModel.findBy('module', id) for enrolment in enrolments: students.append(StudentModel.findById(enrolment.getStudent())) # Get module sessions (+ teachers) sessions = ModuleSessionModel.findBy('module', id) sessions_list = [] for session2 in sessions: sessions_list.append({ 'session': session2, 'staff': TeacherModel.findById(session2.getStaff()), 'type': ModuleSessionTypeModel.findById(session2.getType()) }) # Get session types sessionTypes = ModuleSessionTypeModel.all() return render_template('module_view.html', data={ 'module': module, 'leader': leader, 'teachers': teachers, 'students': students, 'sessionTypes': sessionTypes, 'sessions': sessions_list })
def List(): """ Lists all modules. """ # Verify user access if not Authorization.canAccess(session.get('user'), ('scheduling_admin')): return render_template('error/no_access.html') # Get list of all teachers teachers = TeacherModel.all() # Get list of modules modules = ModuleModel.all() return render_template('module_list.html', data={ 'modules': modules, 'teachers': teachers })
def View(module_id, session_id): """ Returns module session information. """ # Verify user access if not Authorization.canAccess(session.get('user'), ('scheduling_admin')): return render_template('error/no_access.html') # Get module object module = ModuleModel.findById(module_id) if not module: return render_template('error/resource_not_found.html') # Get session object theSession = ModuleSessionModel.findById(session_id) if not theSession: return render_template('error/resource_not_found.html') # Get the campus objects campus_list = CampusModel.all() campuses = [] for campus in campus_list: buildings = CampusBuildingModel.findBy('campus', campus.getId()) if (len(buildings) > 0): campuses.append({'campus': campus, 'buildings': buildings}) theSession = { 'session': theSession, 'staff': TeacherModel.findById(theSession.getStaff()), 'type': ModuleSessionTypeModel.findById(theSession.getType()), 'campuses': CampusModel.all() } # Get list of teachers teachers = TeacherModel.all() # Get list of session types session_types = ModuleSessionTypeModel.all() # Get terms terms = TermModel.all() term_list = [] for term in terms: term_list.append({ 'term': term, 'startDate': datetime.utcfromtimestamp(term.getStartDate()).strftime("%B %Y"), 'endDate': datetime.utcfromtimestamp(term.getEndDate()).strftime("%B %Y") }) # Get list of room bookings room_bookings = RoomBookingModel.findBy('module_session', session_id) room_bookings2 = [] for booking in room_bookings: room = CampusBuildingRoomModel.findById(booking.getRoom()) building = CampusBuildingModel.findById(room.getBuilding()) campus = CampusModel.findById(building.getCampus()) timeFrom = datetime.utcfromtimestamp( booking.getTimeFrom()).strftime("%Y-%m-%d %H:%M") timeTo = datetime.utcfromtimestamp( booking.getTimeTo()).strftime("%Y-%m-%d %H:%M") room_bookings2.append({ 'booking': booking, 'room': room, 'building': building, 'campus': campus, 'timeFrom': timeFrom, 'timeTo': timeTo }) return render_template('session_view.html', data={ 'module': module, 'session': theSession, 'teachers': teachers, 'sessionTypes': session_types, 'roomBookings': room_bookings2, 'campuses': campuses, 'terms': term_list })