From bae21b14c93e458014107a007e894e93a181bd0e Mon Sep 17 00:00:00 2001 From: markotibold Date: Sat, 25 Jun 2011 16:38:16 +0200 Subject: added a container view for the permissions example --- examples/permissionsexample/views.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'examples/permissionsexample/views.py') diff --git a/examples/permissionsexample/views.py b/examples/permissionsexample/views.py index 20e7cba7..ca456191 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,10 @@ 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 LoggedinView(View): + + permissions = (IsAuthenticated, ) + def get(self, request): + return 'Logged in or not?' \ No newline at end of file -- cgit v1.2.3 From 8cab127c2a99ab027e981f3e9198b7c548f0aa46 Mon Sep 17 00:00:00 2001 From: markotibold Date: Sun, 26 Jun 2011 01:38:56 +0200 Subject: some restyling and updated requirements.txt for yaml support --- examples/permissionsexample/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'examples/permissionsexample/views.py') diff --git a/examples/permissionsexample/views.py b/examples/permissionsexample/views.py index ca456191..f95c2c84 100644 --- a/examples/permissionsexample/views.py +++ b/examples/permissionsexample/views.py @@ -29,8 +29,10 @@ class ThrottlingExampleView(View): """ return "Successful response to GET request because throttle is not yet active." -class LoggedinView(View): - +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 -- cgit v1.2.3