예제 #1
0
    def post(self):
        json_data = request.get_json(force=True)

        # check if the input exists
        if not json_data:
            return {'message': 'No input data provided'}, 400

        # get the input
        project_name = json_data['project_name']
        repository_name = json_data['repository_name']
        url = json_data['url']

        # check if the project already exists
        result = Repositories.get_repositories(project_name, repository_name)
        if len(result) > 1:
            return {'message': 'Repository name already exists'}, 400

        # check if the project's url already exists
        result = Repositories.get_repositories_by_url(repository_name, url)
        if len(result) > 1:
            return {'message': 'Repository url already exists'}, 400

        # create the repository
        Repositories.new_repository(project_name=project_name,
                                    repository_name=repository_name,
                                    url=url)

        # get the new project to confirm that everything is OK
        result = Repositories.get_repositories(project_name, repository_name)

        result = json.dumps(result, indent=4, sort_keys=True, default=str)

        # return the new project to the client
        return {"status": 'success', 'data': result}, 201
예제 #2
0
파일: Feature.py 프로젝트: csnoboa/testview
    def delete(self):
        args = request.args

        # check if the input exists
        if not args:
            return {'message': 'No input data provided'}, 400

        # get the input
        project_name = args['project_name']
        repository_name = args['repository_name']
        feature_name = args['feature_name']

        # check if the project exists
        result = Repositories.get_repositories(project_name, repository_name)
        if not result:
            return {'message': 'Repository name not exists'}, 400

        # check if the feature exists in this project
        result = Features.get_features(project_name, repository_name,
                                       feature_name)
        if not result:
            return {'message': 'Feature name not exists'}, 400

        # delete the feature
        Features.delete_feature(project_name, repository_name, feature_name)

        result = json.dumps(result, indent=4, sort_keys=True, default=str)
        # return to the client the deleted feature
        return {"status": 'success', 'data': result}, 201
예제 #3
0
 def get(self):
     args = request.args
     if not args:
         return {'message': 'No input data provided'}, 400
     project_name = args['project_name']
     result = Repositories.get_repositories(project_name)
     result = json.dumps(result, indent=4, sort_keys=True, default=str)
     return {"data": result}, 201
예제 #4
0
    def post(self):
        json_data = request.get_json(force=True)

        # check if the input exists
        if not json_data:
            return {'message': 'No input data provided'}, 400

        # get the input
        project_name = json_data['project_name']
        repository_name = json_data['repository_name']
        feature_name = json_data['feature_name']
        file_path = json_data['file_path']

        # check if the project exists
        result = Repositories.get_repositories(project_name, repository_name)
        if len(result) < 1:
            return {'message': 'Repository name not exists'}, 400

        # check if the file_name exists in the project

        file_path = file_path.replace('\\\\', '\\')
        file_path = file_path.replace(' ', '')
        result = Files.get_files(project_name=project_name,
                                 repository_name=repository_name,
                                 file_path=file_path)
        if not result:
            return {'message': 'File path not exists'}, 400

        # check if the feature_name exists in the project
        result = Features.get_features(project_name, repository_name,
                                       feature_name)
        if not result:
            return {'message': 'Feature name not exists'}, 400

        # check if the feature_name exists in the project
        result = Associations.get_associations(project_name, repository_name,
                                               file_path, feature_name)
        if result:
            return {'message': 'Association name already exists'}, 400

        # create the association
        Associations.new_association(project_name, repository_name, file_path,
                                     feature_name)

        # update the numbe of features associated to the file
        Files.update_file(project_name, repository_name, file_path)

        # # update the number of files associated to the feature
        Features.update_feature_files_associated(project_name, repository_name,
                                                 feature_name)

        # get the new association to confirm that everything is OK
        result = Associations.get_associations(project_name, repository_name,
                                               file_path, feature_name)

        result = json.dumps(result, indent=4, sort_keys=True, default=str)
        # return the new association to the client
        return {"status": 'success', 'data': result}, 201
예제 #5
0
    def delete(self):
        args = request.args

        # check if the input exists
        if not args:
            return {'message': 'No input data provided'}, 400

        # get the input
        project_name = args['project_name']
        repository_name = args['repository_name']
        feature_name = args['feature_name']
        file_path = args['file_path']

        # check if the project exists
        result = Repositories.get_repositories(project_name, repository_name)
        if not result:
            return {'message': 'Repository name not exists'}, 400

        file_path = file_path.replace('\\\\', '\\')
        file_path = file_path.replace(' ', '')

        result = Files.get_files(project_name=project_name,
                                 repository_name=repository_name,
                                 file_path=file_path)
        if not result:
            return {'message': 'File path not exists'}, 400

        # check if the association exists in this repository
        result = Associations.get_associations(project_name, repository_name,
                                               file_path, feature_name)
        if not result:
            return {'message': 'Association not exists'}, 400

        # delete the association
        Associations.delete_association(project_name, repository_name,
                                        file_path, feature_name)

        # update the numbe of features associated to the file
        Files.update_file(project_name, repository_name, file_path)

        # # update the number of files associated to the feature
        Features.update_feature_files_associated(project_name, repository_name,
                                                 feature_name)

        result = json.dumps(result, indent=4, sort_keys=True, default=str)
        # return to the client the deleted association
        return {"status": 'success', 'data': result}, 201
예제 #6
0
    def put(self):
        json_data = request.get_json(force=True)

        # check if the input exists
        if not json_data:
            return {'message': 'No input data provided'}, 400

        # get the input
        project_name = json_data['project_name']
        repository_name_old = json_data['repository_name_old']
        repository_name_new = json_data['repository_name_new']
        url_new = json_data['url_new']

        result = Repositories.get_repositories(project_name,
                                               repository_name_old)
        if len(result) < 1:
            return {'message': 'Repository name not exists'}, 400

        Repositories.edit_repositories(project_name=project_name,
                                       repository_name_old=repository_name_old,
                                       repository_name_new=repository_name_new,
                                       url_new=url_new)

        return {"status": 'success'}, 201
예제 #7
0
파일: Feature.py 프로젝트: csnoboa/testview
    def post(self):
        json_data = request.get_json(force=True)

        # check if the input exists
        if not json_data:
            return {'message': 'No input data provided'}, 400

        # get the input
        project_name = json_data['project_name']
        repository_name = json_data['repository_name']
        feature_name = json_data['feature_name']
        number_bugs_string = json_data['number_bugs']
        number_bugs = int(number_bugs_string)

        # check if the project exists
        result = Repositories.get_repositories(project_name, repository_name)
        if not result:
            return {'message': 'Repository name not exists'}, 400

        # check if the feature already exists
        result = Features.get_features(project_name, repository_name,
                                       feature_name)
        if len(result) > 1:
            return {'message': 'Feature name already exists'}, 400

        # create the new feature
        Features.new_feature(project_name, repository_name, feature_name,
                             number_bugs)

        # get the new feature to confirm that everything is OK
        result = Features.get_features(project_name, repository_name,
                                       feature_name)

        result = json.dumps(result, indent=4, sort_keys=True, default=str)

        return {"status": 'success', 'data': result}, 201