예제 #1
0
def collection_new():
    ''' Page to create a new collection. '''

    clt_status = pkgdblib.get_status(SESSION, 'clt_status')['clt_status']
    form = pkgdb2.forms.AddCollectionForm(clt_status=clt_status)
    if form.validate_on_submit():
        clt_name = form.collection_name.data
        clt_version = form.collection_version.data
        clt_status = form.collection_status.data
        clt_branchname = form.collection_branchname.data
        clt_disttag = form.collection_distTag.data
        clt_gitbranch = form.collection_git_branch_name.data
        clt_koji_name = form.collection_kojiname.data

        try:
            message = pkgdblib.add_collection(
                SESSION,
                clt_name=clt_name,
                clt_version=clt_version,
                clt_status=clt_status,
                clt_branchname=clt_branchname,
                clt_disttag=clt_disttag,
                clt_gitbranch=clt_gitbranch,
                clt_koji_name=clt_koji_name,
                user=flask.g.fas_user,
            )
            SESSION.commit()
            flask.flash(message)
            return flask.redirect(flask.url_for('.list_collections'))
        # In theory we should never hit this
        except pkgdblib.PkgdbException, err:  # pragma: no cover
            SESSION.rollback()
            flask.flash(str(err), 'errors')
예제 #2
0
def collection_new():
    ''' Page to create a new collection. '''

    clt_status = pkgdblib.get_status(SESSION, 'clt_status')['clt_status']
    form = pkgdb2.forms.AddCollectionForm(clt_status=clt_status)
    if form.validate_on_submit():
        clt_name = form.collection_name.data
        clt_version = form.collection_version.data
        clt_status = form.collection_status.data
        clt_branchname = form.collection_branchname.data
        clt_disttag = form.collection_distTag.data
        clt_gitbranch = form.collection_git_branch_name.data
        clt_koji_name = form.collection_kojiname.data

        try:
            message = pkgdblib.add_collection(
                SESSION,
                clt_name=clt_name,
                clt_version=clt_version,
                clt_status=clt_status,
                clt_branchname=clt_branchname,
                clt_disttag=clt_disttag,
                clt_gitbranch=clt_gitbranch,
                clt_koji_name=clt_koji_name,
                user=flask.g.fas_user,
            )
            SESSION.commit()
            flask.flash(message)
            return flask.redirect(flask.url_for('.list_collections'))
        # In theory we should never hit this
        except pkgdblib.PkgdbException, err:  # pragma: no cover
            SESSION.rollback()
            flask.flash(str(err), 'errors')
예제 #3
0
def api_collection_new():
    '''
New collection
--------------
    Create a new collection.

    ::

        /api/collection/new/

    Accept POST queries only.

    :arg collection_name: String of the collection name to be created.
    :arg collection_version: String of the version of the collection.
    :arg collection_status: String of the name of the user owner of the
        collection.
    :arg collection_publishURLTemplate:
    :arg collection_pendingURLTemplate:
    :arg collection_summary: A summary description of the collection.
    :arg collection_description: A description of the collection.
    :arg collection_branchname: The short name of the collection (ie: F-18).
    :arg collection_distTag: The dist tag used by rpm for this collection
        (ie: .fc18).
    :arg collection_git_branch_name: The git branch name for this collection
        (ie: f18).
    :arg collection_kojiname: the name of the collection in koji.

    Sample response:

    ::

        {
          "output": "ok",
          "messages": ["Collection F-20 created"]
        }

        {
          "output": "notok",
          "error": ["You are not allowed to create collections"]
        }

    '''
    httpcode = 200
    output = {}

    clt_status = pkgdblib.get_status(SESSION, 'clt_status')['clt_status']

    form = forms.AddCollectionForm(
        csrf_enabled=False,
        clt_status=clt_status,
    )
    if form.validate_on_submit():
        clt_name = form.collection_name.data
        clt_version = form.collection_version.data
        clt_status = form.collection_status.data
        clt_branchname = form.collection_branchname.data
        clt_disttag = form.collection_distTag.data
        clt_gitbranch = form.collection_git_branch_name.data
        clt_koji_name = form.collection_kojiname.data

        try:
            message = pkgdblib.add_collection(
                SESSION,
                clt_name=clt_name,
                clt_version=clt_version,
                clt_status=clt_status,
                clt_branchname=clt_branchname,
                clt_disttag=clt_disttag,
                clt_gitbranch=clt_gitbranch,
                clt_koji_name=clt_koji_name,
                user=flask.g.fas_user,
            )
            SESSION.commit()
            output['output'] = 'ok'
            output['messages'] = [message]
        # Apparently we're pretty tight on checks and looks like we cannot
        # raise this exception in a normal situation
        except pkgdblib.PkgdbException, err:  # pragma: no cover
            SESSION.rollback()
            output['output'] = 'notok'
            output['error'] = str(err)
            httpcode = 500
