diff options
Diffstat (limited to 'examples/permissionsexample/views.py')
| -rw-r--r-- | examples/permissionsexample/views.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/examples/permissionsexample/views.py b/examples/permissionsexample/views.py index 20e7cba7..f95c2c84 100644 --- a/examples/permissionsexample/views.py +++ b/examples/permissionsexample/views.py @@ -1,6 +1,16 @@ from djangorestframework.views import View -from djangorestframework.permissions import PerUserThrottling +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')},] + class ThrottlingExampleView(View): """ @@ -17,4 +27,12 @@ class ThrottlingExampleView(View): """ Handle GET requests. """ - return "Successful response to GET request because throttle is not yet active."
\ No newline at end of file + return "Successful response to GET request because throttle is not yet active." + +class LoggedInExampleView(View): + """ + You can login with **'test', 'test'.** + """ + permissions = (IsAuthenticated, ) + def get(self, request): + return 'Logged in or not?'
\ No newline at end of file |
