Skip to content

Commit

Permalink
fix: unhandled Http404 error
Browse files Browse the repository at this point in the history
Signed-off-by: Trey <[email protected]>
  • Loading branch information
TreyWW committed Jun 19, 2024
1 parent 15a73b5 commit f0ee9c4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
5 changes: 0 additions & 5 deletions backend/api/clients/delete.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
from typing import Literal

from django.contrib import messages
from django.http.response import HttpResponse
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from django.views.decorators.http import require_http_methods

from backend.models import Client
from backend.service.clients.delete import delete_client
from backend.types.htmx import HtmxHttpRequest


@require_http_methods(["DELETE"])
@login_required
def client_delete(request: HtmxHttpRequest, id: int):
response: str | Literal[True] = delete_client(request, id)

if isinstance(response, str):
messages.error(request, response)
else:
messages.success(request, f"Successfully deleted client #{id}")

return render(request, "base/toast.html")
2 changes: 1 addition & 1 deletion backend/service/clients/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def validate_client(request, client_id: str | int, *, get_defaults: bool = False
if get_defaults:
client_query = client_query.select_related("client_defaults")

client = get_object_or_404(client_query, id=client_id)
client = client_query.get(id=client_id)

if not client.has_access(request.user):
raise PermissionDenied
Expand Down

0 comments on commit f0ee9c4

Please sign in to comment.