def package_request_new(): ''' Page to request 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.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 try: messages = [] for clt in pkg_collection: message = pkgdblib.add_new_package_request( SESSION, 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=clt, pkg_poc=pkg_poc, pkg_upstream_url=pkg_upstream_url, user=flask.g.fas_user, ) if message: messages.append(message) SESSION.commit() for message in messages: flask.flash(message) return flask.redirect(flask.url_for('.index')) # Keep it in, but normally we shouldn't hit this except pkgdblib.PkgdbException, err: # pragma: no cover SESSION.rollback() flask.flash(str(err), 'error')
def package_request_new(): ''' Page to request a new package. ''' collections = pkgdb2.lib.search_collection(SESSION, '*', 'Under Development') collections.reverse() active_collections = pkgdb2.lib.search_collection(SESSION, '*', 'Active') active_collections.reverse() # We want all the branch `Under Development` as well as all the `Active` # branch but we can only have at max 2 Fedora branch active at the same # time. In other words, when Fedora n+1 is released one can no longer # request a package to be added to Fedora n-1 cnt = 0 for collection in active_collections: if collection.name.lower() == 'fedora': if cnt >= 2: continue cnt += 1 collections.append(collection) form = pkgdb2.forms.RequestPackageForm(collections=collections, ) 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 = 'Approved' pkg_critpath = False pkg_collection = form.branches.data if not 'master' in pkg_collection: flask.flash('Adding a request for `master` branch, this branch is ' 'mandatory') pkg_collection.append('master') pkg_poc = flask.g.fas_user.username pkg_upstream_url = form.upstream_url.data bz = APP.config.get('PKGDB2_BUGZILLA_URL') if bz not in pkg_review_url: try: int(pkg_review_url) pkg_review_url = bz + '/' + pkg_review_url except (TypeError, ValueError): pass try: messages = [] for clt in pkg_collection: message = pkgdblib.add_new_package_request( SESSION, 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=clt, pkg_poc=pkg_poc, pkg_upstream_url=pkg_upstream_url, user=flask.g.fas_user, ) if message: messages.append(message) SESSION.commit() for message in messages: flask.flash(message) return flask.redirect(flask.url_for('.index')) # Keep it in, but normally we shouldn't hit this except pkgdblib.PkgdbException, err: # pragma: no cover SESSION.rollback() flask.flash(str(err), 'error')
def api_package_request(): ''' New package request ------------------- Request for an admin to include a new package in pkgdb. :: /api/request/package Accepts POST queries only. :arg pkgname: The name of the package to create. :arg summary: The summary of the package. :arg description: The description of the package. :arg upstream_url: The URL of the upstream website of the package. :arg review_url: The URL where the package review was done. :arg branches: The list of branches desired for this package. Note: if the ``master`` isn't requested, it will be added automatically. :kwarg namespace: The namespace of the package to create (defaults to ``rpms``). Sample response: :: { "output": "ok", "messages": [ 'user: pingou request package: guake on branch master', 'user: pingou request package: guake on branch f18', ] } { "output": "notok", 'error': 'User "pingou" is not in the packager group', } { "error": "Invalid input submitted", "error_detail": [ "branches: 'foobar' is not a valid choice for this field", "review_url: This field is required." ], "output": "notok" } ''' httpcode = 200 output = {} collections = pkgdblib.search_collection( SESSION, '*', 'Under Development') collections.reverse() active_collections = pkgdblib.search_collection(SESSION, '*', 'Active') active_collections.reverse() # We want all the branch `Under Development` as well as all the `Active` # branch but we can only have at max 2 Fedora branch active at the same # time. In other words, when Fedora n+1 is released one can no longer # request a package to be added to Fedora n-1 cnt = 0 for collection in active_collections: if collection.name.lower() == 'fedora': if cnt >= 2: continue cnt += 1 collections.append(collection) namespaces = pkgdblib.get_status(SESSION, 'namespaces')['namespaces'] form = forms.RequestPackageForm( csrf_enabled=False, collections=collections, namespaces=namespaces, ) if str(form.namespace.data) in ['None', '']: form.namespace.data = 'rpms' 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 = 'Approved' pkg_critpath = False pkg_collection = form.branches.data if not 'master' in pkg_collection: pkg_collection.append('master') pkg_poc = flask.g.fas_user.username pkg_upstream_url = form.upstream_url.data pkg_namespace = form.namespace.data bz = APP.config.get('PKGDB2_BUGZILLA_URL') if bz not in pkg_review_url: try: int(pkg_review_url) pkg_review_url = bz + '/' + pkg_review_url except (TypeError, ValueError): pass try: messages = [] for clt in pkg_collection: message = pkgdblib.add_new_package_request( SESSION, 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=clt, pkg_poc=pkg_poc, pkg_upstream_url=pkg_upstream_url, pkg_namespace=pkg_namespace, user=flask.g.fas_user, ) if message: messages.append(message) SESSION.commit() output['output'] = 'ok' output['messages'] = messages except pkgdblib.PkgdbException, err: SESSION.rollback() output['output'] = 'notok' output['error'] = str(err) httpcode = 400
def package_request_new(): ''' Page to request a new package. ''' collections = pkgdb2.lib.search_collection( SESSION, '*', 'Under Development') collections.reverse() active_collections = pkgdb2.lib.search_collection( SESSION, '*', 'Active') active_collections.reverse() # We want all the branch `Under Development` as well as all the `Active` # branch but we can only have at max 2 Fedora branch active at the same # time. In other words, when Fedora n+1 is released one can no longer # request a package to be added to Fedora n-1 cnt = 0 for collection in active_collections: if collection.name.lower() == 'fedora': if cnt >= 2: continue cnt += 1 collections.append(collection) namespaces = pkgdblib.get_status(SESSION, 'namespaces')['namespaces'] default_ns = APP.config.get('DEFAULT_NAMESPACE', 'rpms') # Ensure the `rpms` namespace is always the first in the list (the default) if default_ns in namespaces: namespaces.pop(namespaces.index(default_ns)) namespaces.insert(0, default_ns) form = pkgdb2.forms.RequestPackageForm( collections=collections, 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 = 'Approved' pkg_critpath = False pkg_collection = form.branches.data pkg_namespace = form.namespace.data if not 'master' in pkg_collection: flask.flash( 'Adding a request for `master` branch, this branch is ' 'mandatory') pkg_collection.append('master') pkg_poc = flask.g.fas_user.username pkg_upstream_url = form.upstream_url.data monitoring_status = form.monitoring_status.data koschei = form.koschei.data comaintainers = form.comaintainers.data.strip() or None bz = APP.config.get('PKGDB2_BUGZILLA_URL') pkg_review_url = pkgdblib.check_bz_url(bz, pkg_review_url) try: messages = [] for clt in pkg_collection: message = pkgdblib.add_new_package_request( SESSION, pkg_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=clt, pkg_poc=pkg_poc, pkg_upstream_url=pkg_upstream_url, monitoring_status=monitoring_status, koschei=koschei, comaintainers=comaintainers, user=flask.g.fas_user, ) if message: messages.append(message) SESSION.commit() for message in messages: flask.flash(message) return flask.redirect(flask.url_for('.index')) # 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_request.html', form=form, )
def package_request_new(): ''' Page to request a new package. ''' collections = pkgdb2.lib.search_collection(SESSION, '*', 'Under Development') collections.reverse() active_collections = pkgdb2.lib.search_collection(SESSION, '*', 'Active') active_collections.reverse() # We want all the branch `Under Development` as well as all the `Active` # branch but we can only have at max 2 Fedora branch active at the same # time. In other words, when Fedora n+1 is released one can no longer # request a package to be added to Fedora n-1 cnt = 0 for collection in active_collections: if collection.name.lower() == 'fedora': if cnt >= 2: continue cnt += 1 collections.append(collection) form = pkgdb2.forms.RequestPackageForm( collections=collections, ) 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 = 'Approved' pkg_critpath = False pkg_collection = form.branches.data if not 'master' in pkg_collection: flask.flash( 'Adding a request for `master` branch, this branch is ' 'mandatory') pkg_collection.append('master') pkg_poc = flask.g.fas_user.username pkg_upstream_url = form.upstream_url.data try: messages = [] for clt in pkg_collection: message = pkgdblib.add_new_package_request( SESSION, 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=clt, pkg_poc=pkg_poc, pkg_upstream_url=pkg_upstream_url, user=flask.g.fas_user, ) if message: messages.append(message) SESSION.commit() for message in messages: flask.flash(message) return flask.redirect(flask.url_for('.index')) # Keep it in, but normally we shouldn't hit this except pkgdblib.PkgdbException, err: # pragma: no cover SESSION.rollback() flask.flash(str(err), 'error')
def package_request_new(): ''' Page to request a new package. ''' collections = pkgdb2.lib.search_collection(SESSION, '*', 'Under Development') collections.reverse() active_collections = pkgdb2.lib.search_collection(SESSION, '*', 'Active') active_collections.reverse() # We want all the branch `Under Development` as well as all the `Active` # branch but we can only have at max 2 Fedora branch active at the same # time. In other words, when Fedora n+1 is released one can no longer # request a package to be added to Fedora n-1 cnt = 0 for collection in active_collections: if collection.name.lower() == 'fedora': if cnt >= 2: continue cnt += 1 collections.append(collection) namespaces = pkgdblib.get_status(SESSION, 'namespaces')['namespaces'] default_ns = APP.config.get('DEFAULT_NAMESPACE', 'rpms') # Ensure the `rpms` namespace is always the first in the list (the default) if default_ns in namespaces: namespaces.pop(namespaces.index(default_ns)) namespaces.insert(0, default_ns) form = pkgdb2.forms.RequestPackageForm( collections=collections, 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 = 'Approved' pkg_critpath = False pkg_collection = form.branches.data pkg_namespace = form.namespace.data if not 'master' in pkg_collection: flask.flash('Adding a request for `master` branch, this branch is ' 'mandatory') pkg_collection.append('master') pkg_poc = flask.g.fas_user.username pkg_upstream_url = form.upstream_url.data monitoring_status = form.monitoring_status.data koschei = form.koschei.data comaintainers = form.comaintainers.data.strip() or None bz = APP.config.get('PKGDB2_BUGZILLA_URL') pkg_review_url = pkgdblib.check_bz_url(bz, pkg_review_url) try: messages = [] for clt in pkg_collection: message = pkgdblib.add_new_package_request( SESSION, pkg_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=clt, pkg_poc=pkg_poc, pkg_upstream_url=pkg_upstream_url, monitoring_status=monitoring_status, koschei=koschei, comaintainers=comaintainers, user=flask.g.fas_user, ) if message: messages.append(message) SESSION.commit() for message in messages: flask.flash(message) return flask.redirect(flask.url_for('.index')) # 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_request.html', form=form, )