예제 #4
0
def api_collection_new():
    '''
    New collection
    --------------
    Create a new collection.

    ::

        /api/collection/new/

    Accepts POST queries only.

    :arg clt_name: String of the collection name to be created.
    :arg version: String of the version of the collection.
    :arg clt_status: String of the name of the user owner of the collection.
    :arg summary: A summary description of the collection.
    :arg description: A description of the collection.
    :arg branchname: The short name of the collection (ie: F-18).
    :arg dist_tag: The dist tag used by rpm for this collection (ie: .fc18).
    :arg kojiname: the name of the collection in koji.
    :kwarg allow_retire: a boolean specifying if the collection should allow
        retiring a package or not.
        Defaults to ``False``.

    Sample response:

    ::

        {
          "output": "ok",
          "messages": ["Collection F-20 created"]
        }

        {
          "output": "notok",
          "error": ["You are not allowed to create collections"]
        }

    '''
    httpcode = 200
    output = {}

    clt_status = pkgdblib.get_status(SESSION, 'clt_status')['clt_status']

    form = forms.AddCollectionForm(
        csrf_enabled=False,
        clt_status=clt_status,
    )
    if form.validate_on_submit():
        clt_name = form.clt_name.data
        clt_version = form.version.data
        clt_status = form.clt_status.data
        clt_branchname = form.branchname.data
        clt_disttag = form.dist_tag.data
        clt_koji_name = form.kojiname.data
        clt_allow_retire = form.allow_retire.data or False

        try:
            message = pkgdblib.add_collection(
                SESSION,
                clt_name=clt_name,
                clt_version=clt_version,
                clt_status=clt_status,
                clt_branchname=clt_branchname,
                clt_disttag=clt_disttag,
                clt_koji_name=clt_koji_name,
                clt_allow_retire=clt_allow_retire,
                user=flask.g.fas_user,
            )
            SESSION.commit()
            output['output'] = 'ok'
            output['messages'] = [message]
        # Apparently we're pretty tight on checks and looks like we cannot
        # raise this exception in a normal situation
        except PkgdbException as err:  # pragma: no cover
            SESSION.rollback()
            output['output'] = 'notok'
            output['error'] = str(err)
            httpcode = 500
    else:
        output['output'] = 'notok'
        output['error'] = 'Invalid input submitted'
        if form.errors:
            detail = []
            for error in form.errors:
                detail.append('%s: %s' % (error,
                              '; '.join(form.errors[error])))
            output['error_detail'] = detail
        httpcode = 500

    jsonout = flask.jsonify(output)
    jsonout.status_code = httpcode
    return jsonout
