From 5f69581e17eb18406281c4767345a27abf0bc9b3 Mon Sep 17 00:00:00 2001 From: Randall Degges Date: Mon, 21 Feb 2011 09:01:43 -0800 Subject: [PATCH 1/4] Removing trailing whitespace. --- docs/create_custom_permission.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/create_custom_permission.txt b/docs/create_custom_permission.txt index f9210d8..4630e19 100644 --- a/docs/create_custom_permission.txt +++ b/docs/create_custom_permission.txt @@ -25,12 +25,12 @@ A custom permission is a simple method of the permission class:: class FlatpagePermission(permissions.BasePermission): label = 'flatpage_permission' checks = ('my_custom_check',) - + def my_custom_check(self, flatpage): if(flatpage.url == '/about/'): return True return False - + authority.register(Flatpage, FlatpagePermission) Note that we first added the name of your custom permission to the ``checks`` @@ -47,7 +47,7 @@ permission is True or False:: return True return False -.. warning:: Although it's possible to return other values than ``True``, for +.. warning:: Although it's possible to return other values than ``True``, for example an object which also evluates to True, we highly advise to only return booleans. @@ -86,7 +86,7 @@ In your python code :: from myapp.permissions import FlatPagePermission - def my_view(request): + def my_view(request): check = FlatPagePermission(request.user) flatpage_object = Flatpage.objects.get(url='/homepage/') if check.my_custom_check(flatpage=flatpage_object): @@ -103,9 +103,9 @@ Using the view decorator (Flatpage, 'url__iexact', 'url')) # The flatpage_object def my_view(request, url): # ... - + See :ref:`check-decorator` how the decorator works in detail. - + In your templates ----------------- :: From 5ce50c034190b3334dc2bc96252ccef771ee6fed Mon Sep 17 00:00:00 2001 From: Randall Degges Date: Mon, 21 Feb 2011 09:01:51 -0800 Subject: [PATCH 2/4] Fixing wording 'more simpler' -> 'simpler'. --- docs/create_custom_permission.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/create_custom_permission.txt b/docs/create_custom_permission.txt index 4630e19..1ca2ce6 100644 --- a/docs/create_custom_permission.txt +++ b/docs/create_custom_permission.txt @@ -51,9 +51,8 @@ permission is True or False:: example an object which also evluates to True, we highly advise to only return booleans. -Custom permissions are not necessary related to a model, you can define more -simpler permissions too. For example, return True if it's between 10 and 12 -o'clock:: +Custom permissions are not necessary related to a model, you can define simpler +permissions too. For example, return True if it's between 10 and 12 o'clock:: def datetime_check(self): hour = int(datetime.datetime.now().strftime("%H")) From 3f3f06dda0e0e668f6ab6a1fc91373437714c9af Mon Sep 17 00:00:00 2001 From: Randall Degges Date: Mon, 21 Feb 2011 09:04:31 -0800 Subject: [PATCH 3/4] Removing trailing whitespace. --- docs/check_decorator.txt | 14 +++++++------- docs/check_python.txt | 2 +- docs/check_templates.txt | 4 ++-- docs/configuration.txt | 4 ++-- docs/create_basic_permission.txt | 8 ++++---- docs/create_per_object_permission.txt | 10 +++++----- docs/documentation_guidelines.txt | 10 +++++----- docs/handling_python.txt | 2 +- docs/handling_template.txt | 2 +- docs/index.txt | 14 +++++++------- docs/installation.txt | 4 ++-- 11 files changed, 37 insertions(+), 37 deletions(-) diff --git a/docs/check_decorator.txt b/docs/check_decorator.txt index 100f677..3461b99 100644 --- a/docs/check_decorator.txt +++ b/docs/check_decorator.txt @@ -19,10 +19,10 @@ Lets start with an example permission:: class FlatpagePermission(permissions.BasePermission): label = 'flatpage_permission' checks = ('can_do_foo',) - + def can_do_foo(self): # ... - + authority.register(Campaign, FlatpagePermission) A decorator for such a simple view would look like:: @@ -53,12 +53,12 @@ a string on the decorator:: @permission_required('flatpage_permission.can_do_foo', 'arg1', 'arg2') def my_view(required, arg1, arg2): # ... - + What happens under the hood?:: # Assumed the view gets called like this my_view(request, 'bla', 'blubb') - + # At the end, the decorator would been called like this can_do_foo('bla', 'blubb') @@ -78,9 +78,9 @@ Here is an example:: # permission.py def can_do_foo(self, flatpage_instance=None): # ... - - # views.py - from django.contrib.flatpages.models import Flatpage + + # views.py + from django.contrib.flatpages.models import Flatpage @permission_required('flatpage_permission.can_do_foo', (Flatpage, 'url__iexact', 'url)) def flatpage(required, url): # ... diff --git a/docs/check_python.txt b/docs/check_python.txt index 3dce90a..46a3858 100644 --- a/docs/check_python.txt +++ b/docs/check_python.txt @@ -4,4 +4,4 @@ Check permissions in python code ================================ -*to be written* \ No newline at end of file +*to be written* diff --git a/docs/check_templates.txt b/docs/check_templates.txt index f84566c..92ba89a 100644 --- a/docs/check_templates.txt +++ b/docs/check_templates.txt @@ -50,7 +50,7 @@ Syntax and example:: {% get_permissions obj as "my_permissions" %} {% get_permissions obj for request.user as "my_permissions" %} - + get_permission ============== @@ -66,7 +66,7 @@ Example:: {% get_permission "poll_permission.change_poll" for request.user and poll as "is_allowed" %} {% get_permission "poll_permission.change_poll" for request.user and poll,second_poll as "is_allowed" %} - + {% if is_allowed %} I've got ze power to change ze pollllllzzz. Muahahaa. {% else %} diff --git a/docs/configuration.txt b/docs/configuration.txt index 6456b71..bcf734a 100644 --- a/docs/configuration.txt +++ b/docs/configuration.txt @@ -1,5 +1,5 @@ .. _configuration: - + ============= Configuration ============= @@ -31,7 +31,7 @@ context processors:: 'django.core.context_processors.media', 'django.core.context_processors.request', ) - + urls.py ======= diff --git a/docs/create_basic_permission.txt b/docs/create_basic_permission.txt index 47a2a36..2920f8f 100644 --- a/docs/create_basic_permission.txt +++ b/docs/create_basic_permission.txt @@ -70,7 +70,7 @@ In your python code ------------------- :: - def my_view(request): + def my_view(request): check = FlatPagePermission(request.user) if check.change_flatpage(): print "Yay, you can change a flatpage!" @@ -84,9 +84,9 @@ Using the view decorator @permission_required_or_403('flatpage_permission.change_flatpage') def my_view(request): # ... - + See :ref:`check-decorator` how the decorator works in detail. - + In your templates ----------------- :: @@ -108,7 +108,7 @@ applications. See :ref:`configuration` how to set up ``autodiscover``. .. image:: .static/authority-permission-py.png :align: left - + We encourage you to place your permission classes in a file called ``permissions.py`` inside your application directories. This will not only keep your application files clean, but it will also load every permission diff --git a/docs/create_per_object_permission.txt b/docs/create_per_object_permission.txt index bdec807..bd2c0b4 100644 --- a/docs/create_per_object_permission.txt +++ b/docs/create_per_object_permission.txt @@ -9,7 +9,7 @@ permission*. A description would be:: Attach a to an object Attach a to an user - + If the user has and the object has then do-something, otherwise do-something-else. @@ -39,7 +39,7 @@ Create per-object permissions Creating per-object permissions is super simple. See this piece of permission class code:: - + class FlatPagePermission(BasePermission): label = 'flatpage_permission' checks = ('review',) @@ -85,7 +85,7 @@ In your python code :: from myapp.permissions import FlatPagePermission - def my_view(request): + def my_view(request): check = FlatPagePermission(request.user) flatpage_object = Flatpage.objects.get(url='/homepage/') if check.review_flatpage(flatpage_object): @@ -102,9 +102,9 @@ Using the view decorator (Flatpage, 'url__iexact', 'url')) # The flatpage_object def my_view(request, url): # ... - + See :ref:`check-decorator` how the decorator works in detail. - + In your templates ----------------- :: diff --git a/docs/documentation_guidelines.txt b/docs/documentation_guidelines.txt index 13b76dd..fc8d6db 100644 --- a/docs/documentation_guidelines.txt +++ b/docs/documentation_guidelines.txt @@ -13,13 +13,13 @@ Headline scheme =================================== First level (equals top and bottom) =================================== - + Second Level (equals bottom) ============================ - + Third level (dashes botton) --------------------------- - + Fourth level (drunken dashes bottom) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -31,10 +31,10 @@ Overall salutation guidelines Use the *We* and *you*:: We think that you should send us a bottle of your local beer. - + Some thoughts ============= * Many internal links are good * Text should not be wider than 80 characters -* Two pages are better than one ultra-long page \ No newline at end of file +* Two pages are better than one ultra-long page diff --git a/docs/handling_python.txt b/docs/handling_python.txt index 023a9b1..33ea6be 100644 --- a/docs/handling_python.txt +++ b/docs/handling_python.txt @@ -4,4 +4,4 @@ Handling permissions in python code =================================== -*to be written* \ No newline at end of file +*to be written* diff --git a/docs/handling_template.txt b/docs/handling_template.txt index ab9b718..8f5e0d8 100644 --- a/docs/handling_template.txt +++ b/docs/handling_template.txt @@ -4,4 +4,4 @@ Handling permissions using templates ==================================== -*to be written* \ No newline at end of file +*to be written* diff --git a/docs/index.txt b/docs/index.txt index a632664..6f9fda9 100644 --- a/docs/index.txt +++ b/docs/index.txt @@ -37,15 +37,15 @@ Documentation .. toctree:: :maxdepth: 1 - + installation configuration **Create and check permissions:** - + .. toctree:: :maxdepth: 1 - + create_basic_permission create_per_object_permission create_custom_permission @@ -54,7 +54,7 @@ Documentation .. toctree:: :maxdepth: 2 - + check_python check_decorator check_templates @@ -63,21 +63,21 @@ Documentation .. toctree:: :maxdepth: 1 - + handling_python handling_admin handling_template Other pages =========== - + * :ref:`search` * :ref:`genindex` .. toctree:: :maxdepth: 1 :glob: - + tips_tricks support documentation_guidelines diff --git a/docs/installation.txt b/docs/installation.txt index 9ccbafb..c85fc38 100644 --- a/docs/installation.txt +++ b/docs/installation.txt @@ -15,9 +15,9 @@ The latest, stable version is always available via the `Python package index_` would prefer either ``pip`` or ``easy_install``:: pip install django-authority - + # .. or with easy_install: - + easy_install django-authority .. _the site: http://pypi.python.org/pypi/django-authority/ From b50fb665126870a214950d1b97e6ad802b4beded Mon Sep 17 00:00:00 2001 From: Randall Degges Date: Mon, 21 Feb 2011 09:09:32 -0800 Subject: [PATCH 4/4] Adding missing ' (to enclose the string). --- docs/check_decorator.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/check_decorator.txt b/docs/check_decorator.txt index 3461b99..e51b8e6 100644 --- a/docs/check_decorator.txt +++ b/docs/check_decorator.txt @@ -81,7 +81,7 @@ Here is an example:: # views.py from django.contrib.flatpages.models import Flatpage - @permission_required('flatpage_permission.can_do_foo', (Flatpage, 'url__iexact', 'url)) + @permission_required('flatpage_permission.can_do_foo', (Flatpage, 'url__iexact', 'url')) def flatpage(required, url): # ...