Exemplo n.º 1
0
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
                           })
Exemplo n.º 2
0
def List(student_id):
    """Returns all modules for given student."""
    # Verify user access
    if not Authorization.canAccess(session.get('user'), ('scheduling_admin')):
        return render_template('error/no_access.html')

    student = StudentModel.findById(student_id)

    if not student:
        return render_template('error/resource_not_found.html')

    module_enrolments = StudentModuleModel.findBy('student', student_id)
    modules = []
    module_id = []

    for enrolment in module_enrolments:
        Module = ModuleModel.findById(enrolment.getModule())
        modules.append(Module)
        module_id.append(Module.getId())

    AllModules = ModuleModel.all()
    Available_Modules = []

    for module in AllModules:
        if module.getId() not in module_id:
            Available_Modules.append(module)

    # get student timetable
    timetable = Timetable.getStudentTimetable(student_id,
                                              Timetable.getStartOfMonth(),
                                              Timetable.getEndOfMonth())

    return render_template('enrolment_list.html',
                           data={
                               "enroled_modules": modules,
                               "available_modules": Available_Modules,
                               "student": student,
                               "timetable": timetable
                           })