Пример #1
0
 def checkprofessor(self, professorname):
     """Checks if the professor with the name passed as argument is already
     in the bank and, if it isn't, stores a new professor. After that,
     returns the Professor object. If the professor name is empty, there is
     a special entry in the bank for this case """
     professor = Professor.find(name_equal=professorname)
     if not professor:
         if not professorname:
             professor = Professor.find(name_equal=NO_PROFESSOR_STRING)[0]
         else:
             professor = Professor(professorname)
             professor.store()
     else:
         professor = professor[0]
     return professor
Пример #2
0
 def checkprofessor(self, professorname):
     """Checks if the professor with the name passed as argument is already
     in the bank and, if it isn't, stores a new professor. After that,
     returns the Professor object. If the professor name is empty, there is
     a special entry in the bank for this case """
     professor = Professor.find(name_equal=professorname)
     if not professor:
         if not professorname:
             professor = Professor.find(name_equal=NO_PROFESSOR_STRING)[0]
         else:
             professor = Professor(professorname)
             professor.store()
     else:
         professor = professor[0]
     return professor
Пример #3
0
 def tearDown(self):
     cursor = MySQLConnection()
     [offer.delete() for offer in Offer.find()]
     [schedule.delete() for schedule in Schedule.find()]
     cursor.execute('DELETE FROM minitableDayOfTheWeek')
     [timePeriod.delete() for timePeriod in TimePeriod.find()]
     [course.delete() for course in Course.find()]
     [professor.delete() for professor in Professor.find()]
     self.browser.quit()
Пример #4
0
 def tearDown(self):
     cursor = MySQLConnection()
     [offer.delete() for offer in Offer.find()]
     [schedule.delete() for schedule in Schedule.find()]
     cursor.execute('DELETE FROM minitableDayOfTheWeek')
     [timePeriod.delete() for timePeriod in TimePeriod.find()]
     [course.delete() for course in Course.find()]
     [professor.delete() for professor in Professor.find()]
     self.browser.quit()
Пример #5
0
 def updateForm(self):
     professors = Professor.find()
     professorName = [professor.name for professor in professors]
     professorIds = [professor.idProfessor for professor in professors]
     professorInfo = zip(professorIds, professorName)
     professorInfo = sorted(professorInfo, key=getKey)
     schedules = Schedule.find()
     scheduleName = schedules
     scheduleIds = [schedule.idSchedule for schedule in schedules]
     scheduleInfo = zip(scheduleIds, scheduleName)
     self.fields['dropDownProfessor'] = forms.ChoiceField(widget=forms.Select, choices=professorInfo, label = "Professor")
     self.fields['listSchedules'] = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=scheduleInfo, label = 'Horários')
Пример #6
0
 def test_edit_offer(self):
     timePeriod = TimePeriod.find()[0]
     course = Course.find()[0]
     first_professor = Professor.find()[0]
     schedules = Schedule.find()
     offer = Offer(timePeriod, course, 10, 0, first_professor)
     offer.setNumberOfRegistrations(10)
     offer.setSchedules(schedules)
     offer.store()
     open_page(self.browser, '/interface/offer/' + str(offer.idOffer),
               self.live_server_url)
     self.assertIn('Interface - Offer Detail', self.browser.title)
     button_edit = self.browser.find_element_by_name('editar')
     button_edit.click()
     self.assertIn('Interface - Offer Edit', self.browser.title)
     dropdown_professor = self.browser.find_element_by_id(
         'id_dropDownProfessor')
     select_professor = Select(dropdown_professor)
     select_professor.select_by_value(str(
         self.second_professor.idProfessor))
     input_classNumber = self.browser.find_element_by_id('id_classNumber')
     input_classNumber.send_keys('1')
     dropdown_practical = self.browser.find_element_by_id(
         'id_dropDownTeoricaPratica')
     select_practical = Select(dropdown_practical)
     select_practical.select_by_value('1')
     input_numberOfRegistrations = self.browser.find_element_by_id(
         'id_numberOfRegistrations')
     input_numberOfRegistrations.send_keys('1')
     self.browser.find_element_by_id("id_listSchedules_1").click()
     self.browser.find_element_by_id("id_listSchedules_2").click()
     button_apply = self.browser.find_element_by_name('Aplicar')
     button_apply.click()
     self.assertIn('Interface - Offer Detail', self.browser.title)
     id_courseCode = self.browser.find_element_by_id('courseCode')
     self.assertEqual(id_courseCode.text, 'tst9999')
     id_name = self.browser.find_element_by_id('name')
     self.assertEqual(id_name.text, 'teste9999')
     id_professor_name = self.browser.find_element_by_id('professor_name')
     self.assertEqual(id_professor_name.text, 'Professor Teste2')
     id_timePeriod = self.browser.find_element_by_id('timePeriod')
     self.assertEqual(id_timePeriod.text, 'Primeiro semestre de 2014')
     id_classNumber = self.browser.find_element_by_id('classNumber')
     self.assertEqual(id_classNumber.text, 'T101')
     id_practical = self.browser.find_element_by_id('practical')
     self.assertEqual(id_practical.text, "PRATICA")
     id_numberOfRegistrations = self.browser.find_element_by_id(
         'numberOfRegistrations')
     self.assertEqual(id_numberOfRegistrations.text, '101')
     id_schedules = self.browser.find_element_by_id('schedules')
     self.assertIn("Domingo 12:00 - 14:00", id_schedules.text)
     self.assertNotIn("Segunda 16:00 - 19:00", id_schedules.text)
     self.assertNotIn("Quarta 14:00 - 16:00", id_schedules.text)
