mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-03 13:14:30 +03:00
Cleanup authentication example
This commit is contained in:
parent
1d9f24f60d
commit
9ce864e63b
|
@ -2,14 +2,23 @@ from djangorestframework.views import View
|
|||
from djangorestframework.permissions import PerUserThrottling, IsAuthenticated
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
|
||||
class PermissionsExampleView(View):
|
||||
"""
|
||||
A container view for permissions examples.
|
||||
"""
|
||||
|
||||
def get(self, request):
|
||||
return [{'name': 'Throttling Example', 'url': reverse('throttled-resource')},
|
||||
{'name': 'Logged in example', 'url': reverse('loggedin-resource')},]
|
||||
return [
|
||||
{
|
||||
'name': 'Throttling Example',
|
||||
'url': reverse('throttled-resource')
|
||||
},
|
||||
{
|
||||
'name': 'Logged in example',
|
||||
'url': reverse('loggedin-resource')
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
class ThrottlingExampleView(View):
|
||||
|
@ -29,6 +38,7 @@ class ThrottlingExampleView(View):
|
|||
"""
|
||||
return "Successful response to GET request because throttle is not yet active."
|
||||
|
||||
|
||||
class LoggedInExampleView(View):
|
||||
"""
|
||||
You can login with **'test', 'test'.** or use curl:
|
||||
|
@ -37,5 +47,6 @@ class LoggedInExampleView(View):
|
|||
"""
|
||||
|
||||
permissions = (IsAuthenticated, )
|
||||
|
||||
def get(self, request):
|
||||
return 'Logged in or not?'
|
||||
return 'You have permission to view this resource'
|
||||
|
|
Loading…
Reference in New Issue
Block a user