Django

Code

Changeset 1302

Show
Ignore:
Timestamp:
11/20/05 10:35:44 (3 years ago)
Author:
adrian
Message:

Fixed #848 -- Made auth docs more clear on permission handling.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/authentication.txt

    r1221 r1302  
    5050    * ``is_staff`` -- Boolean. Designates whether this user can access the 
    5151      admin site. 
    52     * ``is_active`` -- Boolean. Designates whether this user account is valid. 
    53       Set this to ``False`` instead of deleting accounts. 
    54     * ``is_superuser`` -- Boolean. Designates whether this user has permission 
    55       to do anything (according to the permission system)
     52    * ``is_active`` -- Boolean. Designates whether this user can log into the 
     53      Django admin. Set this to ``False`` instead of deleting accounts. 
     54    * ``is_superuser`` -- Boolean. Designates that this user has all permissions 
     55      without explicitly assigning them
    5656    * ``last_login`` -- A datetime of the user's last login. Is set to the 
    5757      current date/time by default. 
     
    9494 
    9595    * ``has_perm(perm)`` -- Returns ``True`` if the user has the specified 
    96       permission
     96      permission, where perm is in the format ``"package.codename"``
    9797 
    9898    * ``has_perms(perm_list)`` -- Returns ``True`` if the user has each of the 
    99       specified permissions. 
     99      specified permissions, where each perm is in the format 
     100      ``"package.codename"``. 
    100101 
    101102    * ``has_module_perms(package_name)`` -- Returns ``True`` if the user has 
     
    272273 
    273274As a shortcut, you can use the convenient ``user_passes_test`` decorator:: 
     275 
     276    from django.views.decorators.auth import user_passes_test 
     277 
     278    def my_view(request): 
     279        # ... 
     280    my_view = user_passes_test(my_view, lambda u: u.has_perm('polls.can_vote')) 
     281 
     282Here's the same thing, using Python 2.4's decorator syntax:: 
    274283 
    275284    from django.views.decorators.auth import user_passes_test