def collection_edit(collection): ''' Allows to edit the information about the specified collection. ''' collections = [] try: collection = pkgdblib.search_collection(SESSION, collection)[0] except NoResultFound: SESSION.rollback() except IndexError: flask.flash('No collection of this name found.', 'errors') return flask.render_template('msg.html') clt_status = pkgdb.lib.get_status(SESSION, 'clt_status')['clt_status'] form = pkgdb.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_publishurl = form.collection_publishURLTemplate.data clt_pendingurl = form.collection_pendingURLTemplate.data clt_summary = form.collection_summary.data clt_description = form.collection_description.data clt_branchname = form.collection_branchname.data clt_disttag = form.collection_distTag.data clt_gitbranch = form.collection_git_branch_name.data try: pkgdblib.edit_collection( SESSION, collection=collection, clt_name=clt_name, clt_version=clt_version, clt_status=clt_status, clt_publishurl=clt_publishurl, clt_pendingurl=clt_pendingurl, clt_summary=clt_summary, clt_description=clt_description, clt_branchname=clt_branchname, clt_disttag=clt_disttag, clt_gitbranch=clt_gitbranch, user=flask.g.fas_user, ) SESSION.commit() flask.flash('Collection "%s" edited' % clt_name) return flask.redirect(flask.url_for( '.collection_info', collection=collection.branchname)) except pkgdblib.PkgdbException, err: SESSION.rollback() flask.flash(err.message, 'errors')
def collection_edit(collection): ''' Allows to edit the information about the specified collection. ''' collections = [] try: collection = pkgdblib.search_collection(SESSION, collection)[0] except NoResultFound: SESSION.rollback() except IndexError: flask.flash('No collection of this name found.', 'errors') return flask.render_template('msg.html') clt_status = pkgdb.lib.get_status(SESSION, 'clt_status')['clt_status'] form = pkgdb.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_publishurl = form.collection_publishURLTemplate.data clt_pendingurl = form.collection_pendingURLTemplate.data clt_summary = form.collection_summary.data clt_description = form.collection_description.data clt_branchname = form.collection_branchname.data clt_disttag = form.collection_distTag.data clt_gitbranch = form.collection_git_branch_name.data try: pkgdblib.edit_collection( SESSION, collection=collection, clt_name=clt_name, clt_version=clt_version, clt_status=clt_status, clt_publishurl=clt_publishurl, clt_pendingurl=clt_pendingurl, clt_summary=clt_summary, clt_description=clt_description, clt_branchname=clt_branchname, clt_disttag=clt_disttag, clt_gitbranch=clt_gitbranch, user=flask.g.fas_user, ) SESSION.commit() flask.flash('Collection "%s" edited' % clt_name) return flask.redirect( flask.url_for('.collection_info', collection=collection.branchname)) except pkgdblib.PkgdbException, err: SESSION.rollback() flask.flash(err.message, 'errors')
def collection_edit(collection): ''' Allows to edit the information about the specified collection. ''' try: collection = pkgdblib.search_collection(SESSION, collection)[0] except IndexError: flask.flash('No collection of this name found.', 'errors') return flask.render_template('msg.html') clt_status = pkgdb.lib.get_status(SESSION, 'clt_status')['clt_status'] form = pkgdb.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 try: pkgdblib.edit_collection( SESSION, collection=collection, clt_name=clt_name, clt_version=clt_version, clt_status=clt_status, clt_branchname=clt_branchname, clt_disttag=clt_disttag, clt_gitbranch=clt_gitbranch, user=flask.g.fas_user, ) SESSION.commit() flask.flash('Collection "%s" edited' % clt_branchname) return flask.redirect(flask.url_for( '.collection_info', collection=collection.branchname)) # In theory we should never hit this except pkgdblib.PkgdbException, err: # pragma: no cover SESSION.rollback() flask.flash(err.message, 'errors')
def test_edit_collection(self): """ Test the edit_collection function. """ create_collection(self.session) collection = pkgdblib.search_collection(self.session, 'F-18')[0] out = pkgdblib.edit_collection(self.session, collection, user=FakeFasUserAdmin()) self.assertEqual(out, None) self.assertRaises(pkgdblib.PkgdbException, pkgdblib.edit_collection, self.session, collection) out = pkgdblib.edit_collection( self.session, collection, clt_name='Fedora youhou!', clt_version='Awesome 18', clt_status='EOL', clt_publishurl='http://.....', clt_pendingurl='http://.....', clt_summary='Fedora awesome release 18', clt_description='This is a description of how cool Fedora is', clt_branchname='f18_b', clt_disttag='fc18', clt_gitbranch='F-18', user=FakeFasUserAdmin(), ) self.assertEqual(out, 'Collection "f18_b" edited') collections = pkgdblib.search_collection(self.session, 'F-18') self.assertEqual(collections, []) collection = pkgdblib.search_collection(self.session, 'f18_b')[0] self.assertEqual(collection.name, 'Fedora youhou!') self.assertEqual(collection.status, 'EOL')