From 25e9d5c03cba7a1ebfedd47dbb2eaee038edea74 Mon Sep 17 00:00:00 2001 From: FrankApiyo Date: Tue, 27 Aug 2024 12:43:37 +0300 Subject: [PATCH] Make submission_request_method_to_throttle configurable --- onadata/libs/throttle.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/onadata/libs/throttle.py b/onadata/libs/throttle.py index 32cdddb4ed..5dfd1b06d6 100644 --- a/onadata/libs/throttle.py +++ b/onadata/libs/throttle.py @@ -24,7 +24,13 @@ def get_form_owner_or_project_from_url(self, url): return None def get_cache_key(self, request, _): - if (request.method == 'POST' and '/submission' in request.path + request_methods_to_throttle = getattr( + settings, + "SUBMISSION_REQUEST_METHODS_TO_THROTTLE", + ['POST'] + ) + if (request.method in request_methods_to_throttle + and '/submission' in request.path and self.get_form_owner_or_project_from_url(request.path)): return f"throttle_method_{request.method}_path_{request.path}" return None