Пример #7
0
    def getOffers(courseCode, idTimePeriod):
        """
         Returns the set of idOffers defined by this courseCode as is defined in expandCourse method.

        @param string courseCode : If it is a normal course this is not used, if this is a subgroup of a course, this courseCode is going to define the offers.Ex PTC3011(P)[ProfName] = only practical offers given by ProfName in course PTC3011.
        @param int idTimePeriod : The idTimePeriod of the wanted offer's timePeriod.
        @return  :
        @author
        """
        professor = None
        practical = None
        if courseCode.find('[') != -1:
            professorName = courseCode.rsplit('[')[1].rsplit(']')[0]
            professor = Professor.find(name_equal=professorName)[0]
            courseCode = courseCode.rsplit('[')[0] + courseCode.rsplit(']')[1]
        if courseCode.find('(') != -1:
            practical = courseCode.rsplit('(')[1].rsplit(')')[0]
            if practical == 'P':
                practical = True
            elif practical == 'T':
                practical = False
            else:
                raise ColumnsControllerError(
                    "The parameter given between the '()' must be equal to 'P' or 'T'."
                )
            courseCode = courseCode.rsplit('(')[0] + courseCode.rsplit(')')[1]

        course = Course.find(courseCode_equal=courseCode,
                             endDate_equal='0000-00-00')[0]
        timePeriod = TimePeriod.pickById(idTimePeriod)
        if professor and practical != None:
            offers = Offer.find(course=course,
                                practical=practical,
                                professor=professor,
                                timePeriod=timePeriod)
        elif professor:
            offers = Offer.find(course=course,
                                professor=professor,
                                timePeriod=timePeriod)
        elif practical != None:
            offers = Offer.find(course=course,
                                practical=practical,
                                timePeriod=timePeriod)
        else:
            offers = Offer.find(course=course, timePeriod=timePeriod)
        idOffers = [offer.idOffer for offer in offers]
        return idOffers
Пример #8
0
 def test_edit_offer(self):
     timePeriod = TimePeriod.find()[0]
     course = Course.find()[0]
     first_professor = Professor.find()[0]
     schedules = Schedule.find()
     offer = Offer(timePeriod, course, 10, 0, first_professor)
     offer.setNumberOfRegistrations(10)
     offer.setSchedules(schedules)
     offer.store()
     open_page(self.browser, '/interface/offer/' + str(offer.idOffer), self.live_server_url)
     self.assertIn('Interface - Offer Detail', self.browser.title)
     button_edit = self.browser.find_element_by_name('editar')
     button_edit.click()
     self.assertIn('Interface - Offer Edit', self.browser.title)
     dropdown_professor = self.browser.find_element_by_id('id_dropDownProfessor')
     select_professor = Select(dropdown_professor)
     select_professor.select_by_value(str(self.second_professor.idProfessor))
     input_classNumber = self.browser.find_element_by_id('id_classNumber')
     input_classNumber.send_keys('1')
     dropdown_practical = self.browser.find_element_by_id('id_dropDownTeoricaPratica')
     select_practical = Select(dropdown_practical)
     select_practical.select_by_value('1')
     input_numberOfRegistrations = self.browser.find_element_by_id('id_numberOfRegistrations')
     input_numberOfRegistrations.send_keys('1')
     self.browser.find_element_by_id("id_listSchedules_1").click()
     self.browser.find_element_by_id("id_listSchedules_2").click()
     button_apply = self.browser.find_element_by_name('Aplicar')
     button_apply.click()
     self.assertIn('Interface - Offer Detail', self.browser.title)
     id_courseCode = self.browser.find_element_by_id('courseCode')
     self.assertEqual(id_courseCode.text, 'tst9999')
     id_name = self.browser.find_element_by_id('name')
     self.assertEqual(id_name.text, 'teste9999')
     id_professor_name = self.browser.find_element_by_id('professor_name')
     self.assertEqual(id_professor_name.text, 'Professor Teste2')
     id_timePeriod = self.browser.find_element_by_id('timePeriod')
     self.assertEqual(id_timePeriod.text, 'Primeiro semestre de 2014')
     id_classNumber = self.browser.find_element_by_id('classNumber')
     self.assertEqual(id_classNumber.text, 'T101')
     id_practical = self.browser.find_element_by_id('practical')
     self.assertEqual(id_practical.text, "PRATICA")
     id_numberOfRegistrations = self.browser.find_element_by_id('numberOfRegistrations')
     self.assertEqual(id_numberOfRegistrations.text, '101')
     id_schedules = self.browser.find_element_by_id('schedules')
     self.assertIn("Domingo 12:00 - 14:00", id_schedules.text)
     self.assertNotIn("Segunda 16:00 - 19:00", id_schedules.text)
     self.assertNotIn("Quarta 14:00 - 16:00", id_schedules.text)
