Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
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
django-rest-framework
Commits
9ce864e6
Commit
9ce864e6
authored
Jan 24, 2012
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup authentication example
parent
1d9f24f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
6 deletions
+17
-6
examples/permissionsexample/views.py
+17
-6
No files found.
examples/permissionsexample/views.py
View file @
9ce864e6
...
@@ -2,14 +2,23 @@ from djangorestframework.views import View
...
@@ -2,14 +2,23 @@ from djangorestframework.views import View
from
djangorestframework.permissions
import
PerUserThrottling
,
IsAuthenticated
from
djangorestframework.permissions
import
PerUserThrottling
,
IsAuthenticated
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
class
PermissionsExampleView
(
View
):
class
PermissionsExampleView
(
View
):
"""
"""
A container view for permissions examples.
A container view for permissions examples.
"""
"""
def
get
(
self
,
request
):
def
get
(
self
,
request
):
return
[{
'name'
:
'Throttling Example'
,
'url'
:
reverse
(
'throttled-resource'
)},
return
[
{
'name'
:
'Logged in example'
,
'url'
:
reverse
(
'loggedin-resource'
)},]
{
'name'
:
'Throttling Example'
,
'url'
:
reverse
(
'throttled-resource'
)
},
{
'name'
:
'Logged in example'
,
'url'
:
reverse
(
'loggedin-resource'
)
},
]
class
ThrottlingExampleView
(
View
):
class
ThrottlingExampleView
(
View
):
...
@@ -20,7 +29,7 @@ class ThrottlingExampleView(View):
...
@@ -20,7 +29,7 @@ class ThrottlingExampleView(View):
throttle will be applied until 60 seconds have passed since the first request.
throttle will be applied until 60 seconds have passed since the first request.
"""
"""
permissions
=
(
PerUserThrottling
,
)
permissions
=
(
PerUserThrottling
,
)
throttle
=
'10/min'
throttle
=
'10/min'
def
get
(
self
,
request
):
def
get
(
self
,
request
):
...
@@ -29,13 +38,15 @@ class ThrottlingExampleView(View):
...
@@ -29,13 +38,15 @@ class ThrottlingExampleView(View):
"""
"""
return
"Successful response to GET request because throttle is not yet active."
return
"Successful response to GET request because throttle is not yet active."
class
LoggedInExampleView
(
View
):
class
LoggedInExampleView
(
View
):
"""
"""
You can login with **'test', 'test'.** or use curl:
You can login with **'test', 'test'.** or use curl:
`curl -X GET -H 'Accept: application/json' -u test:test http://localhost:8000/permissions-example`
`curl -X GET -H 'Accept: application/json' -u test:test http://localhost:8000/permissions-example`
"""
"""
permissions
=
(
IsAuthenticated
,
)
permissions
=
(
IsAuthenticated
,
)
def
get
(
self
,
request
):
def
get
(
self
,
request
):
return
'
Logged in or not?
'
return
'
You have permission to view this resource
'
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