def user_has_view_permission(user, page=None):
    if not user:
        return False

    class FakeRequest(object):
        pass
    fake_request = FakeRequest()

    can_see_unrestricted = get_cms_setting('PUBLIC_FOR') == 'all' or (
        get_cms_setting('PUBLIC_FOR') == 'staff' and user.is_staff)

    # Inherited and direct view permissions
    is_restricted = bool(
        permissions.get_any_page_view_permissions(fake_request, page))

    if not is_restricted and can_see_unrestricted:
        return True
    elif not user.is_authenticated():
        return False

    if not is_restricted:
        # a global permission was given to the request's user
        if permissions.has_global_page_permission(
                fake_request, page.site_id, user=user, can_view=True):
            return True
    else:
        # a specific permission was granted to the request's user
        if page.get_draft_object().has_generic_permission(
                fake_request, "view", user=user):
            return True

    # The user has a normal django permission to view pages globally
    opts = page._meta
    codename = '%s.view_%s' % (opts.app_label, opts.object_name.lower())
    return user.has_perm(codename)
A git repository.
dataset/ETHPy150Open divio/django-cms/cms/forms/wizards.py/user_has_view_permission--crossover with--dataset/ETHPy150Open tony/vcspull/vcspull/repo/git.py/GitRepo.__init__