Hints, tips and tricks — django-authority v0.2 documentation

### Navigation

- index
- next |
- previous |
- django-authority v0.2 documentation »

# Hints, tips and tricks

Within a permission class, you can refer to the user and group using self:

    class CampaignPermission(permissions.BasePermission):
        label = 'campaign_permission'
        checks = ('do_foo',)

        def do_foo(self, campaign=None):
            print self.user
            print self.group
            # ...

You can unregister permission classes and re-register them:

    authority.unregister(Campaign)
    authority.register(Campaign, CampaignPermission)

Within a permission class, you can refer to Django’s basic permissions:

    class FlagpagePermisson(permissions.BasePermission):
        label = 'flatpage_permission'
        checks = ('do_foo',)

        def do_foo(self, campaign=None):
            if foo and self.change_flatpage():
                # ...

    authority.register(Flatpage, FlagpagePermisson)

### Navigation

- index
- next |
- previous |
- django-authority v0.2 documentation »