Exemplo n.º 1
0
                                           day):
                            answer['failed'].append(exam)
            return make_response(jsonify(answer), 200)
        except BaseException as e:
            app.logger.warning('ExamsApi post: {}'.format(str(e)))
            return make_response(jsonify(self.error["postFail"]), 400)

    @jwt_required()
    def delete(self, organization, faculty, group):
        # Delete the entire exams
        try:
            with ScheduleDB(app.config) as db:
                db_data = db.get_group(organization, faculty, group)

            if db_data is None:
                return make_response(jsonify(self.error["unknownGroup"]), 400)

            tag = db_data[1]

            with ScheduleDB(app.config) as db:
                db.delete_exams(tag)

            return make_response(jsonify({}), 200)
        except BaseException as e:
            app.logger.warning('ExamsApi delete: {}'.format(str(e)))
            return make_response(jsonify(self.error["deleteFail"]), 400)


bp.add_url_rule('/<organization>/<faculty>/<group>/exams',
                view_func=ExamsApi.as_view('exams_api'))
Exemplo n.º 2
0
        pet.received_date = received_date
        pet.save()
        response = {'result': 'ok', 'pet': pet_obj(pet)}
        return jsonify(response), 200

    def delete(self, pet_id):
        pet = Pet.objects.filter(external_id=pet_id).first()
        if not pet:
            return jsonify({}), 404
        pet.live = False
        pet.save()
        return jsonify({}), 204


pet_view = PetApi.as_view('pet_api')
bp.add_url_rule('/pets/',
                defaults={'pet_id': None},
                view_func=pet_view,
                methods=[
                    'GET',
                ])
bp.add_url_rule('/pets/', view_func=pet_view, methods=['POST'])

bp.add_url_rule('/pets/<pet_id>',
                view_func=pet_view,
                methods=[
                    'GET',
                    'PUT',
                    'DELETE',
                ])
Exemplo n.º 3
0
                                             classroom, lecturer):
                            answer['failed'].append(lecture)
            return make_response(jsonify(answer), 200)
        except BaseException as e:
            app.logger.warning('ScheduleApi post: {}'.format(str(e)))
            return make_response(jsonify(self.error["postFail"]), 400)

    @jwt_required()
    def delete(self, organization, faculty, group):
        # Delete the entire schedule
        try:
            with ScheduleDB(app.config) as db:
                db_data = db.get_group(organization, faculty, group)

            if db_data is None:
                return make_response(jsonify(self.error["unknownGroup"]), 400)

            tag = db_data[1]

            with ScheduleDB(app.config) as db:
                db.delete_schedule(tag)

            return make_response(jsonify({}), 200)
        except BaseException as e:
            app.logger.warning('ScheduleApi delete: {}'.format(str(e)))
            return make_response(jsonify(self.error["deleteFail"]), 400)


bp.add_url_rule('/<organization>/<faculty>/<group>/schedule',
                view_func=ScheduleApi.as_view('schedule_api'))
Exemplo n.º 4
0
        if not app:
            error = {'code': 'INVALID_CREDENTIALS'}
            return jsonify({'error': error}), 400
        else:
            if bcrypt.check_password_hash(app.app_secret,
                                          request.json['app_secret']):
                tokens = Access.objects.filter(app=app)
                tokens.delete()
                token = str(uuid.uuid4())
                now = datetime.utcnow()
                expires = now + timedelta(days=30)
                access = Access(app=app, token=token, expires=expires)
                access.save()
                expires_3339 = expires.isoformat('T') + 'Z'
                return jsonify({'token': token, 'expires': expires_3339}), 200

            else:
                error = {'code': 'INVALID_CREDENTIALS'}
                return jsonify({'error': error}), 400


app_view = AppApi.as_view('app_api')
access_view = AccessApi.as_view('access_api')

bp.add_url_rule('/apps/', view_func=app_view, methods=[
    'POST',
])
bp.add_url_rule('/apps/tokens/', view_func=access_view, methods=[
    'POST',
])
Exemplo n.º 5
0
        try:
            with ScheduleDB(app.config) as db:
                db_data = db.get_group_list(organization, faculty)

            if db_data is None:
                return make_response(jsonify(self.error["getFail"]), 400)

            data = []
            for row in db_data:
                data.append(del_end_space(row[0]))

            return make_response(jsonify(data), 200)
        except BaseException as e:
            app.logger.warning('FacultyApi get: {}'.format(str(e)))
            return make_response(jsonify(self.error["getFail"]), 400)

    @jwt_required()
    def delete(self, organization, faculty):
        # Delete the entire organizations
        try:
            with ScheduleDB(app.config) as db:
                db.delete_faculty(organization, faculty)
            return make_response(jsonify({}), 200)
        except BaseException as e:
            app.logger.warning('FacultyApi delete: {}'.format(str(e)))
            return make_response(jsonify(self.error["deleteFail"]), 400)


