def test_perm_is_defined_on(self): """Test permission relationship Test whether we check for permission relationship, independent of whether the permission is actually assigned to anyone. """ perm = 'forums_forum.view_in_forum' assert access.perm_is_defined_on(perm, Forum.objects.get(pk=3)) assert not access.perm_is_defined_on(perm, Forum.objects.get(pk=2))
def _allows_public_viewing(self): """Return whether I am a world-readable forum. If a django-authority permission relates to me, I am considered non- public. (We assume that you attached a permission to me in order to assign it to some users or groups.) Considered adding a Public flag to this model, but we didn't want it to show up on form and thus be accidentally flippable by readers of the Admin forum, who are all privileged enough to do so. """ return not perm_is_defined_on('forums_forum.view_in_forum', self)
def _allows_public_posting(self): """Return whether I am a world-writable forum.""" return not perm_is_defined_on('forums_forum.post_in_forum', self)