def package_unretire(package, full=True): ''' Asks an admin to unretire the package. ''' if not bool(full) or str(full) in ['0', 'False']: full = False try: package_acl = pkgdblib.get_acl_package(SESSION, package) package = pkgdblib.search_package(SESSION, package, limit=1)[0] except (NoResultFound, IndexError): SESSION.rollback() flask.flash('No package of this name found.', 'errors') return flask.render_template('msg.html') collections = [ acl.collection.branchname for acl in package_acl if acl.collection.status in ['Active', 'Under Development'] and acl.status == 'Retired' ] form = pkgdb2.forms.BranchForm(collections=collections) if form.validate_on_submit(): for acl in package_acl: if acl.collection.branchname in form.branches.data: if acl.point_of_contact == 'orphan': try: pkgdblib.add_unretire_request( session=SESSION, pkg_name=package.name, pkg_branch=acl.collection.branchname, user=flask.g.fas_user, ) flask.flash( 'Admins have been asked to un-retire branch: %s' % acl.collection.branchname) except pkgdblib.PkgdbException, err: # pragma: no cover # We should never hit this flask.flash(str(err), 'error') SESSION.rollback() except SQLAlchemyError, err: SESSION.rollback() flask.flash( 'Could not save the request for branch: %s, has ' 'it already been requested?' % acl.collection.branchname, 'error') else: # pragma: no cover flask.flash( 'This package is not orphaned on branch: %s' % acl.collection.branchname)
def package_unretire(package, full=True): ''' Asks an admin to unretire the package. ''' if not bool(full) or str(full) in ['0', 'False']: full = False try: package_acl = pkgdblib.get_acl_package(SESSION, package) package = pkgdblib.search_package(SESSION, package, limit=1)[0] except (NoResultFound, IndexError): SESSION.rollback() flask.flash('No package of this name found.', 'errors') return flask.render_template('msg.html') collections = [ acl.collection.branchname for acl in package_acl if acl.collection.status in ['Active', 'Under Development'] and acl.status == 'Retired' ] form = pkgdb2.forms.BranchForm(collections=collections) if form.validate_on_submit(): for acl in package_acl: if acl.collection.branchname in form.branches.data: if acl.point_of_contact == 'orphan': try: pkgdblib.add_unretire_request( session=SESSION, pkg_name=package.name, pkg_branch=acl.collection.branchname, user=flask.g.fas_user, ) flask.flash( 'Admins have been asked to un-retire branch: %s' % acl.collection.branchname) except pkgdblib.PkgdbException, err: # pragma: no cover # We should never hit this flask.flash(str(err), 'error') SESSION.rollback() except SQLAlchemyError, err: SESSION.rollback() flask.flash( 'Could not save the request for branch: %s, has ' 'it already been requested?' % acl.collection.branchname, 'error') else: # pragma: no cover flask.flash('This package is not orphaned on branch: %s' % acl.collection.branchname)
def package_unretire(namespace, package, full=True): ''' Asks an admin to unretire the package. ''' if not bool(full) or str(full) in ['0', 'False']: full = False try: package_acl = pkgdblib.get_acl_package( SESSION, namespace, package) package = pkgdblib.search_package( SESSION, namespace, package, limit=1)[0] except (NoResultFound, IndexError): SESSION.rollback() flask.flash('No package of this name found.', 'errors') return flask.render_template('msg.html') # Get the list of retired branches retire_collections = [ acl.collection.branchname for acl in package_acl if acl.collection.status in ['Active', 'Under Development'] and acl.status == 'Retired' ] # Get the list of all the collections active or under development collections = [ collection.branchname for collection in pkgdb2.lib.search_collection(SESSION, '*', 'Under Development') if collection.branchname in retire_collections ] collections.reverse() active_collections = pkgdb2.lib.search_collection(SESSION, '*', 'Active') active_collections.reverse() cnt = 0 # Restrict the Fedora branch to 2 active versions for collection in active_collections: if collection.name.lower() == 'fedora': if cnt >= 2: continue cnt += 1 if collection.branchname not in retire_collections: continue collections.append(collection.branchname) form = pkgdb2.forms.UnretireForm(collections=collections) if form.validate_on_submit(): review_url = form.review_url.data review_url = review_url.strip() if review_url else None checks_ok = True # Check the review URL bz = APP.config.get('PKGDB2_BUGZILLA_URL') review_url = pkgdblib.check_bz_url(bz, review_url) for br in form.branches.data: if br.startswith('e') \ and 'master' in collections \ and not review_url: checks_ok = False flask.flash( 'You must provide a valid review URL to un-retire an ' 'EPEL branch if master is also retired', 'error') break if not checks_ok: return flask.redirect(flask.url_for( '.package_info', namespace=package.namespace, package=package.name) ) for acl in package_acl: if acl.collection.branchname in form.branches.data: if acl.point_of_contact == 'orphan': try: pkgdblib.add_unretire_request( session=SESSION, namespace=namespace, pkg_name=package.name, pkg_branch=acl.collection.branchname, review_url=review_url, user=flask.g.fas_user, ) flask.flash( 'Admins have been asked to un-retire branch: %s' % acl.collection.branchname) except PkgdbException as err: # pragma: no cover # We should never hit this flask.flash(str(err), 'error') SESSION.rollback() except SQLAlchemyError as err: APP.logger.exception(err) SESSION.rollback() flask.flash( 'Could not save the request for branch: %s, has ' 'it already been requested?' % acl.collection.branchname, 'error') else: # pragma: no cover flask.flash( 'This package is not orphaned on branch: %s' % acl.collection.branchname) try: SESSION.commit() # Keep it in, but normally we shouldn't hit this except PkgdbException as err: # pragma: no cover # We should never hit this SESSION.rollback() APP.logger.exception(err) flask.flash(str(err), 'error') return flask.redirect(flask.url_for( '.package_info', namespace=package.namespace, package=package.name) ) return flask.render_template( 'request_unretire.html', full=full, package=package, form=form, action='unretire', )
def package_unretire(namespace, package, full=True): ''' Asks an admin to unretire the package. ''' if not bool(full) or str(full) in ['0', 'False']: full = False try: package_acl = pkgdblib.get_acl_package(SESSION, namespace, package) package = pkgdblib.search_package(SESSION, namespace, package, limit=1)[0] except (NoResultFound, IndexError): SESSION.rollback() flask.flash('No package of this name found.', 'errors') return flask.render_template('msg.html') # Get the list of retired branches retire_collections = [ acl.collection.branchname for acl in package_acl if acl.collection.status in ['Active', 'Under Development'] and acl.status == 'Retired' ] # Get the list of all the collections active or under development collections = [ collection.branchname for collection in pkgdb2.lib.search_collection( SESSION, '*', 'Under Development') if collection.branchname in retire_collections ] collections.reverse() active_collections = pkgdb2.lib.search_collection(SESSION, '*', 'Active') active_collections.reverse() cnt = 0 # Restrict the Fedora branch to 2 active versions for collection in active_collections: if collection.name.lower() == 'fedora': if cnt >= 2: continue cnt += 1 if collection.branchname not in retire_collections: continue collections.append(collection.branchname) form = pkgdb2.forms.UnretireForm(collections=collections) if form.validate_on_submit(): review_url = form.review_url.data review_url = review_url.strip() if review_url else None checks_ok = True for br in form.branches.data: if br == 'master' and not review_url: checks_ok = False flask.flash( 'You must provide a review URL to un-retire master', 'error') break elif br.startswith( 'e') and 'master' in collections and not review_url: checks_ok = False flask.flash( 'You must provide a review URL to un-retire an EPEL ' 'branch if master is also retired', 'error') break if not checks_ok: return flask.redirect( flask.url_for('.package_info', namespace=package.namespace, package=package.name)) for acl in package_acl: if acl.collection.branchname in form.branches.data: if acl.point_of_contact == 'orphan': try: pkgdblib.add_unretire_request( session=SESSION, namespace=namespace, pkg_name=package.name, pkg_branch=acl.collection.branchname, review_url=form.review_url.data, user=flask.g.fas_user, ) flask.flash( 'Admins have been asked to un-retire branch: %s' % acl.collection.branchname) except pkgdblib.PkgdbException, err: # pragma: no cover # We should never hit this flask.flash(str(err), 'error') SESSION.rollback() except SQLAlchemyError, err: SESSION.rollback() flask.flash( 'Could not save the request for branch: %s, has ' 'it already been requested?' % acl.collection.branchname, 'error') else: # pragma: no cover flask.flash('This package is not orphaned on branch: %s' % acl.collection.branchname)