bp.add_url_rule('/<organization>/<faculty>',
                view_func=FacultyApi.as_view('faculty_api'))
Exemplo n.º 6
0
        try:
            with ScheduleDB(app.config) as db:
                db_data = db.get_faculty(organization)

            if db_data is None:
                return make_response(jsonify(self.error["getFail"]), 400)

            data = []
            for row in db_data:
                data.append(del_end_space(row[0]))

            return make_response(jsonify(data), 200)
        except BaseException as e:
            app.logger.warning('OrganizationApi get: {}'.format(str(e)))
            return make_response(jsonify(self.error["getFail"]), 400)

    @jwt_required()
    def delete(self, organization):
        # Delete the entire organizations
        try:
            with ScheduleDB(app.config) as db:
                db.delete_organization(organization)
            return make_response(jsonify({}), 200)
        except BaseException as e:
            app.logger.warning('OrganizationApi delete: {}'.format(str(e)))
            return make_response(jsonify(self.error["deleteFail"]), 400)


bp.add_url_rule('/<organization>',
                view_func=OrganizationApi.as_view('organization_api'))
Exemplo n.º 7
0
            return jsonify(response), 200

    def delete(self, store_id):
        store = Store.objects.filter(external_id=store_id, live=True).first()
        if not store:
            return jsonify({}), 404
        store.live = False
        store.save()
        return jsonify({}), 204


store_view = StoreApi.as_view('store_api')

bp.add_url_rule('/stores/',
                defaults={'store_id': None},
                view_func=store_view,
                methods=[
                    'GET',
                ])
bp.add_url_rule('/stores/', view_func=store_view, methods=[
    'POST',
])
bp.add_url_rule('/stores/<store_id>',
                view_func=store_view,
                methods=[
                    'GET',
                    'PUT',
                    'DELETE',
                ])
bp.add_url_rule('/stores/<store_id>/pets',
                view_func=store_view,
                methods=[
Exemplo n.º 8
0
                    return make_response(jsonify(self.error["putFail_unknown"]), 400)

                old_tag = db_data[1]

                if old_tag is not None:
                    new_tag = db.update_organization(new_organization, new_faculty, new_group, old_tag)

                    if new_tag is not None:
                        return make_response(jsonify(new_tag), 200)
                    else:
                        return make_response(jsonify(self.error["putFail_unknown"]), 400)
                else:
                    return make_response(jsonify(self.error["putFail_unknown"]), 400)
        except BaseException as e:
            app.logger.warning('GroupApi put: {}'.format(str(e)))
            return make_response(jsonify(self.error["putFail_unknown"]), 400)

    @jwt_required()
    def delete(self, organization, faculty, group):
        # Delete the group
        try:
            with ScheduleDB(app.config) as db:
                db.delete_group(organization, faculty, group)
            return make_response(jsonify({}), 200)
        except BaseException as e:
            app.logger.warning('GroupApi delete: {}'.format(str(e)))
            return make_response(jsonify(self.error["deleteFail"]), 400)


bp.add_url_rule('/<organization>/<faculty>/<group>', view_func=GroupApi.as_view('group_api'))
Exemplo n.º 9
0
        # Return the organizations list
        try:
            with ScheduleDB(app.config) as db:
                db_data = db.get_organizations()

            if db_data is None:
                return make_response(jsonify(self.error["getFail"]), 400)

            data = []
            for row in db_data:
                data.append(del_end_space(row[0]))

            return make_response(jsonify(data), 200)
        except BaseException as e:
            app.logger.warning('DbInfoApi get: {}'.format(str(e)))
            return make_response(jsonify(self.error["getFail"]), 400)

    @jwt_required()
    def delete(self):
        # Delete the entire organizations
        try:
            with ScheduleDB(app.config) as db:
                db.delete_all_organizations()
            return make_response(jsonify({}), 200)
        except BaseException as e:
            app.logger.warning('DbInfoApi delete: {}'.format(str(e)))
            return make_response(jsonify(self.error["deleteFail"]), 400)


bp.add_url_rule('/', view_func=DbInfoApi.as_view('db_info__api'))