Esempio n. 1
0
 def delete(self, id):
     filters = ScenarioFilter.query.get(id)
     if not filters:
         abort(404)
     db_session.delete(filters)
     db_session.commit()
     return {'result': True}
Esempio n. 2
0
 def delete(self, id):
     report = RedHatBugzillaReport.query.get(id)
     if not report:
         abort(404)
     db_session.delete(report)
     db_session.commit()
     return {'result': True}
Esempio n. 3
0
 def delete(self, id):
     project = Project.query.get(id)
     if not project:
         abort(404)
     db_session.delete(project)
     db_session.commit()
     return {'result': True}
Esempio n. 4
0
 def delete(self, id):
     harvester = Harvester.query.get(id)
     if not harvester:
         abort(404)
     db_session.delete(harvester)
     db_session.commit()
     return {'result': True}
Esempio n. 5
0
 def delete(self, id):
     user = User.query.get(id)
     if not user:
         abort(404)
     db_session.delete(user)
     db_session.commit()
     return {'result': True}
Esempio n. 6
0
 def delete(self, id):
     team = Team.query.get(id)
     if not team:
         abort(404)
     db_session.delete(team)
     db_session.commit()
     return {'result': True}
Esempio n. 7
0
 def post(self):
     args = project_parser.parse_args()
     project = Project(name=args['name'],
                       git_url=args['git_url'],
                       gerrit_server=args['gerrit_server'])
     db_session.add(project)
     db_session.commit()
     return project, 201
Esempio n. 8
0
    def post(self):
        args = scenario_filter_parser.parse_args()
        _filter = ScenarioFilter()
        _filter.filter_desc = args['filter_desc']
        _filter.name = args['name']

        db_session.add(_filter)
        db_session.commit()
        return 201
Esempio n. 9
0
 def post(self):
     args = authuser_parser.parse_args()
     user = AuthUser()
     user.username = args['username']
     user.hash_password(args['password'])
     print user.password_hash
     db_session.add(user)
     db_session.commit()
     return True
Esempio n. 10
0
    def post(self):
        args = user_parser.parse_args()
        user = User(name=args['name'],
                    email=args['email'],
                    user_id=args['user_id'])
        db_session.add(user)
        db_session.commit()

        return user, 201
Esempio n. 11
0
    def post(self):
        args = harvester_parser.parse_args()
        harvester = Harvester()
        harvester.name = args['name']
        harvester.url = args['url']
        harvester.description = args['description']

        db_session.add(harvester)
        db_session.commit()
        return harvester, 201
Esempio n. 12
0
    def put(self, id):
        harvester = Harvester.query.get(id)
        if not harvester:
            abort(404)
        args = harvester_parser.parse_args()
        harvester.name = args['name']
        harvester.url = args['url']
        harvester.description = args['description']
        db_session.commit()

        return harvester, 201
Esempio n. 13
0
    def put(self, id):
        user = User.query.get(id)
        if not user:
            abort(404)

        args = user_parser.parse_args()
        user.name = args['name']
        user.email = args['email']
        user.user_id = args['user_id']
        db_session.commit()
        return user, 201
Esempio n. 14
0
    def put(self, id):
        project = Project.query.get(id)
        if not project:
            abort(404)

        args = project_parser.parse_args()
        project.name = args['name']
        project.git_url = args['git_url']
        project.gerrit_server = args['gerrit_server']
        db_session.commit()

        return project, 201
Esempio n. 15
0
    def post(self):
        args = team_parser.parse_args()
        team = Team(name=args['name'])
        users = args.get('users', None)
        if users:
            user_ids = [user['id'] for user in users]
            selected_users = User.query.filter(User.id.in_(user_ids)).all()
            for selected_user in selected_users:
                team.users.append(selected_user)

        db_session.add(team)
        db_session.commit()
        return team, 201
Esempio n. 16
0
    def put(self, id):
        report = RedHatBugzillaReport.query.get(id)
        if not report:
            abort(404)
        args = bz_parser.parse_args()
        tmp_url = args['url']
        if 'GoAheadAndLogIn' not in tmp_url:
            tmp_url = tmp_url + '&GoAheadAndLogIn=1'

        if 'ctype=csv' not in tmp_url:
            tmp_url = tmp_url + '&ctype=csv'

        report.name = args['name']
        report.url = tmp_url
        report.description = args['description'] or ''
        db_session.commit()
        return report, 201
