fix: return right 404
This commit is contained in:
parent
cb493ed24b
commit
6d462b6cbf
1 changed files with 3 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
from django.shortcuts import render, get_object_or_404, redirect
|
||||
from django.http import HttpRequest, HttpResponseNotAllowed, Http404, HttpResponseBadRequest
|
||||
from django.http import HttpRequest, HttpResponseNotAllowed, HttpResponseNotFound, HttpResponseBadRequest
|
||||
from .models import UserConnection
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from .dj_wg_manager import DJWGManager
|
||||
|
@ -45,7 +45,7 @@ def toggle_connection(request: HttpRequest, connection_id: int):
|
|||
return HttpResponseBadRequest("invalid state")
|
||||
connection = get_object_or_404(UserConnection, pk=connection_id)
|
||||
if connection.user != request.user and not request.user.is_superuser:
|
||||
return Http404()
|
||||
return HttpResponseNotFound()
|
||||
wg_manager = DJWGManager()
|
||||
match request.POST["state"]:
|
||||
case "enabled":
|
||||
|
@ -59,7 +59,7 @@ def toggle_connection(request: HttpRequest, connection_id: int):
|
|||
def delete_connection(request: HttpRequest, connection_id: int):
|
||||
connection = get_object_or_404(UserConnection, pk=connection_id)
|
||||
if connection.user != request.user and not request.user.is_superuser:
|
||||
return Http404()
|
||||
return HttpResponseNotFound()
|
||||
# sync and disable before delete
|
||||
wg_manager = DJWGManager()
|
||||
wg_manager.sync()
|
||||
|
|
Loading…
Reference in a new issue