Пример #1
0
def host_country_delete(host_id, host_country_id):
    """ Delete a host_country.
    """
    form = forms.ConfirmationForm()
    if form.validate_on_submit():
        hostobj = mmlib.get_host(SESSION, host_id)

        if hostobj is None:
            flask.abort(404, 'Host not found')

        if not (is_site_admin(flask.g.fas_user, hostobj.site)
                or is_mirrormanager_admin(flask.g.fas_user)):
            flask.abort(403, 'Access denied')

        hostcntobj = mmlib.get_host_country(SESSION, host_country_id)

        if hostcntobj is None:
            flask.abort(404, 'Host Country not found')
        else:
            SESSION.delete(hostcntobj)

        try:
            SESSION.commit()
            flask.flash('Host Country deleted')
        except SQLAlchemyError as err:  # pragma: no cover
            # We check everything before deleting so the only error we could
            # run in is DB server related, and that we can't fake in our
            # tests
            SESSION.rollback()
            flask.flash('Could not delete Country of the host')
            APP.logger.debug('Could not delete Country of the host')
            APP.logger.exception(err)

    return flask.redirect(flask.url_for('host_view', host_id=host_id))
Пример #2
0
def host_country_delete(host_id, host_country_id):
    """ Delete a host_country.
    """
    hostobj = mmlib.get_host(SESSION, host_id)

    if hostobj is None:
        flask.abort(404, 'Host not found')

    hostcntobj = mmlib.get_host_country(SESSION, host_country_id)

    if hostcntobj is None:
        flask.abort(404, 'Host Country not found')
    else:
        SESSION.delete(hostcntobj)

    try:
        SESSION.commit()
        flask.flash('Host Country deleted')
    except SQLAlchemyError as err:
        SESSION.rollback()
        flask.flash('Could not delete Country of the host')
        APP.logger.debug('Could not delete Country of the host')
        APP.logger.exception(err)

    return flask.redirect(flask.url_for('host_view', host_id=host_id))
Пример #3
0
def host_country_delete(host_id, host_country_id):
    """ Delete a host_country.
    """
    form = forms.ConfirmationForm()
    if form.validate_on_submit():
        hostobj = mmlib.get_host(SESSION, host_id)

        if hostobj is None:
            flask.abort(404, 'Host not found')

        if not (is_site_admin(flask.g.fas_user, hostobj.site)
                or is_mirrormanager_admin(flask.g.fas_user)):
            flask.abort(403, 'Access denied')

        hostcntobj = mmlib.get_host_country(SESSION, host_country_id)

        if hostcntobj is None:
            flask.abort(404, 'Host Country not found')
        else:
            SESSION.delete(hostcntobj)

        try:
            SESSION.commit()
            flask.flash('Host Country deleted')
        except SQLAlchemyError as err:  # pragma: no cover
            # We check everything before deleting so the only error we could
            # run in is DB server related, and that we can't fake in our
            # tests
            SESSION.rollback()
            flask.flash('Could not delete Country of the host')
            APP.logger.debug('Could not delete Country of the host')
            APP.logger.exception(err)

    return flask.redirect(flask.url_for('host_view', host_id=host_id))
Пример #4
0
def host_country_delete(host_id, host_country_id):
    """ Delete a host_country.
    """
    hostobj = mmlib.get_host(SESSION, host_id)

    if hostobj is None:
        flask.abort(404, 'Host not found')

    hostcntobj = mmlib.get_host_country(SESSION, host_country_id)

    if hostcntobj is None:
        flask.abort(404, 'Host Country not found')
    else:
        SESSION.delete(hostcntobj)

    try:
        SESSION.commit()
        flask.flash('Host Country deleted')
    except SQLAlchemyError as err:
        SESSION.rollback()
        flask.flash('Could not delete Country of the host')
        APP.logger.debug('Could not delete Country of the host')
        APP.logger.exception(err)

    return flask.redirect(flask.url_for('host_view', host_id=host_id))