Unpin django-ratelimit (#31416)

* fix: fix ratelimit upgrade changes

Co-authored-by: Awais Qureshi <awais.qureshi@arbisoft.com>
This commit is contained in:
Mohammad Ahtasham ul Hassan
2023-01-19 16:39:23 +05:00
committed by GitHub
parent 11e07f06b4
commit b01cf355a7
11 changed files with 35 additions and 33 deletions

View File

@@ -6,7 +6,7 @@ import logging
from django.conf import settings
from django.utils.decorators import method_decorator
from ratelimit.decorators import ratelimit
from django_ratelimit.decorators import ratelimit
from rest_framework.response import Response
from rest_framework.views import APIView
from django.db import transaction
@@ -33,8 +33,12 @@ class CourseSaveForLaterApiView(APIView):
"""
@transaction.atomic
@method_decorator(ratelimit(key=POST_EMAIL_KEY, rate=settings.SAVE_FOR_LATER_EMAIL_RATE_LIMIT, method='POST'))
@method_decorator(ratelimit(key=REAL_IP_KEY, rate=settings.SAVE_FOR_LATER_IP_RATE_LIMIT, method='POST'))
@method_decorator(ratelimit(key=POST_EMAIL_KEY,
rate=settings.SAVE_FOR_LATER_EMAIL_RATE_LIMIT,
method='POST', block=False))
@method_decorator(ratelimit(key=REAL_IP_KEY,
rate=settings.SAVE_FOR_LATER_IP_RATE_LIMIT,
method='POST', block=False))
def post(self, request):
"""
**Use Case**
@@ -124,8 +128,12 @@ class ProgramSaveForLaterApiView(APIView):
"""
@transaction.atomic
@method_decorator(ratelimit(key=POST_EMAIL_KEY, rate=settings.SAVE_FOR_LATER_EMAIL_RATE_LIMIT, method='POST'))
@method_decorator(ratelimit(key=REAL_IP_KEY, rate=settings.SAVE_FOR_LATER_IP_RATE_LIMIT, method='POST'))
@method_decorator(ratelimit(key=POST_EMAIL_KEY,
rate=settings.SAVE_FOR_LATER_EMAIL_RATE_LIMIT,
method='POST', block=False))
@method_decorator(ratelimit(key=REAL_IP_KEY,
rate=settings.SAVE_FOR_LATER_IP_RATE_LIMIT,
method='POST', block=False))
def post(self, request):
"""
**Use Case**

View File

@@ -15,8 +15,8 @@ from django.template import TemplateDoesNotExist
from django.utils.safestring import mark_safe
from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.defaults import permission_denied
from django_ratelimit.exceptions import Ratelimited
from mako.exceptions import TopLevelLookupException
from ratelimit.exceptions import Ratelimited
from common.djangoapps.edxmako.shortcuts import render_to_response, render_to_string
from common.djangoapps.util.cache import cache_if_anonymous