Beispiel #1
0
def instance_permissions(user, instance=None):
    """ How should this user see this instance? Figure's out the user's status
    compared to the instance, then figures owner/group/world for the user,
    then fires off a new copy of that permissions dictionary for that role.

    If instance is missing, we're talking about this site's group and user as
    figured in the settings.
    """
    if not instance:
        top_group = user.status_over(SITE_GROUP)
        user_role = _figure_role((SITE_OWNER.pk, SITE_GROUP.name), 
                                  user.pk,
                                  user.all_group_ids)
    else:
        top_group = user.status_over(instance.group)
        user_role = role_for(user, instance)
    return narrow_config(top_group.name)[user_role]
Beispiel #2
0
def api_for(user_role, group=None):
    config = narrow_config(group)[user_role]
    return {user_role: api_dict(config=config)}