<commit_before>#
# Copyright (c) 2009 rPath, Inc.
#
# All Rights Reserved
#
from mint.rest.api import requires
from mint.rest.api import base
from mint.rest.api import models
from mint.rest.middleware import auth

class ProductReleasesController(base.BaseController):
    modelName = 'releaseId'

    urls = {'images' : {'GET' : 'images',
                        'POST' : 'addImage',
                        'PUT'  : 'setImages'},
            'publish' : {'POST' : 'publish'},
            'unpublish' : {'POST' : 'unpublish'}}

    @auth.public
    def index(self, request, hostname):
        limit = request.GET.get('limit', None)
        if limit:
            limit = int(limit)
        return self.db.listReleasesForProduct(hostname, limit=limit)

    @auth.public
    def get(self, request, hostname, releaseId):
        return self.db.getReleaseForProduct(hostname, releaseId)

    def destroy(self, request, hostname, releaseId):
        self.db.deleteRelease(hostname, releaseId)
        return self.index(request, hostname)

    @requires('release', models.UpdateRelease)
    def create(self, request, hostname, release):
        releaseId = self.db.createRelease(hostname, release.name,
                                          release.description,
                                          release.version,
                                          [ x.imageId for x in release.imageIds])
        return self.get(request, hostname, releaseId)<commit_msg>Create release without specifying images.<commit_after>#
# Copyright (c) 2009 rPath, Inc.
#
# All Rights Reserved
#
from mint.rest.api import requires
from mint.rest.api import base
from mint.rest.api import models
from mint.rest.middleware import auth

class ProductReleasesController(base.BaseController):
    modelName = 'releaseId'

    urls = {'images' : {'GET' : 'images',
                        'POST' : 'addImage',
                        'PUT'  : 'setImages'},
            'publish' : {'POST' : 'publish'},
            'unpublish' : {'POST' : 'unpublish'}}

    @auth.public
    def index(self, request, hostname):
        limit = request.GET.get('limit', None)
        if limit:
            limit = int(limit)
        return self.db.listReleasesForProduct(hostname, limit=limit)

    @auth.public
    def get(self, request, hostname, releaseId):
        return self.db.getReleaseForProduct(hostname, releaseId)

    def destroy(self, request, hostname, releaseId):
        self.db.deleteRelease(hostname, releaseId)
        return self.index(request, hostname)

    @requires('release', models.UpdateRelease)
    def create(self, request, hostname, release):
        if release.imageIds is not None:
            imageIds = [ x.imageId for x in release.imageIds]
        else:
            imageIds = []

        releaseId = self.db.createRelease(hostname, release.name,
                                          release.description,
                                          release.version, imageIds)
        return self.get(request, hostname, releaseId)
{'fraction_non_alphanumeric': 0.10891089108910891, 'fraction_numerical': 0.0026402640264026403, 'mean_word_length': 2.2176220806794054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1174183', 'n_tokens_mistral': 821, 'n_tokens_neox': 801, 'n_words': 208}