Ejemplo n.º 1
0
def package_new():
    ''' Page to create a new package. '''

    collections = pkgdb2.lib.search_collection(
        SESSION, '*', 'Under Development')
    collections.extend(pkgdb2.lib.search_collection(SESSION, '*', 'Active'))
    pkg_status = pkgdb2.lib.get_status(SESSION, 'pkg_status')['pkg_status']
    namespaces = pkgdb2.lib.get_status(SESSION, 'namespaces')['namespaces']

    form = pkgdb2.forms.AddPackageForm(
        collections=collections,
        pkg_status_list=pkg_status,
        namespaces=namespaces,
    )
    if form.validate_on_submit():
        pkg_name = form.pkgname.data
        pkg_summary = form.summary.data
        pkg_description = form.description.data
        pkg_review_url = form.review_url.data
        pkg_status = form.status.data
        pkg_critpath = form.critpath.data
        pkg_collection = form.branches.data
        pkg_poc = form.poc.data
        pkg_upstream_url = form.upstream_url.data
        pkg_namespace = form.namespace.data
        monitoring_status = form.monitoring_status.data
        koschei = form.koschei.data

        try:
            message = pkgdblib.add_package(
                SESSION,
                namespace=pkg_namespace,
                pkg_name=pkg_name,
                pkg_summary=pkg_summary,
                pkg_description=pkg_description,
                pkg_review_url=pkg_review_url,
                pkg_status=pkg_status,
                pkg_critpath=pkg_critpath,
                pkg_collection=pkg_collection,
                pkg_poc=pkg_poc,
                pkg_upstream_url=pkg_upstream_url,
                monitoring_status=monitoring_status,
                koschei=koschei,
                user=flask.g.fas_user,
            )
            SESSION.commit()
            flask.flash(message)
            return flask.redirect(flask.url_for('.list_packages'))
        # Keep it in, but normally we shouldn't hit this
        except PkgdbException as err:  # pragma: no cover
            SESSION.rollback()
            flask.flash(str(err), 'error')

    return flask.render_template(
        'package_new.html',
        form=form,
    )
Ejemplo n.º 2
0
def package_new():
    ''' Page to create a new package. '''

    collections = pkgdb2.lib.search_collection(SESSION, '*',
                                               'Under Development')
    collections.extend(pkgdb2.lib.search_collection(SESSION, '*', 'Active'))
    pkg_status = pkgdb2.lib.get_status(SESSION, 'pkg_status')['pkg_status']
    namespaces = pkgdb2.lib.get_status(SESSION, 'namespaces')['namespaces']

    form = pkgdb2.forms.AddPackageForm(
        collections=collections,
        pkg_status_list=pkg_status,
        namespaces=namespaces,
    )
    if form.validate_on_submit():
        pkg_name = form.pkgname.data
        pkg_summary = form.summary.data
        pkg_description = form.description.data
        pkg_review_url = form.review_url.data
        pkg_status = form.status.data
        pkg_critpath = form.critpath.data
        pkg_collection = form.branches.data
        pkg_poc = form.poc.data
        pkg_upstream_url = form.upstream_url.data
        pkg_namespace = form.namespace.data
        monitoring_status = form.monitoring_status.data
        koschei = form.koschei.data

        try:
            message = pkgdblib.add_package(
                SESSION,
                namespace=pkg_namespace,
                pkg_name=pkg_name,
                pkg_summary=pkg_summary,
                pkg_description=pkg_description,
                pkg_review_url=pkg_review_url,
                pkg_status=pkg_status,
                pkg_critpath=pkg_critpath,
                pkg_collection=pkg_collection,
                pkg_poc=pkg_poc,
                pkg_upstream_url=pkg_upstream_url,
                monitoring_status=monitoring_status,
                koschei=koschei,
                user=flask.g.fas_user,
            )
            SESSION.commit()
            flask.flash(message)
            return flask.redirect(flask.url_for('.list_packages'))
        # Keep it in, but normally we shouldn't hit this
        except PkgdbException as err:  # pragma: no cover
            SESSION.rollback()
            flask.flash(str(err), 'error')

    return flask.render_template(
        'package_new.html',
        form=form,
    )
