Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
course-discovery
Commits
0fe2d40f
Commit
0fe2d40f
authored
Apr 22, 2016
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated throttle
ECOM-4277
parent
2f2cb5a5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
6 deletions
+3
-6
course_discovery/apps/core/tests/test_throttles.py
+0
-5
course_discovery/apps/core/throttles.py
+3
-1
No files found.
course_discovery/apps/core/tests/test_throttles.py
View file @
0fe2d40f
from
django.core.cache
import
cache
from
django.core.urlresolvers
import
reverse
from
rest_framework.test
import
APITestCase
from
course_discovery.apps.core.models
import
UserThrottleRate
...
...
@@ -48,7 +47,3 @@ class RateLimitingTest(APITestCase):
self
.
user
.
save
()
response
=
self
.
_make_requests
()
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_anonymous_throttling
(
self
):
self
.
client
.
logout
()
self
.
test_rate_limiting
()
course_discovery/apps/core/throttles.py
View file @
0fe2d40f
...
...
@@ -9,9 +9,10 @@ class OverridableUserRateThrottle(UserRateThrottle):
def
allow_request
(
self
,
request
,
view
):
user
=
request
.
user
if
user
and
user
.
is_authenticated
():
if
user
.
is_superuser
:
return
True
if
not
user
.
is_anonymous
():
try
:
# Override this throttle's rate if applicable
user_throttle
=
UserThrottleRate
.
objects
.
get
(
user
=
user
)
...
...
@@ -19,4 +20,5 @@ class OverridableUserRateThrottle(UserRateThrottle):
self
.
num_requests
,
self
.
duration
=
self
.
parse_rate
(
self
.
rate
)
except
UserThrottleRate
.
DoesNotExist
:
pass
return
super
(
OverridableUserRateThrottle
,
self
)
.
allow_request
(
request
,
view
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment