Esempio n. 1
0
    def GET(self):
        '''
            This function is called when the '/' page (index.html) is loaded
            If user is not logged in, they are redirected to the login page.
        '''
        if not session.validate_session():
            raise web.seeother('/login')
        else:
            current_ay_with_current_date = model.get_current_ay_sem()[0:8]
            current_database_ay = model.get_current_ay()

            to_migrate_db = False

            if current_ay_with_current_date != current_database_ay:
                to_migrate_db = True

            # [NOTE] for debugging purposes, comment out this line when done.
            # to_migrate_db = True

            return RENDER.index(need_migration=to_migrate_db)
Esempio n. 2
0
    def GET(self):
        '''
            This function is called when the database migration page is loaded
            If user is not logged in, they are redirected to the login page.
        '''
        if not session.validate_session():
            raise web.seeother('/login')
        else:
            current_ay_with_current_date = model.get_current_ay_sem()[0:8]
            current_database_ay = model.get_current_ay()

            if current_ay_with_current_date == current_database_ay:
                # pass # [NOTE] uncomment out this line for debugging purposes
                raise web.seeother(
                    "/")  # [NOTE] comment out this line for debugging purposes

            next_ay = model.get_next_ay(current_database_ay)
            future_ay = model.get_next_ay(next_ay)

            return RENDER.databaseMigrate(current_database_ay, next_ay,
                                          future_ay)
    def GET(self):
        '''
            Renders the modules page if users requested
            for the page through the GET method.
        '''
        if not session.validate_session():
            raise web.seeother('/login')

        input_data = model.validate_input(web.input(), ["aysem"],
                                          aysem_specific=False,
                                          attr_required=False)
        try:
            target_ay_sem = input_data.aysem
        except AttributeError:
            target_ay_sem = model.get_current_ay_sem()

        lst_of_mods = model.get_all_mods_taken_together(aysem=target_ay_sem)
        # Get a list of all AY-Sems (for users to select)
        all_ay_sems = model.get_all_ay_sems()

        return RENDER.overlappingModules(lst_of_mods, all_ay_sems,
                                         target_ay_sem)
    def GET(self):
        '''
            Renders the list of modules with specific class size page if users
            requested for the page through the GET method.
        '''
        if not session.validate_session():
            raise web.seeother('/login')

        input_data = model.validate_input(web.input(), ["aysem"],
                                          aysem_specific=False,
                                          attr_required=False)
        try:
            # Search request by user
            ay_sem_of_interest = input_data.aysem
            lower_range_class_size = input_data.lowerClassSize
            higher_range_class_size = input_data.higherClassSize
        except AttributeError:
            # Loading the page without sufficient data (first time load page)
            current_aysem = model.get_current_ay_sem()
            return RENDER.moduleSpecificSize(self.all_ay_sems, None,
                                             current_aysem, None, None)

        if not self.is_valid_range(lower_range_class_size,
                                   higher_range_class_size):
            return Outcome().POST("mods-specific-size-range", False, None)
        else:
            # All inputs are valid
            # Convert unicode to int
            lower_range = int(lower_range_class_size)
            higher_range = int(higher_range_class_size)

            list_of_mods = \
                model.get_mod_specified_class_size(ay_sem_of_interest, lower_range,
                                                   higher_range)

            return RENDER.moduleSpecificSize(self.all_ay_sems, list_of_mods,
                                             ay_sem_of_interest, lower_range,
                                             higher_range)
 def __init__(self):
     self.CURRENT_SEM = model.get_current_ay_sem()
     self.AVAILABLE_AY_SEM = model.get_all_ay_sems()