Ejemplo n.º 3
0
def package_new():
    ''' Page to create a new package. '''

    collections = pkgdb2.lib.search_collection(
        SESSION, '*', 'Under Development')
    collections.extend(pkgdb2.lib.search_collection(SESSION, '*', 'Active'))
    pkg_status = pkgdb2.lib.get_status(SESSION, 'pkg_status')['pkg_status']

    form = pkgdb2.forms.AddPackageForm(
        collections=collections,
        pkg_status_list=pkg_status,
    )
    if form.validate_on_submit():
        pkg_name = form.pkg_name.data
        pkg_summary = form.pkg_summary.data
        pkg_description = form.pkg_description.data
        pkg_review_url = form.pkg_reviewURL.data
        pkg_status = form.pkg_status.data
        pkg_shouldopen = form.pkg_shouldopen.data
        pkg_critpath = form.pkg_critpath.data
        pkg_collection = form.pkg_collection.data
        pkg_poc = form.pkg_poc.data
        pkg_upstream_url = form.pkg_upstreamURL.data

        try:
            message = pkgdblib.add_package(
                SESSION,
                pkg_name=pkg_name,
                pkg_summary=pkg_summary,
                pkg_description=pkg_description,
                pkg_reviewURL=pkg_review_url,
                pkg_status=pkg_status,
                pkg_shouldopen=pkg_shouldopen,
                pkg_critpath=pkg_critpath,
                pkg_collection=pkg_collection,
                pkg_poc=pkg_poc,
                pkg_upstreamURL=pkg_upstream_url,
                user=flask.g.fas_user,
            )
            SESSION.commit()
            flask.flash(message)
            return flask.redirect(flask.url_for('.list_packages'))
        # Keep it in, but normally we shouldn't hit this
        except pkgdblib.PkgdbException, err:  # pragma: no cover
            SESSION.rollback()
            flask.flash(str(err), 'error')
Ejemplo n.º 4
0
def package_new():
    ''' Page to create a new package. '''

    collections = pkgdb2.lib.search_collection(SESSION, '*',
                                               'Under Development')
    collections.extend(pkgdb2.lib.search_collection(SESSION, '*', 'Active'))
    pkg_status = pkgdb2.lib.get_status(SESSION, 'pkg_status')['pkg_status']

    form = pkgdb2.forms.AddPackageForm(
        collections=collections,
        pkg_status_list=pkg_status,
    )
    if form.validate_on_submit():
        pkg_name = form.pkg_name.data
        pkg_summary = form.pkg_summary.data
        pkg_description = form.pkg_description.data
        pkg_review_url = form.pkg_reviewURL.data
        pkg_status = form.pkg_status.data
        pkg_shouldopen = form.pkg_shouldopen.data
        pkg_critpath = form.pkg_critpath.data
        pkg_collection = form.pkg_collection.data
        pkg_poc = form.pkg_poc.data
        pkg_upstream_url = form.pkg_upstreamURL.data

        try:
            message = pkgdblib.add_package(
                SESSION,
                pkg_name=pkg_name,
                pkg_summary=pkg_summary,
                pkg_description=pkg_description,
                pkg_reviewURL=pkg_review_url,
                pkg_status=pkg_status,
                pkg_shouldopen=pkg_shouldopen,
                pkg_critpath=pkg_critpath,
                pkg_collection=pkg_collection,
                pkg_poc=pkg_poc,
                pkg_upstreamURL=pkg_upstream_url,
                user=flask.g.fas_user,
            )
            SESSION.commit()
            flask.flash(message)
            return flask.redirect(flask.url_for('.list_packages'))
        # Keep it in, but normally we shouldn't hit this
        except pkgdblib.PkgdbException, err:  # pragma: no cover
            SESSION.rollback()
            flask.flash(str(err), 'error')
