Exemple #1
0
def write_authorized(user, collection):
    """Check if the user is allowed to write the collection."""
    if owner_only.read_authorized(user, collection):
        return True

    curl = _normalize_trail_slash(collection.url)

    return _dict_knows(WRITE_AUTHORIZED, curl, user)
def read_authorized(user, collection):
    """Check if the user is allowed to read the collection."""
    is_group_collection, allowed = group_collection(user, collection)
    if is_group_collection == True:
        return allowed
    return (
            owner_only.read_authorized(user, collection) or
            "r" in RIGHTS.get(collection.url.rstrip("/") or "/", user))
Exemple #3
0
def write_authorized(user, collection):
    """Check if the user is allowed to write the collection."""
    if owner_only.read_authorized(user, collection):
        return True
    else:
        try:
            return "w" in RIGHTS.get(collection.url.rstrip("/") or "/", user)
        except (NoSectionError, NoOptionError):
            return False
Exemple #4
0
def read_authorized(user, collection):
    """Check if the user is allowed to read the collection."""
    if user is None:
        return False
    elif owner_only.read_authorized(user, collection):
        return True
    else:
        try:
            return "r" in _read_rights().get(
                collection.url.rstrip("/") or "/", user)
        except (NoSectionError, NoOptionError):
            return False
Exemple #5
0
def read_authorized(user, collection):
    """Check if the user is allowed to read the collection."""
    return (
        owner_only.read_authorized(user, collection) or
        "r" in RIGHTS.get(collection.url.rstrip("/") or "/", user))