Esempio n. 6
0
    def GET(self, *test_data):
        '''
            Renders the oversubscribed modules page if users requested
            for the page through the GET method.
        '''
        if test_data:
            target_ay_sem = test_data[0]
        else:
            if not session.validate_session():
                raise web.seeother('/login')

            input_data = model.validate_input(web.input(), ["aysem"],
                                              aysem_specific=False,
                                              attr_required=False)
            try:
                target_ay_sem = input_data.aysem
            except AttributeError:
                target_ay_sem = model.get_current_ay_sem()

        all_ay_sems = model.get_all_ay_sems()

        #list_of_oversub_mod = model.get_oversub_mod()
        list_of_oversub_mod = []

        current_ay = model.get_current_ay()
        if target_ay_sem[0:8] == current_ay:

            fixed_mounting_handler = Fixed()
            fixed_mounting_handler.GET(to_render=False, logged_in=True)
            full_mounting_plan = fixed_mounting_handler.full_mounting_plan

            if target_ay_sem[9:15] == "Sem 1":
                for subplan in full_mounting_plan:
                    module_code = subplan[0]
                    module_name = subplan[1]
                    sem1_quota = subplan[4]
                    sem1_num_students = subplan[6]
                    if ((sem1_quota != '?' and sem1_quota != '-') \
                        and sem1_num_students > sem1_quota) \
                        or ((sem1_quota == '?' or sem1_quota == '-') and sem1_num_students > 0):
                        if sem1_quota == '?' or sem1_quota == '-':
                            oversub_amount = sem1_num_students
                        else:
                            oversub_amount = sem1_num_students - sem1_quota
                        list_of_oversub_mod.append(
                            (module_code, module_name, target_ay_sem,
                             sem1_quota, sem1_num_students, oversub_amount))

            else:
                for subplan in full_mounting_plan:
                    module_code = subplan[0]
                    module_name = subplan[1]
                    sem2_quota = subplan[5]
                    sem2_num_students = subplan[7]
                    if ((sem2_quota != '?' and sem2_quota != '-') \
                        and sem2_num_students > sem2_quota) \
                        or ((sem2_quota == '?' or sem2_quota == '-') and sem2_num_students > 0):
                        if sem2_quota == '?' or sem2_quota == '-':
                            oversub_amount = sem2_num_students
                        else:
                            oversub_amount = sem2_num_students - sem2_quota
                        list_of_oversub_mod.append(
                            (module_code, module_name, target_ay_sem,
                             sem2_quota, sem2_num_students, oversub_amount))

        else:
            tenta_mounting_handler = Tentative()
            tenta_mounting_handler.GET(to_render=False, logged_in=True)
            full_mounting_plan = tenta_mounting_handler.full_mounting_plan

            if target_ay_sem[9:15] == "Sem 1":
                for subplan in full_mounting_plan:
                    module_code = subplan[0]
                    module_name = subplan[1]
                    sem1_quota = subplan[4]
                    sem1_num_students = subplan[6]
                    if ((sem1_quota != '?' and sem1_quota != '-') \
                        and sem1_num_students > sem1_quota) \
                        or ((sem1_quota == '?' or sem1_quota == '-') and sem1_num_students > 0):
                        if sem1_quota == '?' or sem1_quota == '-':
                            oversub_amount = sem1_num_students
                        else:
                            oversub_amount = sem1_num_students - sem1_quota
                        list_of_oversub_mod.append(
                            (module_code, module_name, target_ay_sem,
                             sem1_quota, sem1_num_students, oversub_amount))

            else:
                for subplan in full_mounting_plan:
                    module_code = subplan[0]
                    module_name = subplan[1]
                    sem2_quota = subplan[5]
                    sem2_num_students = subplan[7]
                    if ((sem2_quota != '?' and sem2_quota != '-') \
                        and sem2_num_students > sem2_quota) \
                        or ((sem2_quota == '?' or sem2_quota == '-') and sem2_num_students > 0):
                        if sem2_quota == '?' or sem2_quota == '-':
                            oversub_amount = sem2_num_students
                        else:
                            oversub_amount = sem2_num_students - sem2_quota
                        list_of_oversub_mod.append(
                            (module_code, module_name, target_ay_sem,
                             sem2_quota, sem2_num_students, oversub_amount))

        if not test_data:
            return RENDER.oversubscribedModules(list_of_oversub_mod,
                                                all_ay_sems, target_ay_sem)
        else:
            return list_of_oversub_mod