mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-09 16:10:50 +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 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):
|
||||||
|
@ -29,6 +38,7 @@ 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:
|
||||||
|
@ -37,5 +47,6 @@ class LoggedInExampleView(View):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
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'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user