remove dead code, update middleware
This commit is contained in:
@@ -16,16 +16,15 @@ def get_debug_info():
|
||||
EXCLUDE_PATHS = (
|
||||
"/api/v3",
|
||||
"/api/v2",
|
||||
"/api/v1",
|
||||
"/logs/auditlogs",
|
||||
"/winupdate/winupdater",
|
||||
"/winupdate/results",
|
||||
f"/{settings.ADMIN_URL}",
|
||||
"/logout",
|
||||
"/agents/installagent",
|
||||
"/logs/downloadlog",
|
||||
)
|
||||
|
||||
ENDS_WITH = "/refreshedservices/"
|
||||
|
||||
|
||||
class AuditMiddleware:
|
||||
def __init__(self, get_response):
|
||||
@@ -37,7 +36,9 @@ class AuditMiddleware:
|
||||
return response
|
||||
|
||||
def process_view(self, request, view_func, view_args, view_kwargs):
|
||||
if not request.path.startswith(EXCLUDE_PATHS):
|
||||
if not request.path.startswith(EXCLUDE_PATHS) and not request.path.endswith(
|
||||
ENDS_WITH
|
||||
):
|
||||
# https://stackoverflow.com/questions/26240832/django-and-middleware-which-uses-request-user-is-always-anonymous
|
||||
try:
|
||||
# DRF saves the class of the view function as the .cls property
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
from django.urls import path
|
||||
from . import views
|
||||
from apiv3 import views as v3_views
|
||||
|
||||
urlpatterns = [
|
||||
path("<int:pk>/getwinupdates/", views.get_win_updates),
|
||||
path("<int:pk>/runupdatescan/", views.run_update_scan),
|
||||
path("editpolicy/", views.edit_policy),
|
||||
path("winupdater/", views.win_updater),
|
||||
path("results/", v3_views.WinUpdater.as_view()),
|
||||
path("<int:pk>/installnow/", views.install_updates),
|
||||
]
|
||||
|
||||
@@ -58,20 +58,3 @@ def edit_policy(request):
|
||||
patch.action = request.data["policy"]
|
||||
patch.save(update_fields=["action"])
|
||||
return Response("ok")
|
||||
|
||||
|
||||
@api_view()
|
||||
@authentication_classes((TokenAuthentication,))
|
||||
@permission_classes((IsAuthenticated,))
|
||||
def win_updater(request):
|
||||
agent = get_object_or_404(Agent, agent_id=request.data["agent_id"])
|
||||
agent.delete_superseded_updates()
|
||||
patches = (
|
||||
WinUpdate.objects.filter(agent=agent)
|
||||
.exclude(installed=True)
|
||||
.filter(action="approve")
|
||||
)
|
||||
if patches:
|
||||
return Response(ApprovedUpdateSerializer(patches, many=True).data)
|
||||
|
||||
return Response("nopatches")
|
||||
Reference in New Issue
Block a user