Пример #9
0
 def test_delete_offer(self):
     timePeriod = TimePeriod.find()[0]
     course = Course.find()[0]
     first_professor = Professor.find()[0]
     schedules = Schedule.find()
     offer = Offer(timePeriod, course, 10, 0, first_professor)
     offer.setNumberOfRegistrations(10)
     offer.setSchedules(schedules)
     offer.store()
     open_page(self.browser, '/interface/offer/' + str(offer.idOffer), self.live_server_url)
     self.assertIn('Interface - Offer Detail', self.browser.title)
     button_delete = self.browser.find_element_by_name('deletar')
     button_delete.click()
     alert = self.browser.switch_to.alert
     alert.accept()
     self.assertIn('Interface', self.browser.title)
     open_page(self.browser, '/interface/offer/' + str(offer.idOffer), self.live_server_url)
     self.assertNotIn('Interface - Offer Detail', self.browser.title)
     
Пример #10
0
 def test_delete_offer(self):
     timePeriod = TimePeriod.find()[0]
     course = Course.find()[0]
     first_professor = Professor.find()[0]
     schedules = Schedule.find()
     offer = Offer(timePeriod, course, 10, 0, first_professor)
     offer.setNumberOfRegistrations(10)
     offer.setSchedules(schedules)
     offer.store()
     open_page(self.browser, '/interface/offer/' + str(offer.idOffer),
               self.live_server_url)
     self.assertIn('Interface - Offer Detail', self.browser.title)
     button_delete = self.browser.find_element_by_name('deletar')
     button_delete.click()
     alert = self.browser.switch_to.alert
     alert.accept()
     self.assertIn('Interface', self.browser.title)
     open_page(self.browser, '/interface/offer/' + str(offer.idOffer),
               self.live_server_url)
     self.assertNotIn('Interface - Offer Detail', self.browser.title)
    def getOffers(courseCode, idTimePeriod):
        """
         Returns the set of idOffers defined by this courseCode as is defined in expandCourse method.

        @param string courseCode : If it is a normal course this is not used, if this is a subgroup of a course, this courseCode is going to define the offers.Ex PTC3011(P)[ProfName] = only practical offers given by ProfName in course PTC3011.
        @param int idTimePeriod : The idTimePeriod of the wanted offer's timePeriod.
        @return  :
        @author
        """
        professor = None
        practical = None
        if courseCode.find('[') != -1:
            professorName = courseCode.rsplit('[')[1].rsplit(']')[0]
            professor = Professor.find(name_equal = professorName)[0]
            courseCode = courseCode.rsplit('[')[0] + courseCode.rsplit(']')[1]
        if courseCode.find('(') != -1:
            practical = courseCode.rsplit('(')[1].rsplit(')')[0]
            if practical == 'P':
                practical = True
            elif practical == 'T':
                practical = False
            else:
                raise ColumnsControllerError("The parameter given between the '()' must be equal to 'P' or 'T'.")
            courseCode = courseCode.rsplit('(')[0] + courseCode.rsplit(')')[1]

        course = Course.find(courseCode_equal = courseCode, endDate_equal = '0000-00-00')[0]
        timePeriod = TimePeriod.pickById(idTimePeriod)
        if professor and practical != None:
            offers = Offer.find(course = course, practical = practical, professor = professor, timePeriod = timePeriod)
        elif professor:
            offers = Offer.find(course = course, professor = professor, timePeriod = timePeriod)
        elif practical != None:
            offers = Offer.find(course = course, practical = practical, timePeriod = timePeriod)
        else:
            offers = Offer.find(course = course, timePeriod = timePeriod)
        idOffers = [offer.idOffer for offer in offers]
        return idOffers
Пример #12
0
def professor(request):
    professors = Professor.find()
    rendered_page = render(request, 'professor.html',
                           {'professors': professors})
    return rendered_page
Пример #13
0
def professor(request):
    professors = Professor.find()
    rendered_page = render(request, 'professor.html', {'professors': professors})
    return rendered_page
Пример #14
0
 def tearDown(self):
     [professor.delete() for professor in Professor.find()]
     self.browser.quit()
Пример #15
0
 def tearDown(self):
     [professor.delete() for professor in Professor.find()]
     self.browser.quit()