Skip to content

Commit 1667c8c

Browse files
dogboatMaffooch
andauthored
error message when viewing non-URL (#14421)
* helpful error message rather than crash when trying to view non-URL in URL view * Update dojo/url/ui/views.py --------- Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com>
1 parent 9480d4e commit 1667c8c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

dojo/url/ui/views.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from django.core.exceptions import PermissionDenied, ValidationError
99
from django.core.management import call_command
1010
from django.db import DEFAULT_DB_ALIAS
11-
from django.http import HttpRequest, HttpResponseRedirect
11+
from django.http import Http404, HttpRequest, HttpResponseRedirect
1212
from django.shortcuts import get_object_or_404, render
1313
from django.urls import reverse
1414
from django.utils import timezone
@@ -100,6 +100,14 @@ def process_endpoint_view(request: HttpRequest, location_id: int, *, host_view=F
100100
101101
"""
102102
location = get_object_or_404(Location, id=location_id)
103+
if location.location_type != URL.get_location_type():
104+
messages.add_message(
105+
request,
106+
messages.ERROR,
107+
"Viewing this object is only available in the Pro UI.",
108+
extra_tags="alert-danger",
109+
)
110+
raise Http404
103111
host = location.url.host
104112
locations = None
105113
metadata = None

0 commit comments

Comments
 (0)