Exemplo n.º 1
0
    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
        )
Exemplo n.º 2
0
    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
        )
Exemplo n.º 3
0
    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
        )
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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
        )
Exemplo n.º 6
0
    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
        )
Exemplo n.º 7
0
    def on_post(self, req, resp):
        id_number = req.get_json('id_number')
        user_type = req.get_json('user_type')
        username = req.get_json('username')
        password = req.get_json('password')
        first_name = req.get_json('first_name')
        middle_name = req.get_json('middle_name')
        last_name = req.get_json('last_name')
        age = req.get_json('age')
        birth_date = req.get_json('birth_date')

        # TODO: Add profile picture upload support.

        new_user = User(id_number, user_type, username, password, first_name,
                        middle_name, last_name, age, birth_date)
        db.Session.add(new_user)
        db.Session.commit()

        if user_type == 'admin':
            db.Session.add(Admin(new_user.user_id))
        elif user_type == 'teacher':
            db.Session.add(Teacher(new_user.user_id))
        else:  # Oh, it's a student then.
            db.Session.add(Student(new_user.user_id,
                                   1))  # Assume that it is a 7th grader.

        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_201,
            'Ignacio! Where is the damn internal code again?',
            'User created successfully',
            'New user {0} has been created.'.format(username))
Exemplo n.º 8
0
    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
        )
Exemplo n.º 9
0
    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
        )
Exemplo n.º 10
0
    def on_delete(self, req, resp):
        settings = db.Session.query(VariableSettings).one()

        db.Session.delete(settings)
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_200,
            'Ignacio! Where is the damn internal code again?',
            'Settings deleted successfully', 'Settings has been deleted.')
Exemplo n.º 11
0
    def on_post(self, req, resp):
        name = req.get_json('position_name')

        db.Session.add(TeacherPositionList(name))
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_201, 'Ignacio! Where is the damn internal code again?',
            'Teacher position created successfully', 'New position {0} has been created.'.format(name)
        )
Exemplo n.º 12
0
    def on_delete(self, req, resp):
        batch = db.Session.query(Batch).filter_by(
            batch_year=req.get_json('batch_year')).one()

        db.Session.delete(batch)
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_200,
            'Ignacio! Where is the damn internal code again?',
            'Batch year deleted successfully', 'Batch year has been deleted.')
Exemplo n.º 13
0
    def on_delete(self, req, resp):
        position = db.Session.query(TeacherPositionList)\
                             .filter_by(position_id=req.get_json('teacher_position_id')).one()

        db.Session.delete(position)
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code again?',
            'Position deleted successfully', 'Position {0} has been deleted.'.format(position.position_name)
        )
Exemplo n.º 14
0
    def on_post(self, req, resp):
        student_id = req.get_json('student_id')
        batch_year = req.get_json('batch_year')

        db.Session.add(StudentBatch(student_id, batch_year))
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_201, 'Ignacio! Where is the damn internal code again?',
            'Added new student batch year successfully', 'New batch year for {0} has been added.'.format(student_id)
        )
Exemplo n.º 15
0
    def on_post(self, req, resp):
        criterion_id = req.get_json('criterion_id')
        criterion_description = req.get_json('criterion_description')

        db.Session.add(StudentCharacterRatingCriteria(criterion_id, criterion_description))
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_201, 'Ignacio! Where is the damn internal code again?',
            'Added new criterion successfully', 'New criterion for {0} has been added.'.format(criterion_id)
        )
Exemplo n.º 16
0
    def on_delete(self, req, resp):
        user = db.Session.query(User).filter_by(
            user_id=req.get_json('user_id')).one()

        db.Session.delete(user)
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_200,
            'Ignacio! Where is the damn internal code again?',
            'User deleted successfully',
            'User {0} has been deleted.'.format(user.username))
Exemplo n.º 17
0
    def on_post(self, req, resp):
        teacher_id = req.get_json('teacher_id')
        position_id = req.get_json('teacher_position_id')
        school_year = req.get_json('school_year')

        db.Session.add(TeacherPosition(teacher_id, position_id, school_year))
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_201, 'Ignacio! Where is the damn internal code again?',
            'Teacher position created successfully', 'New position {0} has been created.'.format(position_id)
        )
Exemplo n.º 18
0
    def on_delete(self, req, resp):
        student_batch_year = db.Session.query(StudentStatus).filter_by(student_id=req.get_json('student_id'),
                                                                       batch_year=req.get_json('batch_year')
                                                                       ).one()
        db.Session.delete(student_batch_year)
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code again?',
            'Student batch year deleted successfully',
            'Batch year of student {0} has been deleted.'.format(req.get_json('student_id'))
        )
Exemplo n.º 19
0
    def on_delete(self, req, resp):
        section = db.Session.query(Section).filter_by(
            section_id=req.get_json('section_id')).one()

        db.Session.delete(section)
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_200,
            'Ignacio! Where is the damn internal code again?',
            'Section successfully',
            'Section {0} has been deleted.'.format(req.get_json('section_id')))
