def get(self, request, *args, **kwargs): if not self.allow_unauthenticated and not request.user.is_authenticated: return HttpResponseRedirect("/") self.school = request.subdomain self.student = get_student(request) feature_flow = self.get_feature_flow(request, *args, **kwargs) # take semester provided by feature flow if available, otherwise the first available sem all_semesters = get_current_semesters(self.school) if "semester" in feature_flow: sem = feature_flow.pop("semester") sem_dict = {"name": sem.name, "year": sem.year} if sem_dict not in all_semesters: all_semesters.append(sem_dict) curr_sem_index = all_semesters.index(sem_dict) else: curr_sem_index = 0 sem = Semester.objects.get(**all_semesters[curr_sem_index]) integrations = [] if self.student and self.student.user.is_authenticated: self.student.school = self.school self.student.save() for i in self.student.integrations.all(): integrations.append(i.name) final_exams = [] if SCHOOLS_MAP[self.school].final_exams is None: final_exams = [] else: for year, terms in SCHOOLS_MAP[self.school].final_exams.items(): for term in terms: final_exams.append({"name": term, "year": str(year)}) init_data = { "school": self.school, "currentUser": get_student_dict(self.school, self.student, sem), "currentSemester": curr_sem_index, "allSemesters": all_semesters, # 'oldSemesters': get_old_semesters(self.school), "uses12HrTime": SCHOOLS_MAP[self.school].ampm, "studentIntegrations": integrations, "latestAgreement": AgreementSerializer(Agreement.objects.latest()).data, "registrar": SCHOOLS_MAP[self.school].registrar, "examSupportedSemesters": list(map(all_semesters.index, final_exams)), "timeUpdatedTos": Agreement.objects.latest().last_updated.isoformat(), "featureFlow": dict(feature_flow, name=self.feature_name), } return render(request, "timetable.html", {"init_data": json.dumps(init_data)})
def get(self, request, *args, **kwargs): if not self.allow_unauthenticated and not request.user.is_authenticated: return HttpResponseRedirect('/') self.school = request.subdomain self.student = get_student(request) feature_flow = self.get_feature_flow(request, *args, **kwargs) # take semester provided by feature flow if available, otherwise the first available sem all_semesters = get_current_semesters(self.school) if 'semester' in feature_flow: sem = feature_flow.pop('semester') sem_dict = {'name': sem.name, 'year': sem.year} if sem_dict not in all_semesters: all_semesters.append(sem_dict) curr_sem_index = all_semesters.index(sem_dict) else: curr_sem_index = 0 sem = Semester.objects.get(**all_semesters[curr_sem_index]) integrations = [] if self.student and self.student.user.is_authenticated: self.student.school = self.school self.student.save() for i in self.student.integrations.all(): integrations.append(i.name) final_exams = [] if SCHOOLS_MAP[self.school].final_exams is None: final_exams = [] else: for year, terms in SCHOOLS_MAP[self.school].final_exams.items(): for term in terms: final_exams.append({'name': term, 'year': str(year)}) init_data = { 'school': self.school, 'currentUser': get_student_dict(self.school, self.student, sem), 'currentSemester': curr_sem_index, 'allSemesters': all_semesters, # 'oldSemesters': get_old_semesters(self.school), 'uses12HrTime': SCHOOLS_MAP[self.school].ampm, 'studentIntegrations': integrations, 'latestAgreement': AgreementSerializer(Agreement.objects.latest()).data, 'registrar': SCHOOLS_MAP[self.school].registrar, 'examSupportedSemesters': list(map(all_semesters.index, final_exams)), 'timeUpdatedTos': Agreement.objects.latest().last_updated.isoformat(), 'featureFlow': dict(feature_flow, name=self.feature_name) } return render(request, 'timetable.html', {'init_data': json.dumps(init_data)})
def get(self, request, *args, **kwargs): self.school = request.subdomain self.student = get_student(request) feature_flow = self.get_feature_flow(request, *args, **kwargs) # take semester provided by feature flow if available, otherwise the first available sem all_semesters = get_current_semesters(self.school) if 'semester' in feature_flow: sem = feature_flow.pop('semester') sem_dict = {'name': sem.name, 'year': sem.year} if sem_dict not in all_semesters: all_semesters.append(sem_dict) curr_sem_index = all_semesters.index(sem_dict) else: curr_sem_index = 0 sem = Semester.objects.get(**all_semesters[curr_sem_index]) integrations = [] if self.student and self.student.user.is_authenticated(): self.student.school = self.school self.student.save() for i in self.student.integrations.all(): integrations.append(i.name) final_exams = [] if SCHOOLS_MAP[self.school].final_exams is None: final_exams = [] else: for year, terms in SCHOOLS_MAP[self.school].final_exams.items(): for term in terms: final_exams.append({ 'name': term, 'year': str(year) }) init_data = { 'school': self.school, 'currentUser': get_student_dict(self.school, self.student, sem), 'currentSemester': curr_sem_index, 'allSemesters': all_semesters, # 'oldSemesters': get_old_semesters(self.school), 'uses12HrTime': SCHOOLS_MAP[self.school].ampm, 'studentIntegrations': integrations, 'examSupportedSemesters': map(all_semesters.index, final_exams), 'timeUpdatedTos': Agreement.objects.latest().last_updated.isoformat(), 'featureFlow': dict(feature_flow, name=self.feature_name) } return render(request, 'timetable.html', {'init_data': json.dumps(init_data)})
def setUp(self): self.img_dir = os.path.dirname(os.path.realpath(__file__)) + '/test_failures' self.init_screenshot_dir() self.driver = webdriver.Chrome(chrome_options=self.chrome_options) sem = get_current_semesters('jhu')[0] sem, _ = Semester.objects.update_or_create(name=sem['name'], year=sem['year']) for section in Section.objects.filter(semester__name="Fall", semester__year=2017): section.semester = sem section.save() self.current_sem = sem self.driver.get(self.get_test_url('jhu')) WebDriverWait(self.driver, self.TIMEOUT) \ .until(lambda driver: driver.find_element_by_tag_name('body'))
def setUp(self): self.img_dir = os.path.dirname(os.path.realpath(__file__)) + '/test_failures' self.init_screenshot_dir() self.driver = webdriver.Chrome(chrome_options=self.chrome_options) sem = get_current_semesters('jhu')[0] sem, _ = Semester.objects.update_or_create(name=sem['name'], year=sem['year']) for section in Section.objects.filter(semester__name="Fall", semester__year=2017): section.semester = sem section.save() self.current_sem = sem self.driver.get(self.get_test_url('jhu')) WebDriverWait(self.driver, self.TIMEOUT) \ .until(lambda driver: driver.find_element_by_tag_name('body'))
def setUp(self): self.img_dir = os.path.dirname( os.path.realpath(__file__)) + "/test_failures" self.init_screenshot_dir() self.driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=self.chrome_options) sem = get_current_semesters("jhu")[0] sem, _ = Semester.objects.update_or_create(name=sem["name"], year=sem["year"]) for section in Section.objects.filter(semester__name="Fall", semester__year=2017): section.semester = sem section.save() self.current_sem = sem self.driver.get(self.get_test_url("jhu")) WebDriverWait(self.driver, self.TIMEOUT).until( lambda driver: driver.find_element_by_tag_name("body"))
def get(self, request, *args, **kwargs): self.school = request.subdomain self.student = get_student(request) feature_flow = self.get_feature_flow(request, *args, **kwargs) # take semester provided by feature flow if available, otherwise the first available sem all_semesters = get_current_semesters(self.school) if 'semester' in feature_flow: sem = feature_flow.pop('semester') sem_dict = {'name': sem.name, 'year': sem.year} if sem_dict not in all_semesters: all_semesters.append(sem_dict) curr_sem_index = all_semesters.index(sem_dict) else: curr_sem_index = 0 sem = Semester.objects.get(**all_semesters[curr_sem_index]) integrations = [] if self.student and self.student.user.is_authenticated(): self.student.school = self.school self.student.save() for i in self.student.integrations.all(): integrations.append(i.name) init_data = { 'school': self.school, 'currentUser': get_student_dict(self.school, self.student, sem), 'currentSemester': curr_sem_index, 'allSemesters': all_semesters, 'oldSemesters': get_old_semesters(self.school), 'uses12HrTime': self.school in AM_PM_SCHOOLS, 'studentIntegrations': integrations, 'examSupportedSemesters': map(all_semesters.index, final_exams_available.get(self.school, [])), 'timeUpdatedTos': Agreement.objects.latest().last_updated.isoformat(), 'featureFlow': dict(feature_flow, name=self.feature_name) } return render(request, 'timetable.html', {'init_data': json.dumps(init_data)})
def change_to_current_term(self, clear_alert=False): sem = get_current_semesters('jhu')[0] self.change_term("%s %s" % (sem['name'], sem['year']), clear_alert=clear_alert)
def change_to_current_term(self, clear_alert=False): sem = get_current_semesters('jhu')[0] self.change_term("%s %s" % (sem['name'], sem['year']), clear_alert=clear_alert)
def change_to_current_term(self, clear_alert=False): sem = get_current_semesters("jhu")[0] self.change_term("%s %s" % (sem["name"], sem["year"]), clear_alert=clear_alert)