Exemplo n.º 1
0
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 = pkgdblib.get_status(SESSION, 'clt_status')['clt_status']
    form = pkgdb2.forms.AddCollectionForm(
        clt_status=clt_status
    )

    if form.validate_on_submit():
        clt_name = form.clt_name.data
        clt_version = form.version.data
        clt_status = form.clt_status.data
        clt_branchname = form.branchname.data
        clt_disttag = form.dist_tag.data
        clt_koji_name = form.kojiname.data
        clt_allow_retire = form.allow_retire.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_koji_name=clt_koji_name,
                clt_allow_retire=clt_allow_retire,
                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 PkgdbException as err:  # pragma: no cover
            SESSION.rollback()
            flask.flash(str(err), 'errors')
    elif flask.request.method == 'GET':
        form = pkgdb2.forms.AddCollectionForm(
            clt_status=clt_status,
            collection=collection
        )

    return flask.render_template(
        'collection_edit.html',
        form=form,
        collection=collection,
    )
Exemplo n.º 2
0
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 = pkgdblib.get_status(SESSION, 'clt_status')['clt_status']
    form = pkgdb2.forms.AddCollectionForm(clt_status=clt_status)

    if form.validate_on_submit():
        clt_name = form.clt_name.data
        clt_version = form.version.data
        clt_status = form.clt_status.data
        clt_branchname = form.branchname.data
        clt_disttag = form.dist_tag.data
        clt_koji_name = form.kojiname.data
        clt_allow_retire = form.allow_retire.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_koji_name=clt_koji_name,
                clt_allow_retire=clt_allow_retire,
                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 PkgdbException as err:  # pragma: no cover
            SESSION.rollback()
            flask.flash(str(err), 'errors')
    elif flask.request.method == 'GET':
        form = pkgdb2.forms.AddCollectionForm(clt_status=clt_status,
                                              collection=collection)

    return flask.render_template(
        'collection_edit.html',
        form=form,
        collection=collection,
    )