def test_public_access(self): # Assert Forums think they're publicly viewable and postable # at appropriate times. # By default, users have access to forums that aren't restricted. u = UserFactory() f = ForumFactory() assert f.allows_viewing_by(u) assert f.allows_posting_by(u)
def test_public_access(self): # Assert Forums think they're publicly viewable and postable # at appropriate times. # By default, users have access to forums that aren't restricted. u = UserFactory() f = ForumFactory() assert f.allows_viewing_by(u) assert f.allows_posting_by(u)
def test_access_restriction(self): """Assert Forums are inaccessible to the public when restricted.""" # If the a forum has 'forums_forum.view_in_forum' permission defined, # then it isn't public by default. If it has # 'forums_forum.post_in_forum', then it isn't postable to by default. f = ForumFactory() ct = ContentType.objects.get_for_model(f) PermissionFactory(codename='forums_forum.view_in_forum', content_type=ct, object_id=f.id) PermissionFactory(codename='forums_forum.post_in_forum', content_type=ct, object_id=f.id) unprivileged_user = UserFactory() assert not f.allows_viewing_by(unprivileged_user) assert not f.allows_posting_by(unprivileged_user)
def test_access_restriction(self): """Assert Forums are inaccessible to the public when restricted.""" # If the a forum has 'forums_forum.view_in_forum' permission defined, # then it isn't public by default. If it has # 'forums_forum.post_in_forum', then it isn't postable to by default. f = ForumFactory() ct = ContentType.objects.get_for_model(f) PermissionFactory(codename='forums_forum.view_in_forum', content_type=ct, object_id=f.id) PermissionFactory(codename='forums_forum.post_in_forum', content_type=ct, object_id=f.id) unprivileged_user = UserFactory() assert not f.allows_viewing_by(unprivileged_user) assert not f.allows_posting_by(unprivileged_user)