예제 #1
0
def api_package_new():
    ''' Create a new package.

    :arg packagename: String of the package name to be created.
    :arg summary: String of the summary description of the package.

    '''
    httpcode = 200
    output = {}

    collections = pkgdb.lib.search_collection(SESSION, '*',
                                              'Under Development')
    collections.extend(pkgdb.lib.search_collection(SESSION, '*', 'Active'))
    pkg_status = pkgdb.lib.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.pkg_name.data
        pkg_summary = form.pkg_summary.data
        pkg_reviewURL = form.pkg_reviewURL.data
        pkg_status = form.pkg_status.data
        pkg_shouldopen = form.pkg_shouldopen.data
        pkg_collection = form.pkg_collection.data
        pkg_owner = form.pkg_owner.data
        pkg_upstreamURL = form.pkg_upstreamURL.data

        try:
            message = pkgdblib.add_package(SESSION,
                                           pkg_name=pkg_name,
                                           pkg_summary=pkg_summary,
                                           pkg_reviewURL=pkg_reviewURL,
                                           pkg_status=pkg_status,
                                           pkg_shouldopen=pkg_shouldopen,
                                           pkg_collection=pkg_collection,
                                           pkg_owner=pkg_owner,
                                           pkg_upstreamURL=pkg_upstreamURL,
                                           user=flask.g.fas_user)
            SESSION.commit()
            output['output'] = 'ok'
            output['messages'] = [message]
        except pkgdblib.PkgdbException, err:
            SESSION.rollback()
            output['output'] = 'notok'
            output['error'] = err
            httpcode = 500
예제 #2
0
def package_new():
    ''' Page to create a new package. '''

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

    form = pkgdb.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(err.message, 'error')
예제 #3
0
def api_package_new():
    """ Create a new package.

    :arg packagename: String of the package name to be created.
    :arg summary: String of the summary description of the package.

    """
    httpcode = 200
    output = {}

    collections = pkgdb.lib.search_collection(SESSION, "*", "Under Development")
    collections.extend(pkgdb.lib.search_collection(SESSION, "*", "Active"))
    pkg_status = pkgdb.lib.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.pkg_name.data
        pkg_summary = form.pkg_summary.data
        pkg_reviewURL = form.pkg_reviewURL.data
        pkg_status = form.pkg_status.data
        pkg_shouldopen = form.pkg_shouldopen.data
        pkg_collection = form.pkg_collection.data
        pkg_owner = form.pkg_owner.data
        pkg_upstreamURL = form.pkg_upstreamURL.data

        try:
            message = pkgdblib.add_package(
                SESSION,
                pkg_name=pkg_name,
                pkg_summary=pkg_summary,
                pkg_reviewURL=pkg_reviewURL,
                pkg_status=pkg_status,
                pkg_shouldopen=pkg_shouldopen,
                pkg_collection=pkg_collection,
                pkg_owner=pkg_owner,
                pkg_upstreamURL=pkg_upstreamURL,
                user=flask.g.fas_user,
            )
            SESSION.commit()
            output["output"] = "ok"
            output["messages"] = [message]
        except pkgdblib.PkgdbException, err:
            SESSION.rollback()
            output["output"] = "notok"
            output["error"] = err
            httpcode = 500
예제 #4
0
def package_new():
    ''' Page to create a new package. '''

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

    form = pkgdb.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_reviewURL = form.pkg_reviewURL.data
        pkg_status = form.pkg_status.data
        pkg_shouldopen = form.pkg_shouldopen.data
        pkg_collection = form.pkg_collection.data
        pkg_poc = form.pkg_poc.data
        pkg_upstreamURL = form.pkg_upstreamURL.data

        try:
            message = pkgdblib.add_package(
                SESSION,
                pkg_name=pkg_name,
                pkg_summary=pkg_summary,
                pkg_reviewURL=pkg_reviewURL,
                pkg_status=pkg_status,
                pkg_shouldopen=pkg_shouldopen,
                pkg_collection=pkg_collection,
                pkg_poc=pkg_poc,
                pkg_upstreamURL=pkg_upstreamURL,
                user=flask.g.fas_user,
            )
            SESSION.commit()
            flask.flash(message)
            return flask.redirect(flask.url_for('.list_packages'))
        except pkgdblib.PkgdbException, err:
            SESSION.rollback()
            flask.flash(err.message, 'error')