Esempio n. 17
0
    def post(self):
        args = bz_parser.parse_args()
        tmp_url = args['url']
        if 'GoAheadAndLogIn' not in tmp_url:
            tmp_url = tmp_url + '&GoAheadAndLogIn=1'

        if 'ctype=csv' not in tmp_url:
            tmp_url = tmp_url + '&ctype=csv'

        report = RedHatBugzillaReport()
        report.name = args['name']
        report.url = tmp_url
        report.require_authentication = True
        report.description = args['description'] or ''

        db_session.add(report)
        db_session.commit()

        return report, 201
Esempio n. 18
0
def update_gerrit_review(gerrit_review):
    LOG.debug('Updating review %s' % gerrit_review['change_id'])
    review = utils.get_gerrit_reviews(
        filter={'change_id': gerrit_review['change_id']}, first=True)

    if review:
        LOG.debug('Review found in database. Change id: %s and commit id %s' %
                  (review.change_id, review.commit_id))
        current_revision = gerrit_review.get('current_revision', None)
        if gerrit_review.get('status', None) == 'MERGED':
            LOG.debug('Review %s was merged, inserting modified files '
                      'in database' % gerrit_review['change_id'])
            if gerrit_review.get('revisions', None) and current_revision:
                if gerrit_review['revisions'].get(current_revision):
                    files = gerrit_review['revisions'][current_revision].get(
                        'files')
                    files_in_database = [f.filename for f in review.files]
                    files_in_gerrit = files.keys() if files else []
                    files_to_delete = list(
                        set(files_in_database) - set(files_in_gerrit))
                    for f in review.files:
                        if f.filename in files_to_delete:
                            review.files.remove(f)

                    for f in files.keys():
                        if f not in files_in_database:
                            gerrit_file = GerritReviewFile()
                            gerrit_file.filename = f
                            review.files.append(gerrit_file)

        review.commit_id = current_revision
        review.version = gerrit_review.get('version')

        user_id = gerrit_review['owner'].get('username', None)
        email = gerrit_review['owner'].get('email', None)

        user = (utils.get_users(filter={'user_id': user_id}, first=True)
                or utils.get_users(filter={'email': email}, first=True))
        review.user = user
        review.user_id = user.id if user else None
        review.status = gerrit_review['status']
        db_session.commit()
Esempio n. 19
0
    def put(self, id):
        team = Team.query.get(id)
        if not team:
            abort(404)

        args = team_parser.parse_args()
        team.name = args["name"]
        if args.get('users', None):
            users_ids = [user.get('id', None) for user in args.get('users')]
            users = User.query.filter(
                User.id.in_(users_ids)).all() if users_ids else []
            users_remove = [user for user in team.users if user not in users]
            for user in users_remove:
                team.users.remove(user)
            for user in users:
                if user not in team.users:
                    team.users.append(user)

        db_session.commit()
        return team, 201
Esempio n. 20
0
def insert_gerrit_review(review):
    LOG.debug('Inserting review %s on database' % review['change_id'])

    user = None
    user_id = review['owner'].get('username', None)
    email = review['owner'].get('email', None)
    if user_id:
        LOG.debug('Looking for user with user id %s in database' % user_id)
        user = User.query.filter_by(user_id=user_id).first()
    elif email:
        LOG.debug('Looking for user with email %s in database' % email)
        user = User.query.filter_by(email=email).first()

    LOG.debug('User in database: %s' % user)
    current_revision = review.get('current_revision', None)

    gerrit_review = GerritReview()
    gerrit_review.commit_id = review.get('current_revision', None)
    gerrit_review.change_id = review.get('change_id', None)
    gerrit_review.version = review.get('version', None)
    gerrit_review.user = user
    gerrit_review.user_id = user.id if user else None
    gerrit_review.project = review.get('project', None)
    gerrit_review.status = review.get('status')

    # We only add the files when it's merged, so it's more easy to
    # track down and don't overload the database
    if review.get('status', None) == 'MERGED':
        LOG.debug('Change is merged, inserting the changed files in database')
        if review.get('revisions', None) and current_revision:
            if review['revisions'].get(current_revision):
                files = review['revisions'][current_revision].get('files')
                for f in files.keys():
                    gerrit_file = GerritReviewFile()
                    gerrit_file.filename = f
                    gerrit_review.files.append(gerrit_file)

    db_session.add(gerrit_review)
    db_session.commit()
    LOG.debug('Change %s inserted successfully' % review['change_id'])