diff --git a/mirrormanager2/views.py b/mirrormanager2/views.py index 630d72e7..626b0cdc 100644 --- a/mirrormanager2/views.py +++ b/mirrormanager2/views.py @@ -960,6 +960,10 @@ def host_category_url_new(host_id, hc_id): url = url[:-1] host_category_u.url = url + if url in [url.url for url in hcobj.urls]: + flask.flash(f"URL Not Added: {url} already exists on {hcobj.category.name}", "error") + return flask.redirect(flask.url_for("base.host_view", host_id=host_id)) + # If the user is *not* an admin, keep the current private flag if not is_mirrormanager_admin(flask.g.fas_user): host_category_u.private = private diff --git a/tests/test_ui_app.py b/tests/test_ui_app.py index 61f7e6af..c2259fd3 100644 --- a/tests/test_ui_app.py +++ b/tests/test_ui_app.py @@ -1101,7 +1101,7 @@ def test_host_category_url_new_auth(client, user): output = client.post("/host/2/category/3/url/new", data=post_data, follow_redirects=True) assert output.status_code == 200 data = output.get_data(as_text=True) - assert "Could not add Category URL to the host" in data + assert "URL Not Added: http://pingoured.fr/pub/Fedora already exists on Fedora Linux" in data assert '