Exemplo n.º 20
0
    def on_post(self, req, resp):
        student_id = req.get_json('student_id')
        section_id = req.get_json('section_id')
        school_year = req.get_json('school_year')

        db.Session.add(StudentSection(student_id, section_id, school_year))
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_201, 'Ignacio! Where is the damn internal code again?',
            'Added new student section successfully', 'New section for {0} has been added.'.format(student_id)
        )
Exemplo n.º 21
0
    def on_delete(self, req, resp):
        student_month_days = db.Session.query(StudentStatus).filter_by(month_id=req.get_json('month'),
                                                                       school_year=req.get_json('school_year')
                                                                       ).one()
        db.Session.delete(student_month_days)
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code again?',
            'Month deleted successfully',
            'Month {0} has been deleted.'.format(student_month_days.month)
        )
Exemplo n.º 22
0
    def on_put(self, req, resp):
        student_month_days = db.Session.query(StudentStatus).filter_by(month=req.get_json('month'),
                                                                       school_year=req.get_json('school_year')
                                                                       ).one()
        student_month_days.required_days = req.get_json('required_days').strip()
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code again?',
            'Required days for a month updated successfully',
            'Required days of month {0} has been updated.'.format(student_month_days.month)
        )
Exemplo n.º 23
0
    def on_post(self, req, resp):
        month = req.get_json('month')
        school_year = req.get_json('school_year')
        days_required = req.get_json('days_required')

        db.Session.add(StudentMonthlyRequiredDays(month, school_year, days_required))
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_201, 'Ignacio! Where is the damn internal code again?',
            'Added new monthly required days successfully', 'New required days has been added.'
        )
Exemplo n.º 24
0
    def on_post(self, req, resp):
        batch_year = req.get_json('batch_year')
        school_year = req.get_json('school_year')
        advisor_id = req.get_json('teacher_id')

        db.Session.add(BatchAdvisor(batch_year, school_year, advisor_id))
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_201,
            'Ignacio! Where is the damn internal code again?',
            'Added new batch advisor successfully',
            'New batch advisor has been added.')
Exemplo n.º 25
0
    def on_delete(self, req, resp):
        subject = db.Session.query(StudentSubject).filter_by(student_id=req.get_json('student_id'),
                                                             subject_id=req.get_json('subject_id'),
                                                             school_year=req.get_json('school_year')
                                                             ).one()
        db.Session.delete(subject)
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code again?',
            'Student subject deleted successfully',
            'Subject of student {0} has been deleted.'.format(req.get_json('student_id'))
        )
Exemplo n.º 26
0
    def on_post(self, req, resp):
        student_id = req.get_json('student_id')
        gwa = req.get_json('gwa')
        quarter = req.get_json('quarter')
        school_year = req.get_json('school_year')

        db.Session.add(StudentGWA(student_id, gwa, quarter, school_year))
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_201, 'Ignacio! Where is the damn internal code again?',
            'Added new student GWA successfully', 'New GWA for {0} has been added.'.format(student_id)
        )
Exemplo n.º 27
0
    def on_delete(self, req, resp):
        criterion = db.Session.query(StudentCharacterRatingCriteria).filter_by(
            criterion_id=req.get_json('criterion_id')
        ).one()

        db.Session.delete(criterion)
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code again?',
            'Criterion deleted successfully',
            'Criterion has been deleted.'.format(req.get_json('student_id'))
        )
Exemplo n.º 28
0
    def on_put(self, req, resp):
        grade = 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'),
                                                                       quarter=req.get_json('quarter')
                                                                       ).one()
        grade.grade = req.get_json('grade').strip()
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code again?',
            'Student status updated successfully',
            'Status of student {0} has been updated.'.format(grade.student_id)
        )
Exemplo n.º 29
0
    def on_post(self, req, resp):
        student_id = req.get_json('student_id')
        subject_id = req.get_json('subject_id')
        school_year = req.get_json('school_year')
        quarter = req.get_json('quarter')
        grade = req.get_json('grade')

        db.Session.add(StudentSubjectGrade(student_id, subject_id, school_year, quarter, grade))
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_201, 'Ignacio! Where is the damn internal code again?',
            'Added new student subject grade successfully', 'New grade for {0} has been added.'.format(student_id)
        )
Exemplo n.º 30
0
    def on_delete(self, req, resp):
        student_status = db.Session.query(StudentStatus).filter_by(student_id=req.get_json('student_id'),
                                                                   quarter=req.get_json('quarter'),
                                                                   year_level=req.get_json('year_level'),
                                                                   school_year=req.get_json('school_year')
                                                                   ).one()
        db.Session.delete(student_status)
        db.Session.commit()

        response.set_successful_response(
            resp, falcon.HTTP_200, 'Ignacio! Where is the damn internal code again?',
            'Student status deleted successfully',
            'Status of student {0} has been deleted.'.format(req.get_json('student_id'))
        )