예제 #5
0
    def test_add_package(self):
        """ Test the add_package function. """
        create_collection(self.session)

        self.assertRaises(pkgdblib.PkgdbException,
                          pkgdblib.add_package,
                          self.session,
                          pkg_name='test',
                          pkg_summary='test package',
                          pkg_status='Approved',
                          pkg_collection='F-18',
                          pkg_poc='ralph',
                          pkg_reviewURL=None,
                          pkg_shouldopen=None,
                          pkg_upstreamURL='http://example.org',
                          user=FakeFasUser())
        self.session.rollback()

        self.assertRaises(pkgdblib.PkgdbException,
                          pkgdblib.add_package,
                          self.session,
                          pkg_name='test',
                          pkg_summary='test package',
                          pkg_status='Approved',
                          pkg_collection='F-18',
                          pkg_poc='group::tests',
                          pkg_reviewURL=None,
                          pkg_shouldopen=None,
                          pkg_upstreamURL='http://example.org',
                          user=FakeFasUserAdmin())
        self.session.rollback()

        msg = pkgdblib.add_package(self.session,
                                   pkg_name='guake',
                                   pkg_summary='Drop down terminal',
                                   pkg_status='Approved',
                                   pkg_collection='F-18',
                                   pkg_poc='ralph',
                                   pkg_reviewURL=None,
                                   pkg_shouldopen=None,
                                   pkg_upstreamURL='http://guake.org',
                                   user=FakeFasUserAdmin())
        self.assertEqual(msg, 'Package created')
        self.session.commit()
        packages = model.Package.all(self.session)
        self.assertEqual(1, len(packages))
        self.assertEqual('guake', packages[0].name)

        pkgdblib.add_package(self.session,
                             pkg_name='geany',
                             pkg_summary='GTK IDE',
                             pkg_status='Approved',
                             pkg_collection='devel, F-18',
                             pkg_poc='ralph',
                             pkg_reviewURL=None,
                             pkg_shouldopen=None,
                             pkg_upstreamURL=None,
                             user=FakeFasUserAdmin())
        self.session.commit()
        packages = model.Package.all(self.session)
        self.assertEqual(2, len(packages))
        self.assertEqual('guake', packages[0].name)
        self.assertEqual('geany', packages[1].name)

        pkgdblib.add_package(self.session,
                             pkg_name='fedocal',
                             pkg_summary='web calendar for Fedora',
                             pkg_status='Approved',
                             pkg_collection='devel, F-18',
                             pkg_poc='group::infra-sig',
                             pkg_reviewURL=None,
                             pkg_shouldopen=None,
                             pkg_upstreamURL=None,
                             user=FakeFasUserAdmin())
        self.session.commit()
        packages = model.Package.all(self.session)
        self.assertEqual(3, len(packages))
        self.assertEqual('guake', packages[0].name)
        self.assertEqual('geany', packages[1].name)
        self.assertEqual('fedocal', packages[2].name)
예제 #6
0
    def test_add_package(self):
        """ Test the add_package function. """
        create_collection(self.session)

        self.assertRaises(pkgdblib.PkgdbException,
                          pkgdblib.add_package,
                          self.session,
                          pkg_name='test',
                          pkg_summary='test package',
                          pkg_status='Approved',
                          pkg_collection='F-18',
                          pkg_poc='ralph',
                          pkg_reviewURL=None,
                          pkg_shouldopen=None,
                          pkg_upstreamURL='http://example.org',
                          user=FakeFasUser()
                          )
        self.session.rollback()

        self.assertRaises(pkgdblib.PkgdbException,
                          pkgdblib.add_package,
                          self.session,
                          pkg_name='test',
                          pkg_summary='test package',
                          pkg_status='Approved',
                          pkg_collection='F-18',
                          pkg_poc='group::tests',
                          pkg_reviewURL=None,
                          pkg_shouldopen=None,
                          pkg_upstreamURL='http://example.org',
                          user=FakeFasUserAdmin()
                          )
        self.session.rollback()

        msg = pkgdblib.add_package(self.session,
                                    pkg_name='guake',
                                    pkg_summary='Drop down terminal',
                                    pkg_status='Approved',
                                    pkg_collection='F-18',
                                    pkg_poc='ralph',
                                    pkg_reviewURL=None,
                                    pkg_shouldopen=None,
                                    pkg_upstreamURL='http://guake.org',
                                    user=FakeFasUserAdmin())
        self.assertEqual(msg, 'Package created')
        self.session.commit()
        packages = model.Package.all(self.session)
        self.assertEqual(1, len(packages))
        self.assertEqual('guake', packages[0].name)

        pkgdblib.add_package(self.session,
                             pkg_name='geany',
                             pkg_summary='GTK IDE',
                             pkg_status='Approved',
                             pkg_collection='devel, F-18',
                             pkg_poc='ralph',
                             pkg_reviewURL=None,
                             pkg_shouldopen=None,
                             pkg_upstreamURL=None,
                             user=FakeFasUserAdmin())
        self.session.commit()
        packages = model.Package.all(self.session)
        self.assertEqual(2, len(packages))
        self.assertEqual('guake', packages[0].name)
        self.assertEqual('geany', packages[1].name)

        pkgdblib.add_package(self.session,
                             pkg_name='fedocal',
                             pkg_summary='web calendar for Fedora',
                             pkg_status='Approved',
                             pkg_collection='devel, F-18',
                             pkg_poc='group::infra-sig',
                             pkg_reviewURL=None,
                             pkg_shouldopen=None,
                             pkg_upstreamURL=None,
                             user=FakeFasUserAdmin())
        self.session.commit()
        packages = model.Package.all(self.session)
        self.assertEqual(3, len(packages))
        self.assertEqual('guake', packages[0].name)
        self.assertEqual('geany', packages[1].name)
        self.assertEqual('fedocal', packages[2].name)