예제 #5
0
def api_collection_new():
    '''
New collection
--------------
    Create a new collection.

    ::

        /api/collection/new/

    Accept POST queries only.

    :arg clt_name: String of the collection name to be created.
    :arg version: String of the version of the collection.
    :arg clt_status: String of the name of the user owner of the collection.
    :arg summary: A summary description of the collection.
    :arg description: A description of the collection.
    :arg branchname: The short name of the collection (ie: F-18).
    :arg dist_tag: The dist tag used by rpm for this collection (ie: .fc18).
    :arg kojiname: the name of the collection in koji.

    Sample response:

    ::

        {
          "output": "ok",
          "messages": ["Collection F-20 created"]
        }

        {
          "output": "notok",
          "error": ["You are not allowed to create collections"]
        }

    '''
    httpcode = 200
    output = {}

    clt_status = pkgdblib.get_status(SESSION, 'clt_status')['clt_status']

    form = forms.AddCollectionForm(
        csrf_enabled=False,
        clt_status=clt_status,
    )
    if form.validate_on_submit():
        clt_name = form.clt_name.data
        clt_version = form.version.data
        clt_status = form.clt_status.data
        clt_branchname = form.branchname.data
        clt_disttag = form.dist_tag.data
        clt_koji_name = form.kojiname.data

        try:
            message = pkgdblib.add_collection(
                SESSION,
                clt_name=clt_name,
                clt_version=clt_version,
                clt_status=clt_status,
                clt_branchname=clt_branchname,
                clt_disttag=clt_disttag,
                clt_koji_name=clt_koji_name,
                user=flask.g.fas_user,
            )
            SESSION.commit()
            output['output'] = 'ok'
            output['messages'] = [message]
        # Apparently we're pretty tight on checks and looks like we cannot
        # raise this exception in a normal situation
        except pkgdblib.PkgdbException, err:  # pragma: no cover
            SESSION.rollback()
            output['output'] = 'notok'
            output['error'] = str(err)
            httpcode = 500
예제 #6
0
def api_collection_new():
    '''
    New collection
    --------------
    Create a new collection.

    ::

        /api/collection/new/

    Accepts POST queries only.

    :arg clt_name: String of the collection name to be created.
    :arg version: String of the version of the collection.
    :arg clt_status: String of the name of the user owner of the collection.
    :arg summary: A summary description of the collection.
    :arg description: A description of the collection.
    :arg branchname: The short name of the collection (ie: F-18).
    :arg dist_tag: The dist tag used by rpm for this collection (ie: .fc18).
    :arg kojiname: the name of the collection in koji.
    :kwarg allow_retire: a boolean specifying if the collection should allow
        retiring a package or not.
        Defaults to ``False``.

    Sample response:

    ::

        {
          "output": "ok",
          "messages": ["Collection F-20 created"]
        }

        {
          "output": "notok",
          "error": ["You are not allowed to create collections"]
        }

    '''
    httpcode = 200
    output = {}

    clt_status = pkgdblib.get_status(SESSION, 'clt_status')['clt_status']

    form = forms.AddCollectionForm(
        csrf_enabled=False,
        clt_status=clt_status,
    )
    if form.validate_on_submit():
        clt_name = form.clt_name.data
        clt_version = form.version.data
        clt_status = form.clt_status.data
        clt_branchname = form.branchname.data
        clt_disttag = form.dist_tag.data
        clt_koji_name = form.kojiname.data
        clt_allow_retire = form.allow_retire.data or False

        try:
            message = pkgdblib.add_collection(
                SESSION,
                clt_name=clt_name,
                clt_version=clt_version,
                clt_status=clt_status,
                clt_branchname=clt_branchname,
                clt_disttag=clt_disttag,
                clt_koji_name=clt_koji_name,
                clt_allow_retire=clt_allow_retire,
                user=flask.g.fas_user,
            )
            SESSION.commit()
            output['output'] = 'ok'
            output['messages'] = [message]
        # Apparently we're pretty tight on checks and looks like we cannot
        # raise this exception in a normal situation
        except PkgdbException as err:  # pragma: no cover
            SESSION.rollback()
            output['output'] = 'notok'
            output['error'] = str(err)
            httpcode = 500
    else:
        output['output'] = 'notok'
        output['error'] = 'Invalid input submitted'
        if form.errors:
            detail = []
            for error in form.errors:
                detail.append('%s: %s' %
                              (error, '; '.join(form.errors[error])))
            output['error_detail'] = detail
        httpcode = 500

    jsonout = flask.jsonify(output)
    jsonout.status_code = httpcode
    return jsonout