Ejemplo n.º 5
0
def api_package_new():
    '''
New package
-----------
    Create a new package.

    ::

        /api/package/new/

    Accept POST queries only.

    :arg pkgname: String of the package name to be created.
    :arg summary: String of the summary description of the package.
    :arg description: String describing the package (same as in the
        spec file).
    :arg review_url: the URL of the package review on the bugzilla.
    :arg status: status of the package can be one of: 'Approved',
        'Awaiting Review', 'Denied', 'Obsolete', 'Removed'
    :arg branches: one or more branch names of the collection in which
        this package is added.
    :arg poc: FAS username of the point of contact
    :arg upstream_url: the URL of the upstream project
    :arg critpath: boolean specifying if the package is in the critpath

    Sample response:

    ::

        {
          "output": "ok",
          "messages": ["Package created"]
        }

        {
          "output": "notok",
          "error": ["You're not allowed to add a package"]
        }

    '''
    httpcode = 200
    output = {}

    collections = pkgdblib.search_collection(
        SESSION, '*', 'Under Development')
    collections.extend(pkgdblib.search_collection(SESSION, '*', 'Active'))
    pkg_status = pkgdblib.get_status(SESSION, 'pkg_status')['pkg_status']

    form = forms.AddPackageForm(
        csrf_enabled=False,
        collections=collections,
        pkg_status_list=pkg_status,
    )
    if form.validate_on_submit():
        pkg_name = form.pkgname.data
        pkg_summary = form.summary.data
        pkg_description = form.description.data
        pkg_review_url = form.review_url.data
        pkg_status = form.status.data
        pkg_collection = form.branches.data
        pkg_poc = form.poc.data
        pkg_upstream_url = form.upstream_url.data
        pkg_critpath = form.critpath.data

        try:
            message = pkgdblib.add_package(
                SESSION,
                pkg_name=pkg_name,
                pkg_summary=pkg_summary,
                pkg_description=pkg_description,
                pkg_review_url=pkg_review_url,
                pkg_status=pkg_status,
                pkg_collection=pkg_collection,
                pkg_poc=pkg_poc,
                pkg_upstream_url=pkg_upstream_url,
                pkg_critpath=pkg_critpath,
                user=flask.g.fas_user
            )
            SESSION.commit()
            output['output'] = 'ok'
            output['messages'] = [message]
        except pkgdblib.PkgdbException, err:
            SESSION.rollback()
            output['output'] = 'notok'
            output['error'] = str(err)
            httpcode = 500
Ejemplo n.º 6
0
def api_package_new():
    '''
    New package
    -----------
    Create a new package.

    ::

        /api/package/new/

    Accepts POST queries only.

    :arg pkgname: String of the package name to be created.
    :arg summary: String of the summary description of the package.
    :arg description: String describing the package (same as in the
        spec file).
    :arg review_url: the URL of the package review on the bugzilla.
    :arg status: status of the package can be one of: 'Approved',
        'Awaiting Review', 'Denied', 'Obsolete', 'Removed'
    :arg branches: one or more branch names of the collection in which
        this package is added.
    :arg poc: FAS username of the point of contact
    :arg upstream_url: the URL of the upstream project
    :arg critpath: boolean specifying if the package is in the critpath

    Sample response:

    ::

        {
          "output": "ok",
          "messages": ["Package created"]
        }

        {
          "output": "notok",
          "error": ["You're not allowed to add a package"]
        }

    '''
    httpcode = 200
    output = {}

    collections = pkgdblib.search_collection(SESSION, '*', 'Under Development')
    collections.extend(pkgdblib.search_collection(SESSION, '*', 'Active'))
    pkg_status = pkgdblib.get_status(SESSION, 'pkg_status')['pkg_status']

    form = forms.AddPackageForm(
        csrf_enabled=False,
        collections=collections,
        pkg_status_list=pkg_status,
    )
    if form.validate_on_submit():
        pkg_name = form.pkgname.data
        pkg_summary = form.summary.data
        pkg_description = form.description.data
        pkg_review_url = form.review_url.data
        pkg_status = form.status.data
        pkg_collection = form.branches.data
        pkg_poc = form.poc.data
        pkg_upstream_url = form.upstream_url.data
        pkg_critpath = form.critpath.data

        try:
            message = pkgdblib.add_package(SESSION,
                                           pkg_name=pkg_name,
                                           pkg_summary=pkg_summary,
                                           pkg_description=pkg_description,
                                           pkg_review_url=pkg_review_url,
                                           pkg_status=pkg_status,
                                           pkg_collection=pkg_collection,
                                           pkg_poc=pkg_poc,
                                           pkg_upstream_url=pkg_upstream_url,
                                           pkg_critpath=pkg_critpath,
                                           user=flask.g.fas_user)
            SESSION.commit()
            output['output'] = 'ok'
            output['messages'] = [message]
        except pkgdblib.PkgdbException, err:
            SESSION.rollback()
            output['output'] = 'notok'
            output['error'] = str(err)
            httpcode = 500