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 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)})