def render_student(self, student="", student_id="", error="No Errors!"): ''' Method to render the main page for department''' students = ndb.gql("SELECT * FROM Student\ ORDER BY student_id") values = { 'students': students, 'error': error, 'student_id': student_id } self.response.out.write(template.render('student.html', values))
def render_main(self, department="", dept_id="", error="No Errors!"): ''' Method to render the main page for department''' department = ndb.gql("SELECT * FROM Department\ ORDER BY department_id") data = {} for depts in department: data[depts.department_id] = depts.name print 'JSON: ', data values = { 'department': department, 'error': error, 'dept_id': dept_id, 'jsonData': data } self.response.out.write(template.render('main.html', values))
def render_coursepage(self, courses="", error="", course_id=""): ''' Method to render course dashboard page''' courses = ndb.gql("SELECT * FROM Course\ ORDER BY course_id") # packaging into json object for <iteration 2> API Backend jsonData = {} for course in courses: jsonData['course.course_id'] = course.name values = { 'courses': courses, 'error': error, 'course_id': course_id, 'jsonData': jsonData } self.response.out.write(template.render('course.html', values))
def render_enrollments(self, error="", enrollment=""): ''' render Enrollments dashboard page''' enrollments = ndb.gql("SELECT * FROM Enrollment") enroll_info = list() record = dict() for enrollment in enrollments: record = { 'schedule': enrollment.schedule.get(), 'student': enrollment.student.get(), 'e_key': enrollment.key } #print enrollment enroll_info.append([record]) values = {'enrollments': enroll_info, 'error': error} self.response.out.write(template.render('enrollments.html', values))
def render_schedule(self, schedule="", error=""): ''' Schedule dashboard page''' schedule = ndb.gql("SELECT * FROM Schedule\ ORDER BY year") values = {'schedules': schedule, 'error': error} self.response.out.write(template.render("schedule.html", values))