Skip to content

Commit

Permalink
Show error message on trying to delete last dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Nov 21, 2024
1 parent 27b12b5 commit 1e581db
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion python/nav/web/static/js/src/webfront.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ require([
window.location = '/';
});
request.fail(function (response) {
feedback.addFeedback(response, 'error');
feedback.addFeedback(response.responseText, 'error');
});
}
});
Expand Down
3 changes: 2 additions & 1 deletion python/nav/web/webfront/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from urllib.parse import quote as urlquote

from django.http import (
HttpResponseBadRequest,
HttpResponseForbidden,
HttpResponseRedirect,
HttpResponse,
Expand Down Expand Up @@ -428,7 +429,7 @@ def delete_dashboard(request, did):
"""Delete this dashboard and all widgets on it"""
is_last = AccountDashboard.objects.filter(account=request.account).count() == 1
if is_last:
return HttpResponse('Can not delete last dashboard', status=400)
return HttpResponseBadRequest('Cannot delete last dashboard')

dash = get_object_or_404(AccountDashboard, pk=did, account=request.account)
dash.delete()
Expand Down

0 comments on commit 1e581db

Please sign in to comment.