def on_get(self, req, resp): data = dict() data['month_days'] = dict() if req.get_json('school_year') == '__all__': years = StudentMonthlyRequiredDays.query.order_by(StudentMonthlyRequiredDays.school_year.desc()).all() row_ctr = 0 for year in years: data['month_days'][row_ctr] = dict() for scope in req.scope: try: data['month_days'][row_ctr][scope] = getattr(year, scope) except AttributeError: raise APIUnprocessableEntityError('Invalid scope \'{0}\''.format(scope), 'Scope is not part of the rating criteria.') row_ctr += 1 else: year = db.Session.query(StudentMonthlyRequiredDays).filter_by( school_year=req.get_json('school_year') ).one() data['month_days'] = dict() for scope in req.scope: try: data['month_days'][scope] = getattr(year, scope) except AttributeError: raise APIUnprocessableEntityError('Invalid scope \'{0}\''.format(scope), 'Scope is not part of the criteria.') response.set_successful_response( resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code?', 'Successful monthly required days retrieval', 'Monthly required days successfully gathered.', data )
def on_get(self, req, resp): data = dict() data['rating_criteria'] = dict() if req.get_json('criterion_id') == '__all__': criteria = StudentCharacterRatingCriteria.query.all() row_ctr = 0 for criterion in criteria: data['rating_criteria'][row_ctr] = dict() for scope in req.scope: try: data['rating_criteria'][row_ctr][scope] = getattr(criterion, scope) except AttributeError: raise APIUnprocessableEntityError('Invalid scope \'{0}\''.format(scope), 'Scope is not part of the rating criteria.') row_ctr += 1 else: criterion = db.Session.query(StudentCharacterRatingCriteria).filter_by( criterion_id=req.get_json('criterion_id') ).one() data['rating_criteria'] = dict() for scope in req.scope: try: data['rating_criteria'][scope] = getattr(criterion, scope) except AttributeError: raise APIUnprocessableEntityError('Invalid scope \'{0}\''.format(scope), 'Scope is not part of the criteria.') response.set_successful_response( resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code?', 'Successful rating criteria retrieval', 'Rating criteria successfully gathered.', data )
def on_get(self, req, resp): data = dict() data['teacher'] = dict() if req.get_json('teacher_id') == '__all__': teachers = User.query.filter_by(user_type='teacher').all().order_by(User.last_name.asc(), User.first_name.asc(), User.middle_name.asc(), User.id_number.asc()) row_ctr = 0 for teacher in teachers: data['teacher'][row_ctr] = dict() for scope in req.scope: try: data['teacher'][row_ctr][scope] = getattr(teacher, scope) except AttributeError: raise APIUnprocessableEntityError('Invalid scope \'{0}\''.format(scope), 'Scope is not part of the teacher.') row_ctr += 1 else: teacher = db.Session.query(Teacher).filter_by(teacher_id=req.get_json('teacher_id')).one() data['teacher'] = dict() for scope in req.scope: try: data['teacher'][scope] = getattr(teacher, scope) except AttributeError: raise APIUnprocessableEntityError('Invalid scope \'{0}\''.format(scope), 'Scope is not part of the teacher.') response.set_successful_response( resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code?', 'Successful teacher data retrieval', 'Teacher data successfully gathered.', data )
def on_get(self, req, resp): data = dict() data['student'] = dict() if req.get_json('student_id') == '__all__': students = Student.query.all() row_ctr = 0 for student in students: data['student'][row_ctr] = dict() for scope in req.scope: try: data['student'][row_ctr][scope] = getattr(student, scope) except AttributeError: raise APIUnprocessableEntityError('Invalid scope \'{0}\''.format(scope), 'Scope is not part of the student.') row_ctr += 1 else: student = db.Session.query(Student).filter_by(student_id=req.get_json('student_id')).one() data['student'] = dict() for scope in req.scope: try: data['student'][scope] = getattr(student, scope) except AttributeError: raise APIUnprocessableEntityError('Invalid scope \'{0}\''.format(scope), 'Scope is not part of the student.') response.set_successful_response( resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code?', 'Successful student data retrieval', 'Student data successfully gathered.', data )
def on_get(self, req, resp): data = dict() data['teacher_position'] = dict() if req.get_json('teacher_position_id') == '__all__': positions = TeacherPositionList.query.all() position_ctr = 0 for position in positions: data['teacher_position'][position_ctr] = dict() for scope in req.scope: try: data['teacher_position'][position_ctr][scope] = getattr(position, scope) except AttributeError: raise APIUnprocessableEntityError('Invalid scope \'{0}\''.format(scope), 'Scope is not part of the user.') position_ctr += 1 else: position = db.Session.query(TeacherPositionList).filter_by(position_id=req.get_json('id')).one() data['teacher_position'] = dict() for scope in req.scope: try: data['teacher_position'][scope] = getattr(position, scope) except AttributeError: raise APIUnprocessableEntityError('Invalid scope \'{0}\''.format(scope), 'Scope is not part of the user.') response.set_successful_response( resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code?', 'Successful teacher position retrieval', 'Teacher position successfully gathered.', data )
def on_get(self, req, resp): data = dict() data['user'] = dict() if req.get_json('user_id') == '__all__': users = db.Session.query(User).all().order_by( User.last_name.asc(), User.first_name.asc(), User.middle_name.asc(), User.id_number.asc()) user_ctr = 0 for user in users: data['user'][user_ctr] = dict() for scope in req.scope: try: if scope == 'birth_date': data['user'][user_ctr][ scope] = user.birth_date.strftime( '%Y-%m-%d %H:%M:%S.%f') else: data['user'][user_ctr][scope] = getattr( user, scope) except AttributeError: raise APIUnprocessableEntityError( 'Invalid scope \'{0}\''.format(scope), 'Scope is not part of the user.') user_ctr += 1 else: user = db.Session.query(User).filter_by( user_id=req.get_json('user_id')).one() data['user'] = dict() for scope in req.scope: try: if scope == 'birth_date': data['user'][scope] = user.birth_date.strftime( '%Y-%m-%d %H:%M:%S.%f') else: data['user'][scope] = getattr(user, scope) except AttributeError: raise APIUnprocessableEntityError( 'Invalid scope \'{0}\''.format(scope), 'Scope is not part of the user.') response.set_successful_response( resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code?', 'Successful user data retrieval', 'User data successfully gathered.', data)
def on_get(self, req, resp): grades = db.Session.query(StudentSubjectPendingGrade).filter_by( student_id=req.get_json('student_id'), subject_id=req.get_json('subject_id'), school_year=req.get_json('school_year') ).order_by(StudentSubjectPendingGrade.quarter.desc()) quarter_ctr = 0 data = dict() data['student'] = dict() for grade in grades: data['student'][quarter_ctr] = dict() for scope in req.scope: try: data['student'][quarter_ctr][scope] = getattr(grade, scope) except AttributeError: raise APIUnprocessableEntityError('Invalid scope \'{0}\''.format(scope), 'Scope is not part of the user.') quarter_ctr += 1 response.set_successful_response( resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code?', 'Successful student subject grades retrieval', 'Subject grades successfully gathered.', data )
def on_get(self, req, resp): monthly_attendances = db.Session.query(StudentMonthlyAttendance).filter_by( student_id=req.get_json('student_id') ).order_by(StudentMonthlyAttendance.school_year.desc(), StudentMonthlyAttendance.quarter.desc(), StudentMonthlyAttendance.month.desc()).all() row_ctr = 0 data = dict() data['student'] = dict() for monthly_attendance in monthly_attendances: data['student'][row_ctr] = dict() for scope in req.scope: try: data['student'][row_ctr][scope] = getattr(monthly_attendance, scope) except AttributeError: raise APIUnprocessableEntityError('Invalid scope \'{0}\''.format(scope), 'Scope is not part of the student monthly attendance.') row_ctr += 1 response.set_successful_response( resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code?', 'Successful student attendance retrieval', 'Attendance successfully gathered.', data )
def on_get(self, req, resp): data = dict() year_advisors = db.Session.query(BatchAdvisor).filter_by( advisor=req.get_json('teacher_id')).all().order_by( BatchAdvisor.batch_year.desc(), BatchAdvisor.school_year.desc()) data = dict() data['batch'] = dict() ctr = 0 for year_advisor in year_advisors: data['batch'][ctr] = dict() for scope in req.scope: try: data['batch'][ctr][scope] = getattr(year_advisor, scope) except AttributeError: raise APIUnprocessableEntityError( 'Invalid scope \'{0}\''.format(scope), 'Scope is not part of the student.') response.set_successful_response( resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code?', 'Successful batch advisor data retrieval', 'Batch advisor data successfully gathered.', data)
def on_get(self, req, resp): data = dict() data['admin'] = dict() if req.get_json('admin_id') == '__all__': admins = db.Session.query(User).filter_by( user_type='admin').order_by(User.last_name.asc(), User.first_name.asc(), User.middle_name.asc(), User.id_number.asc()).all() row_ctr = 0 for admin in admins: data['admin'][row_ctr] = dict() for scope in req.scope: try: if scope == 'birth_date': data['admin'][row_ctr][scope] = getattr( admin, scope).strftime('%B %d, %Y') else: data['admin'][row_ctr][scope] = getattr( admin, scope) except AttributeError: raise APIUnprocessableEntityError( 'Invalid scope \'{0}\''.format(scope), 'Scope is not part of the admin.') row_ctr += 1 else: admin = db.Session.query(Admin).filter_by( admin_id=req.get_json('admin_id')).one() data['admin'] = dict() for scope in req.scope: try: data['admin'][scope] = getattr(admin, scope) except AttributeError: raise APIUnprocessableEntityError( 'Invalid scope \'{0}\''.format(scope), 'Scope is not part of the admin.') response.set_successful_response( resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code?', 'Successful admin data retrieval', 'Admin data successfully gathered.', data)
def on_get(self, req, resp): data = dict() data['batch'] = dict() if req.get_json('batch_year') == '__all__': batches = Batch.query.all() batch_ctr = 0 for batch in batches: data['batch'][batch_ctr] = dict() for scope in req.scope: try: data['batch'][batch_ctr][scope] = getattr(batch, scope) except AttributeError: raise APIUnprocessableEntityError( 'Invalid scope \'{0}\''.format(scope), 'Scope is not part of the student.') batch_ctr += 1 else: retrieved_batch = db.Session.query(Batch).filter_by( batch_year=req.get_json('batch_year')).one() data['batch'] = dict() for scope in req.scope: try: data['student'][scope] = getattr(retrieved_batch, scope) except AttributeError: raise APIUnprocessableEntityError( 'Invalid scope \'{0}\''.format(scope), 'Scope is not part of the student.') response.set_successful_response( resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code?', 'Successful batch data retrieval', 'Batch data successfully gathered.', data)
def on_get(self, req, resp): data = dict() data['section'] = dict() if req.get_json('section_id') == '__all__': sections = db.Session.query(Section).order_by( Section.year_level.asc(), Section.section_name.asc()) section_ctr = 0 for section in sections: data['section'][section_ctr] = dict() for scope in req.scope: try: data['section'][section_ctr][scope] = getattr( section, scope) except AttributeError: raise APIUnprocessableEntityError( 'Invalid scope \'{0}\''.format(scope), 'Scope is not part of the user.') section_ctr += 1 else: section = db.Session.query(Section).filter_by( section_id=req.get_json('section_id')).one() data['section'] = dict() for scope in req.scope: try: data['section'][scope] = getattr(section, scope) except AttributeError: raise APIUnprocessableEntityError( 'Invalid scope \'{0}\''.format(scope), 'Scope is not part of the user.') response.set_successful_response( resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code?', 'Successful section data retrieval', 'Section data successfully gathered.', data)
def on_get(self, req, resp): setting = db.Session.query(VariableSettings).one() data = dict() data['setting'] = dict() for scope in req.scope: try: data['setting'][scope] = getattr(setting, scope) except AttributeError: raise APIUnprocessableEntityError( 'Invalid scope \'{0}\''.format(scope), 'Scope is not part of the user.') response.set_successful_response( resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code?', 'Successful settings retrieval', 'Settings successfully gathered.', data)
def on_get(self, req, resp): admin = db.Session.query(User).filter_by( username=req.get_json('username')).one() data = dict() data['admin'] = dict() for scope in req.scope: try: data['admin'][scope] = getattr(admin, scope) except AttributeError: raise APIUnprocessableEntityError( 'Invalid scope \'{0}\''.format(scope), 'Scope is not part of the teacher.') response.set_successful_response( resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code?', 'Successful admin data retrieval', 'Admin data successfully gathered.', data)
def on_get(self, req, resp): years = db.Session.query(StudentBatch).filter_by( student_id=req.get_json('student_id') ).order_by(StudentBatch.batch_year.desc()).all() year_ctr = 0 data = dict() data['student'] = dict() for year in years: data['student'][year_ctr] = dict() for scope in req.scope: try: data['student'][year_ctr][scope] = getattr(year, scope) except AttributeError: raise APIUnprocessableEntityError('Invalid scope \'{0}\''.format(scope), 'Scope is not part of the user.') year_ctr += 1 response.set_successful_response( resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code?', 'Successful student batch years retrieval', 'Batch years successfully gathered.', data )
def on_get(self, req, resp): positions = db.Session.query(TeacherPosition).filter_by( teacher_id=req.get_json('teacher_id') ).order_by(TeacherPosition.school_year.desc(), TeacherPosition.date_created.desc()).all() position_ctr = 0 data = dict() data['teacher'] = dict() for position in positions: data['teacher'][position_ctr] = dict() for scope in req.scope: try: data['teacher'][position_ctr][scope] = getattr(position, scope) except AttributeError: raise APIUnprocessableEntityError('Invalid scope \'{0}\''.format(scope), 'Scope is not part of the user.') position_ctr += 1 response.set_successful_response( resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code?', 'Successful teacher positions retrieval', 'Teacher positions successfully gathered.', data )